0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

View file

@ -0,0 +1,17 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface NotchedOutlineProps
extends StandardProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, NotchedOutlineClassKey> {
disabled?: boolean;
error?: boolean;
focused?: boolean;
labelWidth: number;
notched: boolean;
}
export type NotchedOutlineClassKey = 'root' | 'legend' | 'focused' | 'error' | 'disabled';
declare const NotchedOutline: React.ComponentType<NotchedOutlineProps>;
export default NotchedOutline;

View file

@ -0,0 +1,188 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.styles = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _clsx = _interopRequireDefault(require("clsx"));
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
var _useTheme = _interopRequireDefault(require("../styles/useTheme"));
var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
var styles = function styles(theme) {
return {
/* Styles applied to the root element. */
root: {
position: 'absolute',
bottom: 0,
right: 0,
top: -5,
left: 0,
margin: 0,
padding: '0 8px',
pointerEvents: 'none',
borderRadius: 'inherit',
borderStyle: 'solid',
borderWidth: 1,
overflow: 'hidden'
},
/* Styles applied to the legend element when `labelWidth` is provided. */
legend: {
textAlign: 'left',
padding: 0,
lineHeight: '11px',
// sync with `height` in `legend` styles
transition: theme.transitions.create('width', {
duration: 150,
easing: theme.transitions.easing.easeOut
})
},
/* Styles applied to the legend element. */
legendLabelled: {
display: 'block',
width: 'auto',
textAlign: 'left',
padding: 0,
height: 11,
// sync with `lineHeight` in `legend` styles
fontSize: '0.75em',
visibility: 'hidden',
maxWidth: 0.01,
transition: theme.transitions.create('max-width', {
duration: 50,
easing: theme.transitions.easing.easeOut
}),
'& > span': {
paddingLeft: 5,
paddingRight: 5,
display: 'inline-block'
}
},
/* Styles applied to the legend element is notched. */
legendNotched: {
maxWidth: 1000,
transition: theme.transitions.create('max-width', {
duration: 100,
easing: theme.transitions.easing.easeOut,
delay: 50
})
}
};
};
/**
* @ignore - internal component.
*/
exports.styles = styles;
var NotchedOutline = /*#__PURE__*/React.forwardRef(function NotchedOutline(props, ref) {
var children = props.children,
classes = props.classes,
className = props.className,
label = props.label,
labelWidthProp = props.labelWidth,
notched = props.notched,
style = props.style,
other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "label", "labelWidth", "notched", "style"]);
var theme = (0, _useTheme.default)();
var align = theme.direction === 'rtl' ? 'right' : 'left';
if (label !== undefined) {
return /*#__PURE__*/React.createElement("fieldset", (0, _extends3.default)({
"aria-hidden": true,
className: (0, _clsx.default)(classes.root, className),
ref: ref,
style: style
}, other), /*#__PURE__*/React.createElement("legend", {
className: (0, _clsx.default)(classes.legendLabelled, notched && classes.legendNotched)
}, label ? /*#__PURE__*/React.createElement("span", null, label) : /*#__PURE__*/React.createElement("span", {
dangerouslySetInnerHTML: {
__html: '&#8203;'
}
})));
}
var labelWidth = labelWidthProp > 0 ? labelWidthProp * 0.75 + 8 : 0.01;
return /*#__PURE__*/React.createElement("fieldset", (0, _extends3.default)({
"aria-hidden": true,
style: (0, _extends3.default)((0, _defineProperty2.default)({}, "padding".concat((0, _capitalize.default)(align)), 8), style),
className: (0, _clsx.default)(classes.root, className),
ref: ref
}, other), /*#__PURE__*/React.createElement("legend", {
className: classes.legend,
style: {
// IE 11: fieldset with legend does not render
// a border radius. This maintains consistency
// by always having a legend rendered
width: notched ? labelWidth : 0.01
}
}, /*#__PURE__*/React.createElement("span", {
dangerouslySetInnerHTML: {
__html: '&#8203;'
}
})));
});
process.env.NODE_ENV !== "production" ? NotchedOutline.propTypes = {
/**
* The content of the component.
*/
children: _propTypes.default.node,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: _propTypes.default.object,
/**
* @ignore
*/
className: _propTypes.default.string,
/**
* The label.
*/
label: _propTypes.default.node,
/**
* The width of the label.
*/
labelWidth: _propTypes.default.number.isRequired,
/**
* If `true`, the outline is notched to accommodate the label.
*/
notched: _propTypes.default.bool.isRequired,
/**
* @ignore
*/
style: _propTypes.default.object
} : void 0;
var _default = (0, _withStyles.default)(styles, {
name: 'PrivateNotchedOutline'
})(NotchedOutline);
exports.default = _default;

View file

