@doist/reactist 12.0.4 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/reactist.cjs.development.js +153 -651
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/components/color-picker/color-picker.js +4 -4
- package/es/components/color-picker/color-picker.js.map +1 -1
- package/es/components/{dropdown → deprecated-dropdown}/dropdown.js +0 -0
- package/es/components/deprecated-dropdown/dropdown.js.map +1 -0
- package/es/components/{dropdown → deprecated-dropdown}/index.js +0 -0
- package/es/components/{checkbox → deprecated-dropdown}/index.js.map +0 -0
- package/es/components/{input → deprecated-input}/index.js +0 -0
- package/es/components/{dropdown → deprecated-input}/index.js.map +0 -0
- package/es/components/{input → deprecated-input}/input.js +0 -0
- package/es/components/deprecated-input/input.js.map +1 -0
- package/es/components/{select → deprecated-select}/index.js +0 -0
- package/es/components/{input → deprecated-select}/index.js.map +0 -0
- package/es/components/{select → deprecated-select}/select.js +0 -0
- package/es/components/deprecated-select/select.js.map +1 -0
- package/es/index.js +3 -7
- package/es/index.js.map +1 -1
- package/es/new-components/base-button/base-button.js +12 -9
- package/es/new-components/base-button/base-button.js.map +1 -1
- package/es/new-components/base-button/base-button.module.css.js +1 -1
- package/es/new-components/base-field/base-field.js +60 -16
- package/es/new-components/base-field/base-field.js.map +1 -1
- package/es/new-components/base-field/base-field.module.css.js +1 -1
- package/es/new-components/password-field/password-field.js +8 -2
- package/es/new-components/password-field/password-field.js.map +1 -1
- package/es/new-components/password-field/password-field.module.css.js +1 -1
- package/es/new-components/select-field/select-field.js +6 -2
- package/es/new-components/select-field/select-field.js.map +1 -1
- package/es/new-components/select-field/select-field.module.css.js +1 -1
- package/es/new-components/text/text.module.css.js +1 -1
- package/es/new-components/text-area/text-area.js +10 -3
- package/es/new-components/text-area/text-area.js.map +1 -1
- package/es/new-components/text-area/text-area.module.css.js +1 -1
- package/es/new-components/text-field/text-field.js +8 -2
- package/es/new-components/text-field/text-field.js.map +1 -1
- package/es/new-components/text-field/text-field.module.css.js +1 -1
- package/lib/components/color-picker/color-picker.js +1 -1
- package/lib/components/color-picker/color-picker.js.map +1 -1
- package/lib/components/{dropdown → deprecated-dropdown}/dropdown.d.ts +0 -0
- package/lib/components/{dropdown → deprecated-dropdown}/dropdown.js +0 -0
- package/lib/components/deprecated-dropdown/dropdown.js.map +1 -0
- package/lib/components/{dropdown → deprecated-dropdown}/dropdown.test.d.ts +0 -0
- package/lib/components/{dropdown → deprecated-dropdown}/index.d.ts +0 -0
- package/lib/components/{dropdown → deprecated-dropdown}/index.js +0 -0
- package/lib/components/{checkbox → deprecated-dropdown}/index.js.map +0 -0
- package/lib/components/{input → deprecated-input}/index.d.ts +0 -0
- package/lib/components/{input → deprecated-input}/index.js +0 -0
- package/lib/components/{dropdown → deprecated-input}/index.js.map +0 -0
- package/lib/components/{input → deprecated-input}/input.d.ts +0 -0
- package/lib/components/{input → deprecated-input}/input.js +0 -0
- package/lib/components/deprecated-input/input.js.map +1 -0
- package/lib/components/{input → deprecated-input}/input.test.d.ts +0 -0
- package/lib/components/{select → deprecated-select}/index.d.ts +0 -0
- package/lib/components/{select → deprecated-select}/index.js +0 -0
- package/lib/components/{input → deprecated-select}/index.js.map +0 -0
- package/lib/components/{select → deprecated-select}/select.d.ts +0 -0
- package/lib/components/{select → deprecated-select}/select.js +0 -0
- package/lib/components/deprecated-select/select.js.map +1 -0
- package/lib/components/{select → deprecated-select}/select.test.d.ts +0 -0
- package/lib/index.d.ts +3 -7
- package/lib/index.js +1 -1
- package/lib/new-components/base-button/base-button.d.ts +7 -4
- package/lib/new-components/base-button/base-button.js +1 -1
- package/lib/new-components/base-button/base-button.js.map +1 -1
- package/lib/new-components/base-button/base-button.module.css.js +1 -1
- package/lib/new-components/base-field/base-field.d.ts +66 -9
- package/lib/new-components/base-field/base-field.js +1 -1
- package/lib/new-components/base-field/base-field.js.map +1 -1
- package/lib/new-components/base-field/base-field.module.css.js +1 -1
- package/lib/new-components/password-field/password-field.d.ts +3 -2
- package/lib/new-components/password-field/password-field.js +1 -1
- package/lib/new-components/password-field/password-field.js.map +1 -1
- package/lib/new-components/password-field/password-field.module.css.js +1 -1
- package/lib/new-components/select-field/select-field.d.ts +1 -1
- package/lib/new-components/select-field/select-field.js +1 -1
- package/lib/new-components/select-field/select-field.js.map +1 -1
- package/lib/new-components/select-field/select-field.module.css.js +1 -1
- package/lib/new-components/switch-field/switch-field.d.ts +1 -1
- package/lib/new-components/text/text.module.css.js +1 -1
- package/lib/new-components/text-area/text-area.d.ts +3 -3
- package/lib/new-components/text-area/text-area.js +1 -1
- package/lib/new-components/text-area/text-area.js.map +1 -1
- package/lib/new-components/text-area/text-area.module.css.js +1 -1
- package/lib/new-components/text-field/text-field.d.ts +3 -2
- package/lib/new-components/text-field/text-field.js +1 -1
- package/lib/new-components/text-field/text-field.js.map +1 -1
- package/lib/new-components/text-field/text-field.module.css.js +1 -1
- package/package.json +1 -1
- package/styles/alert.css +1 -1
- package/styles/base-button.css +1 -1
- package/styles/base-button.module.css.css +1 -1
- package/styles/base-field.css +4 -3
- package/styles/base-field.module.css.css +1 -1
- package/styles/checkbox-field.css +1 -1
- package/styles/modal.css +1 -1
- package/styles/password-field.css +5 -4
- package/styles/password-field.module.css.css +1 -1
- package/styles/reactist.css +11 -15
- package/styles/select-field.css +4 -3
- package/styles/select-field.module.css.css +1 -1
- package/styles/switch-field.css +3 -2
- package/styles/text-area.css +4 -3
- package/styles/text-area.module.css.css +1 -1
- package/styles/text-field.css +4 -3
- package/styles/text-field.module.css.css +1 -1
- package/styles/text.css +1 -1
- package/styles/text.module.css.css +1 -1
- package/es/components/checkbox/checkbox.js +0 -24
- package/es/components/checkbox/checkbox.js.map +0 -1
- package/es/components/checkbox/index.js +0 -6
- package/es/components/deprecated-loading/deprecated-loading.js +0 -39
- package/es/components/deprecated-loading/deprecated-loading.js.map +0 -1
- package/es/components/deprecated-modal/deprecated-modal.js +0 -207
- package/es/components/deprecated-modal/deprecated-modal.js.map +0 -1
- package/es/components/deprecated-modal/index.js +0 -11
- package/es/components/deprecated-modal/index.js.map +0 -1
- package/es/components/dropdown/dropdown.js.map +0 -1
- package/es/components/input/input.js.map +0 -1
- package/es/components/popover/index.js +0 -6
- package/es/components/popover/index.js.map +0 -1
- package/es/components/popover/popover.js +0 -206
- package/es/components/popover/popover.js.map +0 -1
- package/es/components/popover/positioning-utils.js +0 -104
- package/es/components/popover/positioning-utils.js.map +0 -1
- package/es/components/select/index.js.map +0 -1
- package/es/components/select/select.js.map +0 -1
- package/lib/components/checkbox/checkbox.d.ts +0 -13
- package/lib/components/checkbox/checkbox.js +0 -2
- package/lib/components/checkbox/checkbox.js.map +0 -1
- package/lib/components/checkbox/checkbox.test.d.ts +0 -1
- package/lib/components/checkbox/index.d.ts +0 -2
- package/lib/components/checkbox/index.js +0 -2
- package/lib/components/deprecated-loading/deprecated-loading.d.ts +0 -19
- package/lib/components/deprecated-loading/deprecated-loading.js +0 -2
- package/lib/components/deprecated-loading/deprecated-loading.js.map +0 -1
- package/lib/components/deprecated-loading/deprecated-loading.test.d.ts +0 -1
- package/lib/components/deprecated-loading/index.d.ts +0 -1
- package/lib/components/deprecated-modal/deprecated-modal.d.ts +0 -88
- package/lib/components/deprecated-modal/deprecated-modal.js +0 -2
- package/lib/components/deprecated-modal/deprecated-modal.js.map +0 -1
- package/lib/components/deprecated-modal/deprecated-modal.test.d.ts +0 -1
- package/lib/components/deprecated-modal/index.d.ts +0 -10
- package/lib/components/deprecated-modal/index.js +0 -2
- package/lib/components/deprecated-modal/index.js.map +0 -1
- package/lib/components/dropdown/dropdown.js.map +0 -1
- package/lib/components/input/input.js.map +0 -1
- package/lib/components/popover/index.d.ts +0 -2
- package/lib/components/popover/index.js +0 -2
- package/lib/components/popover/index.js.map +0 -1
- package/lib/components/popover/popover.d.ts +0 -54
- package/lib/components/popover/popover.js +0 -2
- package/lib/components/popover/popover.js.map +0 -1
- package/lib/components/popover/popover.test.d.ts +0 -1
- package/lib/components/popover/positioning-utils.d.ts +0 -19
- package/lib/components/popover/positioning-utils.js +0 -2
- package/lib/components/popover/positioning-utils.js.map +0 -1
- package/lib/components/popover/positioning-utils.test.d.ts +0 -1
- package/lib/components/select/index.js.map +0 -1
- package/lib/components/select/select.js.map +0 -1
- package/styles/checkbox.css +0 -1
- package/styles/deprecated-loading.css +0 -1
- package/styles/deprecated-modal.css +0 -1
- package/styles/popover.css +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { Tooltip } from '../tooltip/tooltip.js';
|
|
4
|
-
import
|
|
4
|
+
import DeprecatedDropdown from '../deprecated-dropdown/index.js';
|
|
5
5
|
|
|
6
6
|
const COLORS = ['#606060', '#4A90E2', '#03B3B2', '#008299', '#82BA00', '#D24726', '#AC193D', '#DC4FAD', '#3BD5FB', '#74E8D3', '#FFCC00', '#FB886E', '#CCCCCC'];
|
|
7
7
|
|
|
@@ -18,10 +18,10 @@ function ColorPicker({
|
|
|
18
18
|
onChange,
|
|
19
19
|
colorList = COLORS
|
|
20
20
|
}) {
|
|
21
|
-
return /*#__PURE__*/React__default.createElement(
|
|
21
|
+
return /*#__PURE__*/React__default.createElement(DeprecatedDropdown.Box, {
|
|
22
22
|
right: true,
|
|
23
23
|
className: "reactist_color_picker"
|
|
24
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
24
|
+
}, /*#__PURE__*/React__default.createElement(DeprecatedDropdown.Trigger, null, (() => {
|
|
25
25
|
const backgroundColor = _getColor(colorList, color);
|
|
26
26
|
|
|
27
27
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -34,7 +34,7 @@ function ColorPicker({
|
|
|
34
34
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
35
35
|
className: "color_trigger--inner_ring"
|
|
36
36
|
}));
|
|
37
|
-
})()), /*#__PURE__*/React__default.createElement(
|
|
37
|
+
})()), /*#__PURE__*/React__default.createElement(DeprecatedDropdown.Body, null, /*#__PURE__*/React__default.createElement("div", {
|
|
38
38
|
className: "color_options"
|
|
39
39
|
}, colorList.reduce((items, currentColor, currentIndex) => {
|
|
40
40
|
items.push( /*#__PURE__*/React__default.createElement(ColorItem, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-picker.js","sources":["../../../src/components/color-picker/color-picker.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\nimport
|
|
1
|
+
{"version":3,"file":"color-picker.js","sources":["../../../src/components/color-picker/color-picker.tsx"],"sourcesContent":["import React from 'react'\nimport classnames from 'classnames'\n\nimport DeprecatedDropdown from '../deprecated-dropdown'\nimport { Tooltip } from '../tooltip'\n\nimport './color-picker.less'\n\ntype NamedColor = { name: string; color: string }\n\nconst COLORS = [\n '#606060',\n '#4A90E2',\n '#03B3B2',\n '#008299',\n '#82BA00',\n '#D24726',\n '#AC193D',\n '#DC4FAD',\n '#3BD5FB',\n '#74E8D3',\n '#FFCC00',\n '#FB886E',\n '#CCCCCC',\n]\n\nconst _isNamedColor = (color: string | NamedColor | undefined): color is NamedColor =>\n typeof color !== 'string'\n\nconst _getColor = (colorList: (string | NamedColor)[], colorIndex: number) => {\n const index = colorIndex >= colorList.length ? 0 : colorIndex\n return colorList[index]\n}\n\ntype Props = {\n small?: boolean\n color?: number\n onChange?: (color: number) => void\n colorList?: (string | NamedColor)[]\n}\n\nfunction ColorPicker({ color = 0, small, onChange, colorList = COLORS }: Props) {\n return (\n <DeprecatedDropdown.Box right className=\"reactist_color_picker\">\n <DeprecatedDropdown.Trigger>\n {(() => {\n const backgroundColor = _getColor(colorList, color)\n\n return (\n <span\n className={classnames('color_trigger', { small })}\n style={{\n backgroundColor: _isNamedColor(backgroundColor)\n ? backgroundColor.color\n : backgroundColor,\n }}\n >\n <span className=\"color_trigger--inner_ring\" />\n </span>\n )\n })()}\n </DeprecatedDropdown.Trigger>\n <DeprecatedDropdown.Body>\n <div className=\"color_options\">\n {colorList.reduce<React.ReactNode[]>((items, currentColor, currentIndex) => {\n items.push(\n <ColorItem\n isActive={\n color >= colorList.length\n ? currentIndex === 0\n : currentIndex === color\n }\n key={currentIndex}\n color={\n _isNamedColor(currentColor) ? currentColor.color : currentColor\n }\n colorIndex={currentIndex}\n onClick={onChange}\n tooltip={_isNamedColor(currentColor) ? currentColor.name : null}\n />,\n )\n return items\n }, [])}\n </div>\n </DeprecatedDropdown.Body>\n </DeprecatedDropdown.Box>\n )\n}\nColorPicker.displayName = 'ColorPicker'\n\ntype ColorItemProps = {\n color: string\n colorIndex: number\n isActive?: boolean\n onClick?: (colorIndex: number) => void\n tooltip?: React.ReactNode\n}\n\nfunction ColorItem({ color, colorIndex, isActive, onClick, tooltip }: ColorItemProps) {\n const item = (\n <span\n className={'reactist color_item' + (isActive ? ' active' : '')}\n style={{ backgroundColor: color }}\n onClick={() => onClick?.(colorIndex)}\n >\n <span className=\"color_item--inner_ring\" />\n </span>\n )\n\n return tooltip ? <Tooltip content={tooltip}>{item}</Tooltip> : item\n}\nColorItem.displayName = 'ColorItem'\n\nexport { ColorPicker, ColorItem, COLORS }\n"],"names":["COLORS","_isNamedColor","color","_getColor","colorList","colorIndex","index","length","ColorPicker","small","onChange","React","DeprecatedDropdown","Box","right","className","Trigger","backgroundColor","classnames","style","Body","reduce","items","currentColor","currentIndex","push","ColorItem","isActive","key","onClick","tooltip","name","displayName","item","Tooltip","content"],"mappings":";;;;;MAUMA,MAAM,GAAG,CACX,SADW,EAEX,SAFW,EAGX,SAHW,EAIX,SAJW,EAKX,SALW,EAMX,SANW,EAOX,SAPW,EAQX,SARW,EASX,SATW,EAUX,SAVW,EAWX,SAXW,EAYX,SAZW,EAaX,SAbW;;AAgBf,MAAMC,aAAa,GAAIC,KAAD,IAClB,OAAOA,KAAP,KAAiB,QADrB;;AAGA,MAAMC,SAAS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,EAAE7B,aAAa,CAACsB,YAAD,CAAb,GAA8BA,YAAY,CAACQ,IAA3C,GAAkD;KAZ/D,CADJ;IAgBA,OAAOT,KAAP;GAjBH,EAkBE,EAlBF,CADL,CADJ,CAnBJ,CADJ;AA6CH;;AACDd,WAAW,CAACwB,WAAZ,GAA0B,aAA1B;;AAUA,SAASN,SAAT,CAAmB;EAAExB,KAAF;EAASG,UAAT;EAAqBsB,QAArB;EAA+BE,OAA/B;EAAwCC;AAAxC,CAAnB;EACI,MAAMG,IAAI,gBACNtB,4BAAA,OAAA;IACII,SAAS,EAAE,yBAAyBY,QAAQ,GAAG,SAAH,GAAe,EAAhD;IACXR,KAAK,EAAE;MAAEF,eAAe,EAAEf;;IAC1B2B,OAAO,EAAE,MAAMA,OAAN,oBAAMA,OAAO,CAAGxB,UAAH;GAH1B,eAKIM,4BAAA,OAAA;IAAMI,SAAS,EAAC;GAAhB,CALJ,CADJ;EAUA,OAAOe,OAAO,gBAAGnB,4BAAA,CAACuB,OAAD;IAASC,OAAO,EAAEL;GAAlB,EAA4BG,IAA5B,CAAH,GAAiDA,IAA/D;AACH;;AACDP,SAAS,CAACM,WAAV,GAAwB,WAAxB;;;;"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.js","sources":["../../../src/components/deprecated-dropdown/dropdown.tsx"],"sourcesContent":["import React from 'react'\nimport ReactDOM from 'react-dom'\nimport classNames from 'classnames'\n\nimport Button from '../deprecated-button'\n\nimport './dropdown.less'\n\ntype BoxProps = {\n onShowBody?: () => void\n onHideBody?: () => void\n allowBodyInteractions?: boolean\n top?: boolean\n right?: boolean\n scrolling_parent?: string\n children?: [\n React.ReactElement<TriggerProps>,\n React.ReactElement<BodyProps> | ((props: BodyProps) => JSX.Element),\n ]\n className?: string\n}\n\ntype BoxState = {\n top: boolean\n showBody: boolean\n}\n\nclass Box extends React.Component<React.PropsWithChildren<BoxProps>, BoxState> {\n public static displayName: string\n\n constructor(props: BoxProps, context: React.Context<unknown>) {\n super(props, context)\n this.state = {\n showBody: false,\n top: props.top || false,\n }\n\n this._timeout = undefined\n }\n\n componentWillUnmount() {\n document.removeEventListener('click', this._handleClickOutside, true)\n if (this._timeout) {\n clearTimeout(this._timeout)\n }\n }\n _timeout?: ReturnType<typeof setTimeout>\n\n _handleClickOutside = (event: MouseEvent) => {\n const dropdownDOMNode = ReactDOM.findDOMNode(this)\n\n if (dropdownDOMNode && !dropdownDOMNode.contains(event.target as Node))\n this._toggleShowBody()\n else if (!this.props.allowBodyInteractions) {\n // won't close when body interactions are allowed\n this._timeout = setTimeout(() => {\n if (this.state.showBody) {\n this._toggleShowBody()\n }\n }, 100)\n }\n }\n\n _toggleShowBody = () => {\n if (!this.state.showBody) {\n // will show\n if (this.props.onShowBody) this.props.onShowBody()\n document.addEventListener('click', this._handleClickOutside, true)\n } else {\n // will hide\n if (this.props.onHideBody) this.props.onHideBody()\n document.removeEventListener('click', this._handleClickOutside, true)\n }\n\n this.setState({\n showBody: !this.state.showBody,\n })\n }\n\n _getTriggerComponent() {\n const _trigger = this.props.children?.[0]\n return _trigger\n ? React.cloneElement(_trigger, { onClick: this._toggleShowBody })\n : undefined\n }\n\n // https://facebook.github.io/react/docs/refs-and-the-dom.html#exposing-dom-refs-to-parent-components\n _setPosition = (body: HTMLElement | null) => {\n if (body) {\n const scrollingParent = document.getElementById(\n this.props.scrolling_parent ? this.props.scrolling_parent : '',\n )\n\n if (scrollingParent) {\n const dropdown = ReactDOM.findDOMNode(this)\n if (!dropdown) {\n return\n }\n const dropdownVerticalPosition = (ReactDOM.findDOMNode(this) as HTMLElement)\n .offsetTop\n const dropdownTrigger = (dropdown as Element).querySelector('.trigger')\n if (!dropdownTrigger) {\n return\n }\n const dropdownTriggerHeight = dropdownTrigger.clientHeight\n const dropdownBodyHeight = body.clientHeight\n\n const scrollingParentHeight = scrollingParent.clientHeight\n const scrollingParentOffset = scrollingParent.scrollTop\n\n const bottomOffset =\n scrollingParentHeight +\n scrollingParentOffset -\n dropdownVerticalPosition -\n dropdownTriggerHeight\n\n const top = bottomOffset < dropdownBodyHeight\n\n if (top !== this.state.top) {\n this.setState({ top })\n }\n }\n }\n }\n\n _getBodyComponent() {\n if (!this.state.showBody) {\n return null\n }\n const { top } = this.state\n const { right = false, children } = this.props\n const props = { top, right, setPosition: this._setPosition }\n\n const className = classNames({\n body_wrapper: true,\n with_arrow: true,\n top: top,\n bottom: !top,\n })\n\n const body = children?.[1]\n\n const contentMarkup =\n typeof body === 'function'\n ? body(props)\n : body\n ? React.cloneElement(body, props)\n : undefined\n return (\n <div className={className} style={{ position: 'relative' }}>\n {contentMarkup}\n </div>\n )\n }\n\n render() {\n const className = classNames('reactist_dropdown', this.props.className)\n const { top } = this.state\n\n return (\n <div style={{ display: 'inline-block' }} className={className}>\n {top && this._getBodyComponent()}\n {this._getTriggerComponent()}\n {!top && this._getBodyComponent()}\n </div>\n )\n }\n}\n\nBox.displayName = 'Dropdown.Box'\n\ntype NativeButtonProps = React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>\n\ntype TriggerProps = Omit<NativeButtonProps, 'title'> & {\n tooltip?: React.ReactNode\n}\n\nconst Trigger = React.forwardRef<HTMLButtonElement, TriggerProps>(function Trigger(\n { children, onClick, tooltip, className, ...props },\n ref,\n) {\n function handleClick(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) {\n event.preventDefault()\n event.stopPropagation()\n if (onClick) onClick(event)\n }\n\n return (\n <Button\n {...props}\n className={classNames('trigger', className)}\n onClick={handleClick}\n tooltip={tooltip}\n ref={ref}\n >\n {children}\n </Button>\n )\n})\n\nTrigger.displayName = 'Dropdown.Trigger'\n\ntype BodyProps = {\n setPosition?: React.Ref<HTMLDivElement>\n children?: React.ReactNode\n top?: boolean\n right?: boolean\n}\n\nfunction Body({ top, right, children, setPosition }: BodyProps) {\n const style: React.CSSProperties = { position: 'absolute', right: 0, top: 0 }\n\n if (top) {\n style.top = 'auto'\n style.bottom = 0\n }\n\n if (right) {\n style.right = 'auto'\n style.left = 0\n }\n\n return (\n <div ref={setPosition} style={style} className=\"body\" id=\"reactist-dropdown-body\">\n {children}\n </div>\n )\n}\n\nBody.displayName = 'Dropdown.Body'\n\nconst Dropdown = {\n Box,\n Trigger,\n Body,\n}\n\nexport { Dropdown }\n"],"names":["Box","React","Component","constructor","props","context","_timeout","_handleClickOutside","event","dropdownDOMNode","ReactDOM","findDOMNode","contains","target","_toggleShowBody","allowBodyInteractions","setTimeout","state","showBody","onShowBody","document","addEventListener","onHideBody","removeEventListener","setState","_setPosition","body","scrollingParent","getElementById","scrolling_parent","dropdown","dropdownVerticalPosition","offsetTop","dropdownTrigger","querySelector","dropdownTriggerHeight","clientHeight","dropdownBodyHeight","scrollingParentHeight","scrollingParentOffset","scrollTop","bottomOffset","top","undefined","componentWillUnmount","clearTimeout","_getTriggerComponent","_trigger","children","cloneElement","onClick","_getBodyComponent","right","setPosition","className","classNames","body_wrapper","with_arrow","bottom","contentMarkup","style","position","render","display","displayName","Trigger","forwardRef","ref","tooltip","handleClick","preventDefault","stopPropagation","Button","Body","left","id","Dropdown"],"mappings":";;;;;;;;AA2BA,MAAMA,GAAN,SAAkBC,cAAK,CAACC,SAAxB;EAGIC,YAAYC,OAAiBC;IACzB,MAAMD,KAAN,EAAaC,OAAb;SAeJC;;SAEAC,sBAAuBC,KAAD;MAClB,MAAMC,eAAe,GAAGC,QAAQ,CAACC,WAAT,CAAqB,IAArB,CAAxB;MAEA,IAAIF,eAAe,IAAI,CAACA,eAAe,CAACG,QAAhB,CAAyBJ,KAAK,CAACK,MAA/B,CAAxB,EACI,KAAKC,eAAL,GADJ,KAEK,IAAI,CAAC,KAAKV,KAAL,CAAWW,qBAAhB,EAAuC;;QAExC,KAAKT,QAAL,GAAgBU,UAAU,CAAC;UACvB,IAAI,KAAKC,KAAL,CAAWC,QAAf,EAAyB;YACrB,KAAKJ,eAAL;;SAFkB,EAIvB,GA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,GAAG,EAAEA;MAEJnB,QAPL,CADJ;AAWH,CArBe,CAAhB;AAuBAiB,OAAO,CAACD,WAAR,GAAsB,kBAAtB;;AASA,SAASS,IAAT,CAAc;EAAE/B,GAAF;EAAOU,KAAP;EAAcJ,QAAd;EAAwBK;AAAxB,CAAd;EACI,MAAMO,KAAK,GAAwB;IAAEC,QAAQ,EAAE,UAAZ;IAAwBT,KAAK,EAAE,CAA/B;IAAkCV,GAAG,EAAE;GAA1E;;EAEA,IAAIA,GAAJ,EAAS;IACLkB,KAAK,CAAClB,GAAN,GAAY,MAAZ;IACAkB,KAAK,CAACF,MAAN,GAAe,CAAf;;;EAGJ,IAAIN,KAAJ,EAAW;IACPQ,KAAK,CAACR,KAAN,GAAc,MAAd;IACAQ,KAAK,CAACc,IAAN,GAAa,CAAb;;;EAGJ,oBACIzE,4BAAA,MAAA;IAAKkE,GAAG,EAAEd;IAAaO,KAAK,EAAEA;IAAON,SAAS,EAAC;IAAOqB,EAAE,EAAC;GAAzD,EACK3B,QADL,CADJ;AAKH;;AAEDyB,IAAI,CAACT,WAAL,GAAmB,eAAnB;MAEMY,QAAQ,GAAG;EACb5E,GADa;EAEbiE,OAFa;EAGbQ;AAHa;;;;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../../src/components/deprecated-input/input.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './input.less'\n\ntype InputProps = {\n /** Additional css class applied to the input. */\n className?: string\n ref?: React.Ref<HTMLInputElement>\n}\n\ntype Props = InputProps & React.InputHTMLAttributes<HTMLInputElement>\n\nconst Input: React.FC<React.PropsWithRef<Props>> = React.forwardRef(\n (props: Props, ref: React.Ref<HTMLInputElement>) => {\n const className = classNames('reactist_input', props.className)\n return <input {...props} className={className} ref={ref} />\n },\n)\nInput.displayName = 'Input'\n\nexport { Input }\n"],"names":["Input","React","forwardRef","props","ref","className","classNames","displayName"],"mappings":";;;;MAaMA,KAAK,gBAAwCC,cAAK,CAACC,UAAN,CAC/C,CAACC,KAAD,EAAeC,GAAf;EACI,MAAMC,SAAS,GAAGC,UAAU,CAAC,gBAAD,EAAmBH,KAAK,CAACE,SAAzB,CAA5B;EACA,oBAAOJ,4BAAA,QAAA,oCAAWE,KAAX;IAAkBE,SAAS,EAAEA,SAA7B;IAAwCD,GAAG,EAAEA;KAApD;AACH,CAJ8C;AAMnDJ,KAAK,CAACO,WAAN,GAAoB,OAApB;;;;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sources":["../../../src/components/deprecated-select/select.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './select.less'\n\ntype Option = {\n /** Optional key for each option. If not provided `value` is used. */\n key?: string | number\n /** Value of the option. */\n value: string | number\n /** Text to display for the option. */\n text?: string | number\n /** Whether the options is disabled or not. */\n disabled?: boolean\n}\n\ntype Props = {\n className?: string\n disabled?: boolean\n /** Currently selected value. */\n value?: string | number\n /** Callback for the change event. Will be called with the next value (not the full event). */\n onChange?: (value: string) => void\n /** Options that are rendered in the select. */\n options?: Option[]\n /** Value to initially be set */\n defaultValue?: string | number\n}\n\nfunction Select({\n value,\n options = [],\n onChange,\n disabled = true,\n className = '',\n defaultValue,\n ...otherProps\n}: Props) {\n const selectClassName = classNames('reactist_select', { disabled }, className)\n return (\n <select\n className={selectClassName}\n value={value}\n onChange={(event) => (onChange ? onChange(event.target.value) : undefined)}\n disabled={disabled}\n defaultValue={defaultValue}\n {...otherProps}\n >\n {options?.map((option) => (\n <option\n key={option.key || option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.text}\n </option>\n ))}\n </select>\n )\n}\nSelect.displayName = 'Select'\nSelect.defaultProps = {\n options: [],\n disabled: false,\n}\n\nexport { Select }\n"],"names":["Select","value","options","onChange","disabled","className","defaultValue","otherProps","selectClassName","classNames","React","event","target","undefined","map","option","key","text","displayName","defaultProps"],"mappings":";;;;;;AA6BA,SAASA,MAAT;MAAgB;IACZC,KADY;IAEZC,OAAO,GAAG,EAFE;IAGZC,QAHY;IAIZC,QAAQ,GAAG,IAJC;IAKZC,SAAS,GAAG,EALA;IAMZC;;MACGC;;EAEH,MAAMC,eAAe,GAAGC,UAAU,CAAC,iBAAD,EAAoB;IAAEL;GAAtB,EAAkCC,SAAlC,CAAlC;EACA,oBACIK,4BAAA,SAAA;IACIL,SAAS,EAAEG,eADf;IAEIP,KAAK,EAAEA,KAFX;IAGIE,QAAQ,EAAGQ,KAAD,IAAYR,QAAQ,GAAGA,QAAQ,CAACQ,KAAK,CAACC,MAAN,CAAaX,KAAd,CAAX,GAAkCY,SAHpE;IAIIT,QAAQ,EAAEA,QAJd;IAKIE,YAAY,EAAEA;KACVC,UANR,GAQKL,OARL,oBAQKA,OAAO,CAAEY,GAAT,CAAcC,MAAD,iBACVL,4BAAA,SAAA;IACIM,GAAG,EAAED,MAAM,CAACC,GAAP,IAAcD,MAAM,CAACd;IAC1BA,KAAK,EAAEc,MAAM,CAACd;IACdG,QAAQ,EAAEW,MAAM,CAACX;GAHrB,EAKKW,MAAM,CAACE,IALZ,CADH,CARL,CADJ;AAoBH;;AACDjB,MAAM,CAACkB,WAAP,GAAqB,QAArB;AACAlB,MAAM,CAACmB,YAAP,GAAsB;EAClBjB,OAAO,EAAE,EADS;EAElBE,QAAQ,EAAE;AAFQ,CAAtB;;;;"}
|
package/es/index.js
CHANGED
|
@@ -24,21 +24,17 @@ export { usePrevious } from './hooks/use-previous/use-previous.js';
|
|
|
24
24
|
export { Tab, TabAwareSlot, TabList, TabPanel, Tabs } from './new-components/tabs/tabs.js';
|
|
25
25
|
export { Modal, ModalActions, ModalBody, ModalCloseButton, ModalFooter, ModalHeader } from './new-components/modal/modal.js';
|
|
26
26
|
export { Avatar } from './new-components/avatar/avatar.js';
|
|
27
|
-
export { default as Checkbox } from './components/checkbox/index.js';
|
|
28
27
|
export { default as DeprecatedButton } from './components/deprecated-button/index.js';
|
|
29
|
-
export { default as
|
|
28
|
+
export { default as DeprecatedDropdown } from './components/deprecated-dropdown/index.js';
|
|
30
29
|
export { COLORS } from './components/color-picker/color-picker.js';
|
|
31
30
|
export { default as ColorPicker } from './components/color-picker/index.js';
|
|
32
|
-
export { default as Input } from './components/input/index.js';
|
|
33
31
|
export { default as KeyboardShortcut } from './components/keyboard-shortcut/index.js';
|
|
34
32
|
export { SUPPORTED_KEYS } from './components/key-capturer/key-capturer.js';
|
|
35
33
|
export { default as KeyCapturer } from './components/key-capturer/index.js';
|
|
36
|
-
export { default as Popover } from './components/popover/index.js';
|
|
37
34
|
export { default as ProgressBar } from './components/progress-bar/index.js';
|
|
38
|
-
export { default as Select } from './components/select/index.js';
|
|
39
35
|
export { default as Time } from './components/time/index.js';
|
|
40
36
|
export { Notification } from './components/notification/notification.js';
|
|
41
37
|
export { Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu } from './components/menu/menu.js';
|
|
42
|
-
export { default as
|
|
43
|
-
export {
|
|
38
|
+
export { default as DeprecatedInput } from './components/deprecated-input/index.js';
|
|
39
|
+
export { default as DeprecatedSelect } from './components/deprecated-select/index.js';
|
|
44
40
|
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,7 +6,7 @@ import { Tooltip } from '../../components/tooltip/tooltip.js';
|
|
|
6
6
|
import { Spinner } from '../spinner/spinner.js';
|
|
7
7
|
import styles from './base-button.module.css.js';
|
|
8
8
|
|
|
9
|
-
const _excluded = ["as", "variant", "tone", "size", "
|
|
9
|
+
const _excluded = ["as", "variant", "tone", "size", "shape", "disabled", "loading", "tooltip", "onClick", "exceptionallySetClassName", "children", "startIcon", "endIcon", "icon", "width", "align"];
|
|
10
10
|
|
|
11
11
|
function preventDefault(event) {
|
|
12
12
|
event.preventDefault();
|
|
@@ -26,10 +26,10 @@ const BaseButton = /*#__PURE__*/polymorphicComponent(function BaseButton(_ref, r
|
|
|
26
26
|
variant,
|
|
27
27
|
tone = 'normal',
|
|
28
28
|
size = 'normal',
|
|
29
|
+
shape = 'normal',
|
|
29
30
|
disabled = false,
|
|
30
31
|
loading = false,
|
|
31
32
|
tooltip,
|
|
32
|
-
tooltipGapSize,
|
|
33
33
|
onClick,
|
|
34
34
|
exceptionallySetClassName,
|
|
35
35
|
children,
|
|
@@ -37,7 +37,7 @@ const BaseButton = /*#__PURE__*/polymorphicComponent(function BaseButton(_ref, r
|
|
|
37
37
|
endIcon,
|
|
38
38
|
icon,
|
|
39
39
|
width = 'auto',
|
|
40
|
-
align
|
|
40
|
+
align = 'center'
|
|
41
41
|
} = _ref,
|
|
42
42
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
43
|
|
|
@@ -48,23 +48,26 @@ const BaseButton = /*#__PURE__*/polymorphicComponent(function BaseButton(_ref, r
|
|
|
48
48
|
"aria-disabled": isDisabled,
|
|
49
49
|
onClick: isDisabled ? preventDefault : onClick,
|
|
50
50
|
width: icon ? undefined : width,
|
|
51
|
-
className: [exceptionallySetClassName, styles.baseButton, styles["variant-" + variant], styles["tone-" + tone], styles["size-" + size],
|
|
51
|
+
className: [exceptionallySetClassName, styles.baseButton, styles["variant-" + variant], styles["tone-" + tone], styles["size-" + size], shape === 'rounded' ? styles['shape-rounded'] : null, icon ? styles.iconButton : null, disabled ? styles.disabled : null]
|
|
52
52
|
}), icon ? loading && /*#__PURE__*/createElement(Spinner, null) || icon : /*#__PURE__*/createElement(Fragment, null, startIcon ? /*#__PURE__*/createElement(Box, {
|
|
53
53
|
display: "flex",
|
|
54
54
|
className: styles.startIcon,
|
|
55
55
|
"aria-hidden": true
|
|
56
|
-
}, loading && !endIcon ? /*#__PURE__*/createElement(Spinner, null) : startIcon) : null, children ? /*#__PURE__*/createElement(
|
|
57
|
-
|
|
56
|
+
}, loading && !endIcon ? /*#__PURE__*/createElement(Spinner, null) : startIcon) : null, children ? /*#__PURE__*/createElement(Box, {
|
|
57
|
+
as: "span",
|
|
58
|
+
className: styles.label,
|
|
59
|
+
overflow: "hidden",
|
|
60
|
+
width: width === 'full' ? 'full' : undefined,
|
|
61
|
+
textAlign: width === 'auto' ? 'center' : align
|
|
58
62
|
}, children) : null, endIcon || loading && !startIcon ? /*#__PURE__*/createElement(Box, {
|
|
59
63
|
display: "flex",
|
|
60
64
|
className: styles.endIcon,
|
|
61
65
|
"aria-hidden": true
|
|
62
66
|
}, loading ? /*#__PURE__*/createElement(Spinner, null) : endIcon) : null)); // If it's an icon-only button, make sure it uses the aria-label as tooltip if no tooltip was provided
|
|
63
67
|
|
|
64
|
-
const tooltipContent = icon
|
|
68
|
+
const tooltipContent = icon && tooltip === undefined ? props['aria-label'] : tooltip;
|
|
65
69
|
return tooltipContent ? /*#__PURE__*/createElement(Tooltip, {
|
|
66
|
-
content: tooltipContent
|
|
67
|
-
gapSize: tooltipGapSize
|
|
70
|
+
content: tooltipContent
|
|
68
71
|
}, buttonElement) : buttonElement;
|
|
69
72
|
});
|
|
70
73
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-button.js","sources":["../../../src/new-components/base-button/base-button.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Tooltip, TooltipProps } from '../../components/tooltip'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { Box } from '../box'\nimport { Spinner } from '../spinner'\nimport styles from './base-button.module.css'\n\nfunction preventDefault(event: React.SyntheticEvent) {\n event.preventDefault()\n}\n\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'quaternary'\ntype ButtonTone = 'normal' | 'destructive'\ntype ButtonSize = 'small' | 'normal' | 'large'\ntype IconElement = React.ReactChild\n\ntype CommonProps = {\n /**\n * The button's variant.\n */\n variant: ButtonVariant\n /**\n * The button's tone.\n * @default 'normal'\n */\n tone?: ButtonTone\n /**\n * The button's size.\n * @default 'normal'\n */\n size?: ButtonSize\n /**\n * Whether the button is disabled or not.\n * @default false\n */\n disabled?: boolean\n /**\n * Whether the button is busy/loading.\n *\n * A button in this state is functionally and semantically disabled. Visually is does not look\n * dimmed (as disabled buttons normally do), but it shows a loading spinner instead.\n *\n * @default false\n */\n loading?: boolean\n /**\n * A tooltip linked to the button element.\n */\n tooltip?: TooltipProps['content']\n
|
|
1
|
+
{"version":3,"file":"base-button.js","sources":["../../../src/new-components/base-button/base-button.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Tooltip, TooltipProps } from '../../components/tooltip'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { Box } from '../box'\nimport { Spinner } from '../spinner'\nimport styles from './base-button.module.css'\n\nfunction preventDefault(event: React.SyntheticEvent) {\n event.preventDefault()\n}\n\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'quaternary'\ntype ButtonTone = 'normal' | 'destructive'\ntype ButtonSize = 'small' | 'normal' | 'large'\ntype IconElement = React.ReactChild\n\ntype CommonProps = {\n /**\n * The button's variant.\n */\n variant: ButtonVariant\n\n /**\n * The button's tone.\n * @default 'normal'\n */\n tone?: ButtonTone\n\n /**\n * The button's size.\n * @default 'normal'\n */\n size?: ButtonSize\n\n /**\n * Controls the shape of the button. Specifically, it allows to make it have slightly curved\n * corners (the default) vs. having them fully curved to the point that they are as round as\n * possible. In icon-only buttons this allows to have the button be circular.\n * @default 'normal'\n */\n shape?: 'normal' | 'rounded'\n\n /**\n * Whether the button is disabled or not.\n * @default false\n */\n disabled?: boolean\n\n /**\n * Whether the button is busy/loading.\n *\n * A button in this state is functionally and semantically disabled. Visually is does not look\n * dimmed (as disabled buttons normally do), but it shows a loading spinner instead.\n *\n * @default false\n */\n loading?: boolean\n\n /**\n * A tooltip linked to the button element.\n */\n tooltip?: TooltipProps['content']\n}\n\ntype AlignmentProps = {\n width: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'full'\n align?: 'start' | 'center' | 'end'\n}\n\ntype AutoWidthProps = {\n width?: 'auto'\n align?: never\n}\n\ntype IconButtonProps = {\n icon: IconElement\n 'aria-label': string\n children?: never\n startIcon?: never\n endIcon?: never\n width?: never\n align?: never\n}\n\ntype LabelledButtonProps = {\n children: NonNullable<React.ReactNode>\n startIcon?: IconElement\n endIcon?: IconElement\n icon?: never\n} & (AutoWidthProps | AlignmentProps)\n\nexport type BaseButtonProps = CommonProps & (IconButtonProps | LabelledButtonProps)\n\n/**\n * The component that powers `Button` and `ButtonLink`, where the button styling logic and some\n * common functionality resides. This component is internal to Reactist.\n *\n * @see Button\n * @see ButtonLink\n */\nexport const BaseButton = polymorphicComponent<'div', BaseButtonProps>(function BaseButton(\n {\n as = 'div',\n variant,\n tone = 'normal',\n size = 'normal',\n shape = 'normal',\n disabled = false,\n loading = false,\n tooltip,\n onClick,\n exceptionallySetClassName,\n children,\n startIcon,\n endIcon,\n icon,\n width = 'auto',\n align = 'center',\n ...props\n },\n ref,\n) {\n const isDisabled = loading || disabled\n const buttonElement = (\n <Box\n {...props}\n as={as}\n ref={ref}\n aria-disabled={isDisabled}\n onClick={isDisabled ? preventDefault : onClick}\n width={icon ? undefined : width}\n className={[\n exceptionallySetClassName,\n styles.baseButton,\n styles[`variant-${variant}`],\n styles[`tone-${tone}`],\n styles[`size-${size}`],\n shape === 'rounded' ? styles['shape-rounded'] : null,\n icon ? styles.iconButton : null,\n disabled ? styles.disabled : null,\n ]}\n >\n {icon ? (\n (loading && <Spinner />) || icon\n ) : (\n <>\n {startIcon ? (\n <Box display=\"flex\" className={styles.startIcon} aria-hidden>\n {loading && !endIcon ? <Spinner /> : startIcon}\n </Box>\n ) : null}\n {children ? (\n <Box\n as=\"span\"\n className={styles.label}\n overflow=\"hidden\"\n width={width === 'full' ? 'full' : undefined}\n textAlign={width === 'auto' ? 'center' : align}\n >\n {children}\n </Box>\n ) : null}\n {endIcon || (loading && !startIcon) ? (\n <Box display=\"flex\" className={styles.endIcon} aria-hidden>\n {loading ? <Spinner /> : endIcon}\n </Box>\n ) : null}\n </>\n )}\n </Box>\n )\n\n // If it's an icon-only button, make sure it uses the aria-label as tooltip if no tooltip was provided\n const tooltipContent = icon && tooltip === undefined ? props['aria-label'] : tooltip\n return tooltipContent ? (\n <Tooltip content={tooltipContent}>{buttonElement}</Tooltip>\n ) : (\n buttonElement\n )\n})\n"],"names":["preventDefault","event","BaseButton","polymorphicComponent","ref","as","variant","tone","size","shape","disabled","loading","tooltip","onClick","exceptionallySetClassName","children","startIcon","endIcon","icon","width","align","props","isDisabled","buttonElement","React","Box","undefined","className","styles","baseButton","iconButton","Spinner","display","label","overflow","textAlign","tooltipContent","Tooltip","content"],"mappings":";;;;;;;;;;AAOA,SAASA,cAAT,CAAwBC,KAAxB;EACIA,KAAK,CAACD,cAAN;AACH;AAoFD;;;;;;;;;MAOaE,UAAU,gBAAGC,oBAAoB,CAAyB,SAASD,UAAT,OAoBnEE,GApBmE;MACnE;IACIC,EAAE,GAAG,KADT;IAEIC,OAFJ;IAGIC,IAAI,GAAG,QAHX;IAIIC,IAAI,GAAG,QAJX;IAKIC,KAAK,GAAG,QALZ;IAMIC,QAAQ,GAAG,KANf;IAOIC,OAAO,GAAG,KAPd;IAQIC,OARJ;IASIC,OATJ;IAUIC,yBAVJ;IAWIC,QAXJ;IAYIC,SAZJ;IAaIC,OAbJ;IAcIC,IAdJ;IAeIC,KAAK,GAAG,MAfZ;IAgBIC,KAAK,GAAG;;MACLC;;EAIP,MAAMC,UAAU,GAAGX,OAAO,IAAID,QAA9B;EACA,MAAMa,aAAa,gBACfC,aAAA,CAACC,GAAD,oCACQJ,KADR;IAEIhB,EAAE,EAAEA,EAFR;IAGID,GAAG,EAAEA,GAHT;qBAImBkB,UAJnB;IAKIT,OAAO,EAAES,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,CArBR,CADJ;;EAkDA,MAAMmB,cAAc,GAAGlB,IAAI,IAAIN,OAAO,KAAKc,SAApB,GAAgCL,KAAK,CAAC,YAAD,CAArC,GAAsDT,OAA7E;EACA,OAAOwB,cAAc,gBACjBZ,aAAA,CAACa,OAAD;IAASC,OAAO,EAAEF;GAAlB,EAAmCb,aAAnC,CADiB,GAGjBA,aAHJ;AAKH,CA/E6C;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var modules_b9569bce = {"baseButton":"
|
|
1
|
+
var modules_b9569bce = {"baseButton":"a8af2163","label":"bbdb467b","shape-rounded":"ca02fc07","size-small":"_45ffe137","size-normal":"_352995bd","size-large":"_3991076f","disabled":"f82232b7","iconButton":"ef4c88db","startIcon":"a08c25c7","endIcon":"_2f6adc11","variant-primary":"_3d1243b2","variant-secondary":"_16b6b062","variant-tertiary":"cffaea5e","variant-quaternary":"_98cd5c3f","tone-destructive":"_99cb1c4d"};
|
|
2
2
|
|
|
3
3
|
export default modules_b9569bce;
|
|
4
4
|
//# sourceMappingURL=base-button.module.css.js.map
|
|
@@ -2,6 +2,7 @@ import { objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBab
|
|
|
2
2
|
import { createElement } from 'react';
|
|
3
3
|
import { Box } from '../box/box.js';
|
|
4
4
|
import { Stack } from '../stack/stack.js';
|
|
5
|
+
import { Spinner } from '../spinner/spinner.js';
|
|
5
6
|
import { Text } from '../text/text.js';
|
|
6
7
|
import { useId } from '../common-helpers.js';
|
|
7
8
|
import styles from './base-field.module.css.js';
|
|
@@ -14,11 +15,52 @@ function FieldHint(props) {
|
|
|
14
15
|
}, props));
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
function MessageIcon(props) {
|
|
19
|
+
return /*#__PURE__*/createElement("svg", _objectSpread2({
|
|
20
|
+
width: "16",
|
|
21
|
+
height: "16",
|
|
22
|
+
viewBox: "0 0 16 16",
|
|
23
|
+
fill: "none",
|
|
24
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
25
|
+
}, props), /*#__PURE__*/createElement("path", {
|
|
26
|
+
fillRule: "evenodd",
|
|
27
|
+
clipRule: "evenodd",
|
|
28
|
+
d: "M8 2.5C4.96243 2.5 2.5 4.96243 2.5 8C2.5 11.0376 4.96243 13.5 8 13.5C11.0376 13.5 13.5 11.0376 13.5 8C13.5 4.96243 11.0376 2.5 8 2.5ZM1.5 8C1.5 4.41015 4.41015 1.5 8 1.5C11.5899 1.5 14.5 4.41015 14.5 8C14.5 11.5899 11.5899 14.5 8 14.5C4.41015 14.5 1.5 11.5899 1.5 8ZM8.66667 10.3333C8.66667 10.7015 8.36819 11 8 11C7.63181 11 7.33333 10.7015 7.33333 10.3333C7.33333 9.96514 7.63181 9.66667 8 9.66667C8.36819 9.66667 8.66667 9.96514 8.66667 10.3333ZM8.65766 5.65766C8.65766 5.29445 8.36322 5 8 5C7.99087 5.00008 7.98631 5.00013 7.98175 5.00025C7.97719 5.00038 7.97263 5.00059 7.96352 5.00101C7.60086 5.02116 7.3232 5.33149 7.34335 5.69415L7.50077 8.52774C7.53575 9.15742 8.46425 9.15742 8.49923 8.52774L8.65665 5.69415C8.65707 5.68503 8.65728 5.68047 8.65741 5.67591C8.65754 5.67135 8.65758 5.66679 8.65766 5.65766Z",
|
|
29
|
+
fill: "currentColor"
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function FieldMessage({
|
|
34
|
+
id,
|
|
35
|
+
children,
|
|
36
|
+
tone
|
|
37
|
+
}) {
|
|
38
|
+
const textTone = tone === 'error' ? 'danger' : tone === 'success' ? 'positive' : 'normal';
|
|
39
|
+
return /*#__PURE__*/createElement(Text, {
|
|
40
|
+
as: "p",
|
|
41
|
+
tone: textTone,
|
|
42
|
+
size: "copy",
|
|
43
|
+
id: id
|
|
44
|
+
}, /*#__PURE__*/createElement(Box, {
|
|
45
|
+
as: "span",
|
|
46
|
+
marginRight: "xsmall",
|
|
47
|
+
display: "inlineFlex",
|
|
48
|
+
className: styles.messageIcon
|
|
49
|
+
}, tone === 'loading' ? /*#__PURE__*/createElement(Spinner, {
|
|
50
|
+
size: 16
|
|
51
|
+
}) : /*#__PURE__*/createElement(MessageIcon, {
|
|
52
|
+
"aria-hidden": true
|
|
53
|
+
})), children);
|
|
54
|
+
}
|
|
55
|
+
|
|
17
56
|
function BaseField({
|
|
57
|
+
variant = 'default',
|
|
18
58
|
label,
|
|
19
59
|
secondaryLabel,
|
|
20
60
|
auxiliaryLabel,
|
|
21
61
|
hint,
|
|
62
|
+
message,
|
|
63
|
+
tone = 'neutral',
|
|
22
64
|
className,
|
|
23
65
|
children,
|
|
24
66
|
maxWidth,
|
|
@@ -28,21 +70,26 @@ function BaseField({
|
|
|
28
70
|
}) {
|
|
29
71
|
const id = useId(originalId);
|
|
30
72
|
const hintId = useId();
|
|
31
|
-
const
|
|
73
|
+
const messageId = useId();
|
|
74
|
+
const ariaDescribedBy = originalAriaDescribedBy != null ? originalAriaDescribedBy : [message ? messageId : null, hintId].filter(Boolean).join(' ');
|
|
75
|
+
const childrenProps = {
|
|
76
|
+
id,
|
|
77
|
+
'aria-describedby': ariaDescribedBy,
|
|
78
|
+
'aria-invalid': tone === 'error' ? true : undefined
|
|
79
|
+
};
|
|
32
80
|
return /*#__PURE__*/createElement(Stack, {
|
|
33
|
-
space: "small"
|
|
34
|
-
}, /*#__PURE__*/createElement(Box, {
|
|
35
|
-
className: [className, styles.container],
|
|
36
|
-
maxWidth: maxWidth,
|
|
81
|
+
space: "small",
|
|
37
82
|
hidden: hidden
|
|
83
|
+
}, /*#__PURE__*/createElement(Box, {
|
|
84
|
+
className: [className, styles.container, tone === 'error' ? styles.error : null, variant === 'bordered' ? styles.bordered : null],
|
|
85
|
+
maxWidth: maxWidth
|
|
38
86
|
}, /*#__PURE__*/createElement(Box, {
|
|
39
87
|
as: "span",
|
|
40
88
|
display: "flex",
|
|
41
89
|
justifyContent: "spaceBetween",
|
|
42
|
-
alignItems: "flexEnd"
|
|
43
|
-
paddingBottom: "small"
|
|
90
|
+
alignItems: "flexEnd"
|
|
44
91
|
}, /*#__PURE__*/createElement(Text, {
|
|
45
|
-
size:
|
|
92
|
+
size: variant === 'bordered' ? 'caption' : 'body',
|
|
46
93
|
as: "label",
|
|
47
94
|
htmlFor: id
|
|
48
95
|
}, label ? /*#__PURE__*/createElement("span", {
|
|
@@ -52,16 +99,13 @@ function BaseField({
|
|
|
52
99
|
}, "\u00A0(", secondaryLabel, ")") : null), auxiliaryLabel ? /*#__PURE__*/createElement(Box, {
|
|
53
100
|
className: styles.auxiliaryLabel,
|
|
54
101
|
paddingLeft: "small"
|
|
55
|
-
}, auxiliaryLabel) : null), children(
|
|
56
|
-
id,
|
|
57
|
-
|
|
58
|
-
} : {
|
|
59
|
-
id
|
|
60
|
-
})), hint ? /*#__PURE__*/createElement(FieldHint, {
|
|
61
|
-
hidden: hidden,
|
|
102
|
+
}, auxiliaryLabel) : null), children(childrenProps)), message ? /*#__PURE__*/createElement(FieldMessage, {
|
|
103
|
+
id: messageId,
|
|
104
|
+
tone: tone
|
|
105
|
+
}, message) : null, hint ? /*#__PURE__*/createElement(FieldHint, {
|
|
62
106
|
id: hintId
|
|
63
107
|
}, hint) : null);
|
|
64
108
|
}
|
|
65
109
|
|
|
66
|
-
export { BaseField, FieldHint };
|
|
110
|
+
export { BaseField, FieldHint, FieldMessage };
|
|
67
111
|
//# sourceMappingURL=base-field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-field.js","sources":["../../../src/new-components/base-field/base-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box, BoxProps } from '../box'\nimport { useId } from '../common-helpers'\nimport { Text } from '../text'\nimport styles from './base-field.module.css'\nimport { Stack } from '../stack'\n\nimport type { WithEnhancedClassName } from '../common-types'\n\ntype FieldHintProps = {\n id: string\n children: React.ReactNode\n hidden?: boolean\n}\n\nfunction FieldHint(props: FieldHintProps) {\n return <Text as=\"p\" tone=\"secondary\" size=\"copy\" {...props} />\n}\n\n//\n// BaseField\n//\n\ntype HtmlInputProps<T extends HTMLElement> = React.DetailedHTMLProps<\n React.InputHTMLAttributes<T>,\n T\n>\n\ntype BaseFieldProps = WithEnhancedClassName &\n Pick<HtmlInputProps<HTMLInputElement>, 'id' | 'hidden' | 'aria-describedby'> & {\n /**\n * The main label for this field element.\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see secondaryLabel\n * @see auxiliaryLabel\n */\n label: React.ReactNode\n /**\n * An optional secondary label for this field element. It is combined with the `label` to\n * form the field's entire accessible name (unless the field label is overriden by using\n * `aria-label` or `aria-labelledby`).\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see label\n * @see auxiliaryLabel\n */\n secondaryLabel?: React.ReactNode\n /**\n * An optional extra element to be placed to the right of the main and secondary labels.\n *\n * This extra element is not included in the accessible name of the field element. Its only\n * purpose is either visual, or functional (if you include interactive elements in it).\n *\n * @see label\n * @see secondaryLabel\n */\n auxiliaryLabel?: React.ReactNode\n /**\n * A hint or help-like content associated as the accessible description of the field. It is\n * generally rendered below it, and with a visual style that reduces its prominence (i.e.\n * as secondary text).\n */\n hint?: React.ReactNode\n /**\n * The maximum width that the input field can expand to.\n */\n maxWidth?: BoxProps['maxWidth']\n /**\n * Used internally by components composed using `BaseField`. It is not exposed as part of\n * the public props of such components.\n */\n children: (props: { id: string; 'aria-describedby'?: string }) => React.ReactNode\n }\n\ntype FieldComponentProps<T extends HTMLElement> = Omit<BaseFieldProps, 'children' | 'className'> &\n Omit<HtmlInputProps<T>, 'className' | 'style'>\n\nfunction BaseField({\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n className,\n children,\n maxWidth,\n hidden,\n 'aria-describedby': originalAriaDescribedBy,\n id: originalId,\n}: BaseFieldProps & WithEnhancedClassName) {\n const id = useId(originalId)\n const hintId = useId()\n\n const ariaDescribedBy = originalAriaDescribedBy ?? (hint ? hintId : undefined)\n\n return (\n <Stack space=\"small\">\n <Box className={[className, styles.container]} maxWidth={maxWidth} hidden={hidden}>\n <Box\n as=\"span\"\n display=\"flex\"\n justifyContent=\"spaceBetween\"\n alignItems=\"flexEnd\"\n paddingBottom=\"small\"\n >\n <Text size=\"body\" as=\"label\" htmlFor={id}>\n {label ? <span className={styles.primaryLabel}>{label}</span> : null}\n {secondaryLabel ? (\n <span className={styles.secondaryLabel}> ({secondaryLabel})</span>\n ) : null}\n </Text>\n {auxiliaryLabel ? (\n <Box className={styles.auxiliaryLabel} paddingLeft=\"small\">\n {auxiliaryLabel}\n </Box>\n ) : null}\n </Box>\n {children(ariaDescribedBy ? { id, 'aria-describedby': ariaDescribedBy } : { id })}\n </Box>\n {hint ? (\n <FieldHint hidden={hidden} id={hintId}>\n {hint}\n </FieldHint>\n ) : null}\n </Stack>\n )\n}\n\nexport { BaseField, FieldHint }\nexport type { FieldComponentProps }\n"],"names":["FieldHint","props","React","Text","as","tone","size","BaseField","label","secondaryLabel","auxiliaryLabel","hint","className","children","maxWidth","hidden","originalAriaDescribedBy","id","originalId","useId","hintId","ariaDescribedBy","undefined","Stack","space","Box","styles","container","display","justifyContent","alignItems","paddingBottom","htmlFor","primaryLabel","paddingLeft"],"mappings":";;;;;;;;AAeA,SAASA,SAAT,CAAmBC,KAAnB;EACI,oBAAOC,aAAA,CAACC,IAAD;IAAMC,EAAE,EAAC,GAAT;IAAaC,IAAI,EAAC,WAAlB;IAA8BC,IAAI,EAAC;KAAWL,KAA9C,EAAP;AACH;;AA+DD,SAASM,SAAT,CAAmB;EACfC,KADe;EAEfC,cAFe;EAGfC,cAHe;EAIfC,IAJe;EAKfC,SALe;EAMfC,QANe;EAOfC,QAPe;EAQfC,MARe;EASf,oBAAoBC,uBATL;EAUfC,EAAE,EAAEC;AAVW,CAAnB;EAYI,MAAMD,EAAE,GAAGE,KAAK,CAACD,UAAD,CAAhB;EACA,MAAME,MAAM,GAAGD,KAAK,EAApB;EAEA,MAAME,eAAe,GAAGL,uBAAH,WAAGA,uBAAH,GAA+BL,IAAI,GAAGS,MAAH,GAAYE,SAApE;EAEA,oBACIpB,aAAA,CAACqB,KAAD;IAAOC,KAAK,EAAC;GAAb,eACItB,aAAA,CAACuB,GAAD;IAAKb,SAAS,EAAE,CAACA,SAAD,EAAYc,MAAM,CAACC,SAAnB;IAA+Bb,QAAQ,EAAEA;IAAUC,MAAM,EAAEA;GAA3E,eACIb,aAAA,CAACuB,GAAD;IACIrB,EAAE,EAAC;IACHwB,OAAO,EAAC;IACRC,cAAc,EAAC;IACfC,UAAU,EAAC;IACXC,aAAa,EAAC;GALlB,eAOI7B,aAAA,CAACC,IAAD;IAAMG,IAAI,EAAC;IAAOF,EAAE,EAAC;IAAQ4B,OAAO,EAAEf;GAAtC,EACKT,KAAK,gBAAGN,aAAA,OAAA;IAAMU,SAAS,EAAEc,MAAM,CAACO;GAAxB,EAAuCzB,KAAvC,CAAH,GAA0D,IADpE,EAEKC,cAAc,gBACXP,aAAA,OAAA;IAAMU,SAAS,EAAEc,MAAM,CAACjB;GAAxB,WAAA,EAAgDA,cAAhD,KAAA,CADW,GAEX,IAJR,CAPJ,EAaKC,cAAc,gBACXR,aAAA,CAACuB,GAAD;IAAKb,SAAS,EAAEc,MAAM,CAAChB;IAAgBwB,WAAW,EAAC;GAAnD,EACKxB,cADL,CADW,GAIX,IAjBR,CADJ,EAoBKG,QAAQ,CAACQ,eAAe,GAAG;IAAEJ,EAAF;IAAM,oBAAoBI;GAA7B,GAAiD;IAAEJ;GAAnE,CApBb,CADJ,EAuBKN,IAAI,gBACDT,aAAA,CAACF,SAAD;IAAWe,MAAM,EAAEA;IAAQE,EAAE,EAAEG;GAA/B,EACKT,IADL,CADC,GAID,IA3BR,CADJ;AA+BH;;;;"}
|
|
1
|
+
{"version":3,"file":"base-field.js","sources":["../../../src/new-components/base-field/base-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box, BoxProps } from '../box'\nimport { useId } from '../common-helpers'\nimport { Text } from '../text'\nimport styles from './base-field.module.css'\nimport { Stack } from '../stack'\n\nimport type { WithEnhancedClassName } from '../common-types'\nimport { Spinner } from '../spinner'\n\ntype FieldHintProps = {\n id: string\n children: React.ReactNode\n}\n\nfunction FieldHint(props: FieldHintProps) {\n return <Text as=\"p\" tone=\"secondary\" size=\"copy\" {...props} />\n}\n\nfunction MessageIcon(props: React.SVGProps<SVGSVGElement>) {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n {...props}\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M8 2.5C4.96243 2.5 2.5 4.96243 2.5 8C2.5 11.0376 4.96243 13.5 8 13.5C11.0376 13.5 13.5 11.0376 13.5 8C13.5 4.96243 11.0376 2.5 8 2.5ZM1.5 8C1.5 4.41015 4.41015 1.5 8 1.5C11.5899 1.5 14.5 4.41015 14.5 8C14.5 11.5899 11.5899 14.5 8 14.5C4.41015 14.5 1.5 11.5899 1.5 8ZM8.66667 10.3333C8.66667 10.7015 8.36819 11 8 11C7.63181 11 7.33333 10.7015 7.33333 10.3333C7.33333 9.96514 7.63181 9.66667 8 9.66667C8.36819 9.66667 8.66667 9.96514 8.66667 10.3333ZM8.65766 5.65766C8.65766 5.29445 8.36322 5 8 5C7.99087 5.00008 7.98631 5.00013 7.98175 5.00025C7.97719 5.00038 7.97263 5.00059 7.96352 5.00101C7.60086 5.02116 7.3232 5.33149 7.34335 5.69415L7.50077 8.52774C7.53575 9.15742 8.46425 9.15742 8.49923 8.52774L8.65665 5.69415C8.65707 5.68503 8.65728 5.68047 8.65741 5.67591C8.65754 5.67135 8.65758 5.66679 8.65766 5.65766Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\ntype FieldTone = 'neutral' | 'success' | 'error' | 'loading'\n\ntype FieldMessageProps = FieldHintProps & {\n tone: FieldTone\n}\n\nfunction FieldMessage({ id, children, tone }: FieldMessageProps) {\n const textTone = tone === 'error' ? 'danger' : tone === 'success' ? 'positive' : 'normal'\n return (\n <Text as=\"p\" tone={textTone} size=\"copy\" id={id}>\n <Box as=\"span\" marginRight=\"xsmall\" display=\"inlineFlex\" className={styles.messageIcon}>\n {tone === 'loading' ? <Spinner size={16} /> : <MessageIcon aria-hidden />}\n </Box>\n {children}\n </Text>\n )\n}\n\n//\n// BaseField\n//\n\ntype ChildrenRenderProps = {\n id: string\n 'aria-describedby'?: string\n 'aria-invalid'?: true\n}\n\ntype HtmlInputProps<T extends HTMLElement> = React.DetailedHTMLProps<\n React.InputHTMLAttributes<T>,\n T\n>\n\ntype BaseFieldVariant = 'default' | 'bordered'\ntype BaseFieldVariantProps = {\n /**\n * Provides alternative visual layouts or modes that the field can be rendered in.\n *\n * Namely, there are two variants supported:\n *\n * - the default one\n * - a \"bordered\" variant, where the border of the field surrounds also the labels, instead\n * of just surrounding the actual field element\n *\n * In both cases, the message and description texts for the field lie outside the bordered\n * area.\n */\n variant?: BaseFieldVariant\n}\n\ntype BaseFieldProps = WithEnhancedClassName &\n Pick<HtmlInputProps<HTMLInputElement>, 'id' | 'hidden' | 'aria-describedby'> & {\n /**\n * The main label for this field element.\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see secondaryLabel\n * @see auxiliaryLabel\n */\n label: React.ReactNode\n\n /**\n * An optional secondary label for this field element. It is combined with the `label` to\n * form the field's entire accessible name (unless the field label is overriden by using\n * `aria-label` or `aria-labelledby`).\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see label\n * @see auxiliaryLabel\n */\n secondaryLabel?: React.ReactNode\n\n /**\n * An optional extra element to be placed to the right of the main and secondary labels.\n *\n * This extra element is not included in the accessible name of the field element. Its only\n * purpose is either visual, or functional (if you include interactive elements in it).\n *\n * @see label\n * @see secondaryLabel\n */\n auxiliaryLabel?: React.ReactNode\n\n /**\n * A message associated with the field. It is rendered below the field, and with an\n * appearance that conveys the tone of the field (e.g. coloured red for errors, green for\n * success, etc).\n *\n * The message element is associated to the field via the `aria-describedby` attribute. If a\n * `hint` is provided, both the hint and the message are associated as the field accessible\n * description.\n *\n * In the future, when `aria-errormessage` gets better user agent support, we should use it\n * to associate the filed with a message when tone is `\"error\"`.\n *\n * @see tone\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-errormessage\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-invalid\n */\n message?: React.ReactNode\n\n /**\n * The tone with which the message, if any, is presented.\n *\n * If the tone is `\"error\"`, the field border turns red, and the message, if any, is also\n * red.\n *\n * When the tone is `\"loading\"`, it is recommended that you also disable the field. However,\n * this is not enforced by the component. It is only a recommendation.\n *\n * @see message\n * @see hint\n */\n tone?: FieldTone\n\n /**\n * A hint or help-like content associated as the accessible description of the field. It is\n * generally rendered below it, and with a visual style that reduces its prominence (i.e.\n * as secondary text).\n *\n * It sets the `aria-describedby` attribute pointing to the element that holds the hint\n * content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby\n */\n hint?: React.ReactNode\n\n /**\n * The maximum width that the input field can expand to.\n */\n maxWidth?: BoxProps['maxWidth']\n\n /**\n * Used internally by components composed using `BaseField`. It is not exposed as part of\n * the public props of such components.\n */\n children: (props: ChildrenRenderProps) => React.ReactNode\n }\n\ntype FieldComponentProps<T extends HTMLElement> = Omit<\n BaseFieldProps,\n 'children' | 'className' | 'variant'\n> &\n Omit<HtmlInputProps<T>, 'className' | 'style'>\n\nfunction BaseField({\n variant = 'default',\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone = 'neutral',\n className,\n children,\n maxWidth,\n hidden,\n 'aria-describedby': originalAriaDescribedBy,\n id: originalId,\n}: BaseFieldProps & BaseFieldVariantProps & WithEnhancedClassName) {\n const id = useId(originalId)\n const hintId = useId()\n const messageId = useId()\n\n const ariaDescribedBy =\n originalAriaDescribedBy ?? [message ? messageId : null, hintId].filter(Boolean).join(' ')\n\n const childrenProps: ChildrenRenderProps = {\n id,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': tone === 'error' ? true : undefined,\n }\n\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n className,\n styles.container,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n >\n <Box as=\"span\" display=\"flex\" justifyContent=\"spaceBetween\" alignItems=\"flexEnd\">\n <Text\n size={variant === 'bordered' ? 'caption' : 'body'}\n as=\"label\"\n htmlFor={id}\n >\n {label ? <span className={styles.primaryLabel}>{label}</span> : null}\n {secondaryLabel ? (\n <span className={styles.secondaryLabel}> ({secondaryLabel})</span>\n ) : null}\n </Text>\n {auxiliaryLabel ? (\n <Box className={styles.auxiliaryLabel} paddingLeft=\"small\">\n {auxiliaryLabel}\n </Box>\n ) : null}\n </Box>\n {children(childrenProps)}\n </Box>\n {message ? (\n <FieldMessage id={messageId} tone={tone}>\n {message}\n </FieldMessage>\n ) : null}\n {hint ? <FieldHint id={hintId}>{hint}</FieldHint> : null}\n </Stack>\n )\n}\n\nexport { BaseField, FieldHint, FieldMessage }\nexport type { BaseFieldVariant, BaseFieldVariantProps, FieldComponentProps }\n"],"names":["FieldHint","props","React","Text","as","tone","size","MessageIcon","width","height","viewBox","fill","xmlns","fillRule","clipRule","d","FieldMessage","id","children","textTone","Box","marginRight","display","className","styles","messageIcon","Spinner","BaseField","variant","label","secondaryLabel","auxiliaryLabel","hint","message","maxWidth","hidden","originalAriaDescribedBy","originalId","useId","hintId","messageId","ariaDescribedBy","filter","Boolean","join","childrenProps","undefined","Stack","space","container","error","bordered","justifyContent","alignItems","htmlFor","primaryLabel","paddingLeft"],"mappings":";;;;;;;;;AAeA,SAASA,SAAT,CAAmBC,KAAnB;EACI,oBAAOC,aAAA,CAACC,IAAD;IAAMC,EAAE,EAAC,GAAT;IA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IARR,CADJ,EAWKC,cAAc,gBACX7B,aAAA,CAACkB,GAAD;IAAKG,SAAS,EAAEC,MAAM,CAACO;IAAgByB,WAAW,EAAC;GAAnD,EACKzB,cADL,CADW,GAIX,IAfR,CATJ,EA0BKb,QAAQ,CAAC2B,aAAD,CA1Bb,CADJ,EA6BKZ,OAAO,gBACJ/B,aAAA,CAACc,YAAD;IAAcC,EAAE,EAAEuB;IAAWnC,IAAI,EAAEA;GAAnC,EACK4B,OADL,CADI,GAIJ,IAjCR,EAkCKD,IAAI,gBAAG9B,aAAA,CAACF,SAAD;IAAWiB,EAAE,EAAEsB;GAAf,EAAwBP,IAAxB,CAAH,GAA+C,IAlCxD,CADJ;AAsCH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var modules_540a88ff = {"container":"
|
|
1
|
+
var modules_540a88ff = {"container":"_2e189908","auxiliaryLabel":"_83051e0a","bordered":"fd20ef50","error":"d1a17d92","primaryLabel":"_75e0afa0","secondaryLabel":"d04a867d","messageIcon":"_77b2107e"};
|
|
2
2
|
|
|
3
3
|
export default modules_540a88ff;
|
|
4
4
|
//# sourceMappingURL=base-field.module.css.js.map
|
|
@@ -10,13 +10,16 @@ import { PasswordHiddenIcon } from '../icons/password-hidden-icon.js';
|
|
|
10
10
|
import styles from './password-field.module.css.js';
|
|
11
11
|
import styles$1 from '../text-field/text-field.module.css.js';
|
|
12
12
|
|
|
13
|
-
const _excluded = ["label", "secondaryLabel", "auxiliaryLabel", "hint", "maxWidth", "togglePasswordLabel", "hidden", "aria-describedby"];
|
|
13
|
+
const _excluded = ["variant", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth", "togglePasswordLabel", "hidden", "aria-describedby"];
|
|
14
14
|
const PasswordField = /*#__PURE__*/forwardRef(function PasswordField(_ref, ref) {
|
|
15
15
|
let {
|
|
16
|
+
variant = 'default',
|
|
16
17
|
label,
|
|
17
18
|
secondaryLabel,
|
|
18
19
|
auxiliaryLabel,
|
|
19
20
|
hint,
|
|
21
|
+
message,
|
|
22
|
+
tone,
|
|
20
23
|
maxWidth,
|
|
21
24
|
togglePasswordLabel = 'Toggle password visibility',
|
|
22
25
|
hidden,
|
|
@@ -37,18 +40,21 @@ const PasswordField = /*#__PURE__*/forwardRef(function PasswordField(_ref, ref)
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
return /*#__PURE__*/createElement(BaseField, {
|
|
43
|
+
variant: variant,
|
|
40
44
|
id: id,
|
|
41
45
|
label: label,
|
|
42
46
|
secondaryLabel: secondaryLabel,
|
|
43
47
|
auxiliaryLabel: auxiliaryLabel,
|
|
44
48
|
hint: hint,
|
|
49
|
+
message: message,
|
|
50
|
+
tone: tone,
|
|
45
51
|
maxWidth: maxWidth,
|
|
46
52
|
hidden: hidden,
|
|
47
53
|
"aria-describedby": ariaDescribedBy
|
|
48
54
|
}, extraProps => /*#__PURE__*/createElement(Box, {
|
|
49
55
|
display: "flex",
|
|
50
56
|
alignItems: "center",
|
|
51
|
-
className: [styles.inputWrapper, styles$1.inputWrapper]
|
|
57
|
+
className: [styles.inputWrapper, styles$1.inputWrapper, tone === 'error' ? styles$1.error : null, variant === 'bordered' ? styles$1.bordered : null]
|
|
52
58
|
}, /*#__PURE__*/createElement("input", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
|
|
53
59
|
ref: inputRef,
|
|
54
60
|
type: isPasswordVisible ? 'text' : 'password'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-field.js","sources":["../../../src/new-components/password-field/password-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useForkRef } from 'ariakit-utils'\nimport { Tooltip } from '../../components/tooltip'\nimport { BaseField } from '../base-field'\nimport { Box } from '../box'\nimport { useId } from '../common-helpers'\n\nimport { PasswordVisibleIcon } from '../icons/password-visible-icon'\nimport { PasswordHiddenIcon } from '../icons/password-hidden-icon'\n\nimport styles from './password-field.module.css'\nimport textFieldStyles from '../text-field/text-field.module.css'\n\nimport type { TextFieldProps } from '../text-field'\n\ntype PasswordFieldProps = Omit<TextFieldProps, 'type'> & {\n
|
|
1
|
+
{"version":3,"file":"password-field.js","sources":["../../../src/new-components/password-field/password-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useForkRef } from 'ariakit-utils'\nimport { Tooltip } from '../../components/tooltip'\nimport { BaseField, BaseFieldVariantProps } from '../base-field'\nimport { Box } from '../box'\nimport { useId } from '../common-helpers'\n\nimport { PasswordVisibleIcon } from '../icons/password-visible-icon'\nimport { PasswordHiddenIcon } from '../icons/password-hidden-icon'\n\nimport styles from './password-field.module.css'\nimport textFieldStyles from '../text-field/text-field.module.css'\n\nimport type { TextFieldProps } from '../text-field'\n\ntype PasswordFieldProps = Omit<TextFieldProps, 'type'> &\n BaseFieldVariantProps & {\n togglePasswordLabel?: string\n }\n\nconst PasswordField = React.forwardRef<HTMLInputElement, PasswordFieldProps>(function PasswordField(\n {\n variant = 'default',\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n togglePasswordLabel = 'Toggle password visibility',\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n const id = useId(props.id)\n const internalRef = React.useRef<HTMLInputElement>(null)\n const inputRef = useForkRef(internalRef, ref)\n\n const [isPasswordVisible, setPasswordVisible] = React.useState(false)\n\n function togglePasswordVisibility() {\n setPasswordVisible((v) => !v)\n internalRef.current?.focus()\n }\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.inputWrapper,\n textFieldStyles.inputWrapper,\n tone === 'error' ? textFieldStyles.error : null,\n variant === 'bordered' ? textFieldStyles.bordered : null,\n ]}\n >\n <input\n {...props}\n {...extraProps}\n ref={inputRef}\n type={isPasswordVisible ? 'text' : 'password'}\n />\n <Tooltip content={togglePasswordLabel}>\n <button\n type=\"button\"\n onClick={togglePasswordVisibility}\n aria-label={togglePasswordLabel}\n tabIndex={-1}\n >\n {isPasswordVisible ? (\n <PasswordVisibleIcon aria-hidden />\n ) : (\n <PasswordHiddenIcon aria-hidden />\n )}\n </button>\n </Tooltip>\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { PasswordField }\nexport type { PasswordFieldProps }\n"],"names":["PasswordField","React","ref","variant","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","togglePasswordLabel","hidden","ariaDescribedBy","props","id","useId","internalRef","inputRef","useForkRef","isPasswordVisible","setPasswordVisible","togglePasswordVisibility","v","current","focus","BaseField","extraProps","Box","display","alignItems","className","styles","inputWrapper","textFieldStyles","error","bordered","type","Tooltip","content","onClick","tabIndex","PasswordVisibleIcon","PasswordHiddenIcon"],"mappings":";;;;;;;;;;;;;MAoBMA,aAAa,gBAAGC,UAAA,CAAuD,SAASD,aAAT,OAezEE,GAfyE;MACzE;IACIC,OAAO,GAAG,SADd;IAEIC,KAFJ;IAGIC,cAHJ;IAIIC,cAJJ;IAKIC,IALJ;IAMIC,OANJ;IAOIC,IAPJ;IAQIC,QARJ;IASIC,mBAAmB,GAAG,4BAT1B;IAUIC,MAVJ;IAWI,oBAAoBC;;MACjBC;;EAIP,MAAMC,EAAE,GAAGC,KAAK,CAACF,KAAK,CAACC,EAAP,CAAhB;EACA,MAAME,WAAW,GAAGhB,MAAA,CAA+B,IAA/B,CAApB;EACA,MAAMiB,QAAQ,GAAGC,UAAU,CAACF,WAAD,EAAcf,GAAd,CAA3B;EAEA,MAAM,CAACkB,iBAAD,EAAoBC,kBAApB,IAA0CpB,QAAA,CAAe,KAAf,CAAhD;;EAEA,SAASqB,wBAAT;;;IACID,kBAAkB,CAAEE,CAAD,IAAO,CAACA,CAAT,CAAlB;IACA,wBAAAN,WAAW,CAACO,OAAZ,0CAAqBC,KAArB;;;EAGJ,oBACIxB,aAAA,CAACyB,SAAD;IACIvB,OAAO,EAAEA;IACTY,EAAE,EAAEA;IACJX,KAAK,EAAEA;IACPC,cAAc,EAAEA;IAChBC,cAAc,EAAEA;IAChBC,IAAI,EAAEA;IACNC,OAAO,EAAEA;IACTC,IAAI,EAAEA;IACNC,QAAQ,EAAEA;IACVE,MAAM,EAAEA;wBACUC;GAXtB,EAaMc,UAAD,iBACG1B,aAAA,CAAC2B,GAAD;IACIC,OAAO,EAAC;IACRC,UAAU,EAAC;IACXC,SAAS,EAAE,CACPC,MAAM,CAACC,YADA,EAEPC,QAAe,CAACD,YAFT,EAGPxB,IAAI,KAAK,OAAT,GAAmByB,QAAe,CAACC,KAAnC,GAA2C,IAHpC,EAIPhC,OAAO,KAAK,UAAZ,GAAyB+B,QAAe,CAACE,QAAzC,GAAoD,IAJ7C;GAHf,eAUInC,aAAA,QAAA,mDACQa,KADR,GAEQa,UAFR;IAGIzB,GAAG,EAAEgB,QAHT;IAIImB,IAAI,EAAEjB,iBAAiB,GAAG,MAAH,GAAY;KAd3C,eAgBInB,aAAA,CAACqC,OAAD;IAASC,OAAO,EAAE5B;GAAlB,eACIV,aAAA,SAAA;IACIoC,IAAI,EAAC;IACLG,OAAO,EAAElB;kBACGX;IACZ8B,QAAQ,EAAE,CAAC;GAJf,EAMKrB,iBAAiB,gBACdnB,aAAA,CAACyC,mBAAD;;GAAA,CADc,gBAGdzC,aAAA,CAAC0C,kBAAD;;GAAA,CATR,CADJ,CAhBJ,CAdR,CADJ;AAiDH,CA7EqB;;;;"}
|
|
@@ -4,7 +4,7 @@ import { Box } from '../box/box.js';
|
|
|
4
4
|
import { BaseField } from '../base-field/base-field.js';
|
|
5
5
|
import styles from './select-field.module.css.js';
|
|
6
6
|
|
|
7
|
-
const _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "maxWidth", "children", "hidden", "aria-describedby"];
|
|
7
|
+
const _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth", "children", "hidden", "aria-describedby"];
|
|
8
8
|
const SelectField = /*#__PURE__*/forwardRef(function SelectField(_ref, ref) {
|
|
9
9
|
let {
|
|
10
10
|
id,
|
|
@@ -12,6 +12,8 @@ const SelectField = /*#__PURE__*/forwardRef(function SelectField(_ref, ref) {
|
|
|
12
12
|
secondaryLabel,
|
|
13
13
|
auxiliaryLabel,
|
|
14
14
|
hint,
|
|
15
|
+
message,
|
|
16
|
+
tone,
|
|
15
17
|
maxWidth,
|
|
16
18
|
children,
|
|
17
19
|
hidden,
|
|
@@ -25,11 +27,13 @@ const SelectField = /*#__PURE__*/forwardRef(function SelectField(_ref, ref) {
|
|
|
25
27
|
secondaryLabel: secondaryLabel,
|
|
26
28
|
auxiliaryLabel: auxiliaryLabel,
|
|
27
29
|
hint: hint,
|
|
30
|
+
message: message,
|
|
31
|
+
tone: tone,
|
|
28
32
|
maxWidth: maxWidth,
|
|
29
33
|
hidden: hidden,
|
|
30
34
|
"aria-describedby": ariaDescribedBy
|
|
31
35
|
}, extraProps => /*#__PURE__*/createElement(Box, {
|
|
32
|
-
className: styles.selectWrapper
|
|
36
|
+
className: [styles.selectWrapper, tone === 'error' ? styles.error : null]
|
|
33
37
|
}, /*#__PURE__*/createElement("select", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
|
|
34
38
|
ref: ref
|
|
35
39
|
}), children), /*#__PURE__*/createElement(SelectChevron, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-field.js","sources":["../../../src/new-components/select-field/select-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './select-field.module.css'\n\ntype SelectFieldProps = FieldComponentProps<HTMLSelectElement>\n\nconst SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>(function SelectField(\n {\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n children,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box className={styles.selectWrapper}>\n <select {...props} {...extraProps} ref={ref}>\n {children}\n </select>\n <SelectChevron aria-hidden />\n </Box>\n )}\n </BaseField>\n )\n})\n\nfunction SelectChevron(props: JSX.IntrinsicElements['svg']) {\n return (\n <svg width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nexport { SelectField }\nexport type { SelectFieldProps }\n"],"names":["SelectField","React","ref","id","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","children","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","selectWrapper","SelectChevron","width","height","fill","xmlns","d"],"mappings":";;;;;;;MAOMA,WAAW,gBAAGC,UAAA,CAAsD,SAASD,WAAT,
|
|
1
|
+
{"version":3,"file":"select-field.js","sources":["../../../src/new-components/select-field/select-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './select-field.module.css'\n\ntype SelectFieldProps = FieldComponentProps<HTMLSelectElement>\n\nconst SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>(function SelectField(\n {\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n children,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box className={[styles.selectWrapper, tone === 'error' ? styles.error : null]}>\n <select {...props} {...extraProps} ref={ref}>\n {children}\n </select>\n <SelectChevron aria-hidden />\n </Box>\n )}\n </BaseField>\n )\n})\n\nfunction SelectChevron(props: JSX.IntrinsicElements['svg']) {\n return (\n <svg width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nexport { SelectField }\nexport type { SelectFieldProps }\n"],"names":["SelectField","React","ref","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","children","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","selectWrapper","error","SelectChevron","width","height","fill","xmlns","d"],"mappings":";;;;;;;MAOMA,WAAW,gBAAGC,UAAA,CAAsD,SAASD,WAAT,OAetEE,GAfsE;MACtE;IACIC,EADJ;IAEIC,KAFJ;IAGIC,cAHJ;IAIIC,cAJJ;IAKIC,IALJ;IAMIC,OANJ;IAOIC,IAPJ;IAQIC,QARJ;IASIC,QATJ;IAUIC,MAVJ;IAWI,oBAAoBC;;MACjBC;;EAIP,oBACIb,aAAA,CAACc,SAAD;IACIZ,EAAE,EAAEA;IACJC,KAAK,EAAEA;IACPC,cAAc,EAAEA;IAChBC,cAAc,EAAEA;IAChBC,IAAI,EAAEA;IACNC,OAAO,EAAEA;IACTC,IAAI,EAAEA;IACNC,QAAQ,EAAEA;IACVE,MAAM,EAAEA;wBACUC;GAVtB,EAYMG,UAAD,iBACGf,aAAA,CAACgB,GAAD;IAAKC,SAAS,EAAE,CAACC,MAAM,CAACC,aAAR,EAAuBX,IAAI,KAAK,OAAT,GAAmBU,MAAM,CAACE,KAA1B,GAAkC,IAAzD;GAAhB,eACIpB,aAAA,SAAA,mDAAYa,KAAZ,GAAuBE,UAAvB;IAAmCd,GAAG,EAAEA;MACnCS,QADL,CADJ,eAIIV,aAAA,CAACqB,aAAD;;GAAA,CAJJ,CAbR,CADJ;AAuBH,CAxCmB;;AA0CpB,SAASA,aAAT,CAAuBR,KAAvB;EACI,oBACIb,aAAA,MAAA;IAAKsB,KAAK,EAAC,IAAX;IAAgBC,MAAM,EAAC,IAAvB;IAA4BC,IAAI,EAAC,MAAjC;IAAwCC,KAAK,EAAC;KAAiCZ,KAA/E,gBACIb,aAAA,OAAA;IACI0B,CAAC,EAAC;IACFF,IAAI,EAAC;GAFT,CADJ,CADJ;AAQH;;;;"}
|