@ -0,0 +1,50 @@
import * as React from 'react';
import { StandardProps } from '..';
import { InputBaseProps } from '../InputBase';
export interface OutlinedInputProps extends StandardProps<InputBaseProps, OutlinedInputClassKey> {
/**
* The label of the input. It is only used for layout. The actual labelling
* is handled by `InputLabel`. If specified `labelWidth` is ignored.
*/
label?: React.ReactNode;
/**
* The width of the label. Is ignored if `label` is provided. Prefer `label`
* if the input label appears with a strike through.
*/
labelWidth?: number;
/**
* If `true`, the outline is notched to accommodate the label.
*/
notched?: boolean;
}
export type OutlinedInputClassKey =
| 'root'
| 'colorSecondary'
| 'focused'
| 'disabled'
| 'adornedStart'
| 'adornedEnd'
| 'error'
| 'marginDense'
| 'multiline'
| 'notchedOutline'
| 'input'
| 'inputMarginDense'
| 'inputMultiline'
| 'inputAdornedStart'
| 'inputAdornedEnd';
/**
*
* Demos:
*
* - [Text Fields](https://material-ui.com/components/text-fields/)
*
* API:
*
* - [OutlinedInput API](https://material-ui.com/api/outlined-input/)
* - inherits [InputBase API](https://material-ui.com/api/input-base/)
*/
export default function OutlinedInput(props: OutlinedInputProps): JSX.Element;

View file

@ -0,0 +1,335 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.styles = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _clsx = _interopRequireDefault(require("clsx"));
var _utils = require("@material-ui/utils");
var _InputBase = _interopRequireDefault(require("../InputBase"));
var _NotchedOutline = _interopRequireDefault(require("./NotchedOutline"));
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
var styles = function styles(theme) {
var borderColor = theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)';
return {
/* Styles applied to the root element. */
root: {
position: 'relative',
borderRadius: theme.shape.borderRadius,
'&:hover $notchedOutline': {
borderColor: theme.palette.text.primary
},
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
'&:hover $notchedOutline': {
borderColor: borderColor
}
},
'&$focused $notchedOutline': {
borderColor: theme.palette.primary.main,
borderWidth: 2
},
'&$error $notchedOutline': {
borderColor: theme.palette.error.main
},
'&$disabled $notchedOutline': {
borderColor: theme.palette.action.disabled
}
},
/* Styles applied to the root element if the color is secondary. */
colorSecondary: {
'&$focused $notchedOutline': {
borderColor: theme.palette.secondary.main
}
},
/* Styles applied to the root element if the component is focused. */
focused: {},
/* Styles applied to the root element if `disabled={true}`. */
disabled: {},
/* Styles applied to the root element if `startAdornment` is provided. */
adornedStart: {
paddingLeft: 14
},
/* Styles applied to the root element if `endAdornment` is provided. */
adornedEnd: {
paddingRight: 14
},
/* Pseudo-class applied to the root element if `error={true}`. */
error: {},
/* Styles applied to the `input` element if `margin="dense"`. */
marginDense: {},
/* Styles applied to the root element if `multiline={true}`. */
multiline: {
padding: '18.5px 14px',
'&$marginDense': {
paddingTop: 10.5,
paddingBottom: 10.5
}
},
/* Styles applied to the `NotchedOutline` element. */
notchedOutline: {
borderColor: borderColor
},
/* Styles applied to the `input` element. */
input: {
padding: '18.5px 14px',
'&:-webkit-autofill': {
WebkitBoxShadow: theme.palette.type === 'light' ? null : '0 0 0 100px #266798 inset',
WebkitTextFillColor: theme.palette.type === 'light' ? null : '#fff',
caretColor: theme.palette.type === 'light' ? null : '#fff',
borderRadius: 'inherit'
}
},
/* Styles applied to the `input` element if `margin="dense"`. */
inputMarginDense: {
paddingTop: 10.5,
paddingBottom: 10.5
},
/* Styles applied to the `input` element if `multiline={true}`. */
inputMultiline: {
padding: 0
},
/* Styles applied to the `input` element if `startAdornment` is provided. */
inputAdornedStart: {
paddingLeft: 0
},
/* Styles applied to the `input` element if `endAdornment` is provided. */
inputAdornedEnd: {
paddingRight: 0
}
};
};
exports.styles = styles;
var OutlinedInput = /*#__PURE__*/React.forwardRef(function OutlinedInput(props, ref) {
var classes = props.classes,
_props$fullWidth = props.fullWidth,
fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
_props$inputComponent = props.inputComponent,
inputComponent = _props$inputComponent === void 0 ? 'input' : _props$inputComponent,
label = props.label,
_props$labelWidth = props.labelWidth,
labelWidth = _props$labelWidth === void 0 ? 0 : _props$labelWidth,
_props$multiline = props.multiline,
multiline = _props$multiline === void 0 ? false : _props$multiline,
notched = props.notched,
_props$type = props.type,
type = _props$type === void 0 ? 'text' : _props$type,
other = (0, _objectWithoutProperties2.default)(props, ["classes", "fullWidth", "inputComponent", "label", "labelWidth", "multiline", "notched", "type"]);
return /*#__PURE__*/React.createElement(_InputBase.default, (0, _extends2.default)({
renderSuffix: function renderSuffix(state) {
return /*#__PURE__*/React.createElement(_NotchedOutline.default, {
className: classes.notchedOutline,
label: label,
labelWidth: labelWidth,
notched: typeof notched !== 'undefined' ? notched : Boolean(state.startAdornment || state.filled || state.focused)
});
},
classes: (0, _extends2.default)({}, classes, {
root: (0, _clsx.default)(classes.root, classes.underline),
notchedOutline: null
}),
fullWidth: fullWidth,
inputComponent: inputComponent,
multiline: multiline,
ref: ref,
type: type
}, other));
});
process.env.NODE_ENV !== "production" ? OutlinedInput.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the d.ts file and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* This prop helps users to fill forms faster, especially on mobile devices.
* The name can be confusing, as it's more like an autofill.
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
*/
autoComplete: _propTypes.default.string,
/**
* If `true`, the `input` element will be focused during the first mount.
*/
autoFocus: _propTypes.default.bool,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: _propTypes.default.object,
/**
* The color of the component. It supports those theme colors that make sense for this component.
*/
color: _propTypes.default.oneOf(['primary', 'secondary']),
/**
* The default `input` element value. Use when the component is not controlled.
*/
defaultValue: _propTypes.default.any,
/**
* If `true`, the `input` element will be disabled.
*/
disabled: _propTypes.default.bool,
/**
* End `InputAdornment` for this component.
*/
endAdornment: _propTypes.default.node,
/**
* If `true`, the input will indicate an error. This is normally obtained via context from
* FormControl.
*/
error: _propTypes.default.bool,
/**
* If `true`, the input will take up the full width of its container.
*/
fullWidth: _propTypes.default.bool,
/**
* The id of the `input` element.
*/
id: _propTypes.default.string,
/**
* The component used for the `input` element.
* Either a string to use a HTML element or a component.
*/
inputComponent: _propTypes.default.elementType,
/**
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
*/
inputProps: _propTypes.default.object,
/**
* Pass a ref to the `input` element.
*/
inputRef: _utils.refType,
/**
* The label of the input. It is only used for layout. The actual labelling
* is handled by `InputLabel`. If specified `labelWidth` is ignored.
*/
label: _propTypes.default.node,
/**
* The width of the label. Is ignored if `label` is provided. Prefer `label`
* if the input label appears with a strike through.
*/
labelWidth: _propTypes.default.number,
/**
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
* FormControl.
*/
margin: _propTypes.default.oneOf(['dense', 'none']),
/**
* Maximum number of rows to display when multiline option is set to true.
*/
maxRows: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
/**
* If `true`, a textarea element will be rendered.
*/
multiline: _propTypes.default.bool,
/**
* Name attribute of the `input` element.
*/
name: _propTypes.default.string,
/**
* If `true`, the outline is notched to accommodate the label.
*/
notched: _propTypes.default.bool,
/**
* Callback fired when the value is changed.
*
* @param {object} event The event source of the callback.
* You can pull out the new value by accessing `event.target.value` (string).
*/
onChange: _propTypes.default.func,
/**
* The short hint displayed in the input before the user enters a value.
*/
placeholder: _propTypes.default.string,
/**
* It prevents the user from changing the value of the field
* (not from interacting with the field).
*/
readOnly: _propTypes.default.bool,
/**
* If `true`, the `input` element will be required.
*/
required: _propTypes.default.bool,
/**
* Number of rows to display when multiline option is set to true.
*/
rows: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
/**
* Start `InputAdornment` for this component.
*/
startAdornment: _propTypes.default.node,
/**
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
*/
type: _propTypes.default.string,
/**
* The value of the `input` element, required for a controlled component.
*/
value: _propTypes.default.any
} : void 0;
OutlinedInput.muiName = 'Input';
var _default = (0, _withStyles.default)(styles, {
name: 'MuiOutlinedInput'
})(OutlinedInput);
exports.default = _default;

View file

@ -0,0 +1,2 @@
export { default } from './OutlinedInput';
export * from './OutlinedInput';

View file

@ -0,0 +1,15 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function get() {
return _OutlinedInput.default;
}
});
var _OutlinedInput = _interopRequireDefault(require("./OutlinedInput"));

View file

@ -0,0 +1,5 @@
{
"sideEffects": false,
"module": "../esm/OutlinedInput/index.js",
"typings": "./index.d.ts"
}