@doist/reactist 14.0.0 → 15.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/dist/reactist.cjs.development.js +504 -234
- 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 +1 -0
- package/es/components/color-picker/color-picker.js.map +1 -1
- package/es/components/deprecated-dropdown/dropdown.js +4 -2
- package/es/components/deprecated-dropdown/dropdown.js.map +1 -1
- package/es/components/menu/menu.js +5 -2
- package/es/components/menu/menu.js.map +1 -1
- package/es/index.js +3 -2
- package/es/index.js.map +1 -1
- package/es/new-components/deprecated-modal/modal.js +219 -0
- package/es/new-components/deprecated-modal/modal.js.map +1 -0
- package/es/new-components/deprecated-modal/modal.module.css.js +4 -0
- package/es/new-components/deprecated-modal/modal.module.css.js.map +1 -0
- package/es/new-components/modal/modal.js +64 -11
- package/es/new-components/modal/modal.js.map +1 -1
- package/es/new-components/modal/modal.module.css.js +1 -1
- package/es/new-components/tabs/tabs.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/deprecated-dropdown/dropdown.d.ts +6 -2
- package/lib/components/deprecated-dropdown/dropdown.js +1 -1
- package/lib/components/deprecated-dropdown/dropdown.js.map +1 -1
- package/lib/components/menu/menu.js +1 -1
- package/lib/components/menu/menu.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +1 -1
- package/lib/new-components/deprecated-modal/index.d.ts +1 -0
- package/lib/new-components/deprecated-modal/modal-stories-components.d.ts +35 -0
- package/lib/new-components/deprecated-modal/modal.d.ts +157 -0
- package/lib/new-components/deprecated-modal/modal.js +2 -0
- package/lib/new-components/deprecated-modal/modal.js.map +1 -0
- package/lib/new-components/deprecated-modal/modal.module.css.js +2 -0
- package/lib/new-components/deprecated-modal/modal.module.css.js.map +1 -0
- package/lib/new-components/deprecated-modal/modal.test.d.ts +1 -0
- package/lib/new-components/modal/modal-stories-components.d.ts +2 -1
- package/lib/new-components/modal/modal.d.ts +1 -1
- package/lib/new-components/modal/modal.js +1 -1
- package/lib/new-components/modal/modal.js.map +1 -1
- package/lib/new-components/modal/modal.module.css.js +1 -1
- package/lib/new-components/tabs/tabs.module.css.js +1 -1
- package/package.json +6 -7
- package/styles/menu.css +1 -1
- package/styles/reactist.css +5 -4
- package/styles/tabs.css +1 -1
- package/styles/tabs.module.css.css +1 -1
|
@@ -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 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;
|
|
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 data-testid=\"reactist-color-item\"\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;mBACgB;IACZI,SAAS,EAAE,yBAAyBY,QAAQ,GAAG,SAAH,GAAe,EAAhD;IACXR,KAAK,EAAE;MAAEF,eAAe,EAAEf;;IAC1B2B,OAAO,EAAE,MAAMA,OAAN,oBAAMA,OAAO,CAAGxB,UAAH;GAJ1B,eAMIM,4BAAA,OAAA;IAAMI,SAAS,EAAC;GAAhB,CANJ,CADJ;EAWA,OAAOe,OAAO,gBAAGnB,4BAAA,CAACuB,OAAD;IAASC,OAAO,EAAEL;GAAlB,EAA4BG,IAA5B,CAAH,GAAiDA,IAA/D;AACH;;AACDP,SAAS,CAACM,WAAV,GAAwB,WAAxB;;;;"}
|
|
@@ -141,7 +141,8 @@ class Box extends React__default.Component {
|
|
|
141
141
|
style: {
|
|
142
142
|
display: 'inline-block'
|
|
143
143
|
},
|
|
144
|
-
className: className
|
|
144
|
+
className: className,
|
|
145
|
+
"data-testid": "reactist-dropdown-box"
|
|
145
146
|
}, top && this._getBodyComponent(), this._getTriggerComponent(), !top && this._getBodyComponent());
|
|
146
147
|
}
|
|
147
148
|
|
|
@@ -199,7 +200,8 @@ function Body({
|
|
|
199
200
|
ref: setPosition,
|
|
200
201
|
style: style,
|
|
201
202
|
className: "body",
|
|
202
|
-
id: "reactist-dropdown-body"
|
|
203
|
+
id: "reactist-dropdown-body",
|
|
204
|
+
"data-testid": "reactist-dropdown-body"
|
|
203
205
|
}, children);
|
|
204
206
|
}
|
|
205
207
|
|
|
@@ -1 +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,M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;;;"}
|
|
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\n style={{ display: 'inline-block' }}\n className={className}\n data-testid=\"reactist-dropdown-box\"\n >\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' | 'onClick'> & {\n tooltip?: React.ReactNode\n /**\n * @private the onClick prop is not to be used externally\n */\n onClick?: NativeButtonProps['onClick']\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\n ref={setPosition}\n style={style}\n className=\"body\"\n id=\"reactist-dropdown-body\"\n data-testid=\"reactist-dropdown-body\"\n >\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,GAJuB,CAA1B;;;;SAQRA,kBAAkB;MACd,IAAI,CAAC,KAAKG,KAAL,CAAWC,QAAhB,EAA0B;;QAEtB,IAAI,KAAKd,KAAL,CAAWe,UAAf,EAA2B,KAAKf,KAAL,CAAWe,UAAX;QAC3BC,QAAQ,CAACC,gBAAT,CAA0B,OAA1B,EAAmC,KAAKd,mBAAxC,EAA6D,IAA7D;OAHJ,MAIO;;QAEH,IAAI,KAAKH,KAAL,CAAWkB,UAAf,EAA2B,KAAKlB,KAAL,CAAWkB,UAAX;QAC3BF,QAAQ,CAACG,mBAAT,CAA6B,OAA7B,EAAsC,KAAKhB,mBAA3C,EAAgE,IAAhE;;;MAGJ,KAAKiB,QAAL,CAAc;QACVN,QAAQ,EAAE,CAAC,KAAKD,KAAL,CAAWC;OAD1B;;;SAaJO,eAAgBC,IAAD;MACX,IAAIA,IAAJ,EAAU;QACN,MAAMC,eAAe,GAAGP,QAAQ,CAACQ,cAAT,CACpB,KAAKxB,KAAL,CAAWyB,gBAAX,GAA8B,KAA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,QAPL,CADJ;AAWH;;AAEDyB,IAAI,CAACT,WAAL,GAAmB,eAAnB;MAEMY,QAAQ,GAAG;EACb5E,GADa;EAEbiE,OAFa;EAGbQ;AAHa;;;;"}
|
|
@@ -2,8 +2,9 @@ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _
|
|
|
2
2
|
import { useCallback, useMemo, createElement, useContext, forwardRef, Children, cloneElement, createContext } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { polymorphicComponent } from '../../utils/polymorphism.js';
|
|
5
|
-
import
|
|
5
|
+
import FocusLock from 'react-focus-lock';
|
|
6
6
|
import { Portal } from 'ariakit/portal';
|
|
7
|
+
import { useMenuState, MenuButton as MenuButton$1, Menu as Menu$1, MenuItem as MenuItem$1, useMenuItem, MenuGroup as MenuGroup$1 } from 'ariakit/menu';
|
|
7
8
|
|
|
8
9
|
const _excluded = ["children", "onItemSelect"],
|
|
9
10
|
_excluded2 = ["exceptionallySetClassName"],
|
|
@@ -80,11 +81,13 @@ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref3, ref)
|
|
|
80
81
|
} = useContext(MenuContext);
|
|
81
82
|
return state.visible ? /*#__PURE__*/createElement(Portal, {
|
|
82
83
|
preserveTabOrder: true
|
|
84
|
+
}, /*#__PURE__*/createElement(FocusLock, {
|
|
85
|
+
returnFocus: true
|
|
83
86
|
}, /*#__PURE__*/createElement(Menu$1, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
84
87
|
state: state,
|
|
85
88
|
ref: ref,
|
|
86
89
|
className: classNames('reactist_menulist', exceptionallySetClassName)
|
|
87
|
-
}))) : null;
|
|
90
|
+
})))) : null;
|
|
88
91
|
});
|
|
89
92
|
/**
|
|
90
93
|
* A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { polymorphicComponent } from '../../utils/polymorphism'\n\n//\n// Reactist menu is a thin wrapper around Ariakit's menu components. This may or may not be\n// temporary. Our goal is to make it transparent for the users of Reactist of this implementation\n// detail. We may change in the future the external lib we use, or even implement it all internally,\n// as long as we keep the same outer interface as intact as possible.\n//\n// Around the heavy lifting of the external lib we just add some features to better integrate the\n// menu to Reactist's more opinionated approach (e.g. using our button with its custom variants and\n// other features, easily show keyboard shortcuts in menu items, etc.)\n//\nimport * as Ariakit from 'ariakit/menu'\nimport { Portal } from 'ariakit/portal'\n\nimport './menu.less'\nimport { useMenuItem } from 'ariakit/menu'\n\ntype NativeProps<E extends HTMLElement> = React.DetailedHTMLProps<React.HTMLAttributes<E>, E>\n\ntype MenuContextState = {\n state: Ariakit.MenuState\n handleItemSelect: (value: string | null | undefined) => void\n}\n\nconst MenuContext = React.createContext<MenuContextState>(\n // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn\n // (it is normally obtained by calling useMenuState but we can't call hooks outside components).\n // This is however of little consequence since this value is only used if some of the components\n // are used outside Menu, something that should not happen and we do not support.\n // @ts-expect-error\n {},\n)\n\n//\n// Menu\n//\n\ntype MenuProps = Omit<Ariakit.MenuStateProps, 'visible'> & {\n /**\n * The `Menu` must contain a `MenuList` that defines the menu options. It must also contain a\n * `MenuButton` that triggers the menu to be opened or closed.\n */\n children: React.ReactNode\n\n /**\n * An optional callback that will be called back whenever a menu item is selected. It receives\n * the `value` of the selected `MenuItem`.\n *\n * If you pass down this callback, it is recommended that you properly memoize it so it does not\n * change on every render.\n */\n onItemSelect?: (value: string | null | undefined) => void\n}\n\n/**\n * Wrapper component to control a menu. It does not render anything, only providing the state\n * management for the menu components inside it. Note that if you are relying on the `[role='menu']`\n * attribute to style the menu list, it is applied a `menubar` role instead in Safari.\n */\nfunction Menu({ children, onItemSelect, ...props }: MenuProps) {\n const state = Ariakit.useMenuState({ focusLoop: true, gutter: 8, shift: 4, ...props })\n\n const handleItemSelect = React.useCallback(\n function handleItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n },\n [onItemSelect],\n )\n\n const value: MenuContextState = React.useMemo(\n () => ({\n state,\n handleItemSelect,\n }),\n [state, handleItemSelect],\n )\n\n return <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n}\n\n//\n// MenuButton\n//\n\ntype MenuButtonProps = Omit<Ariakit.MenuButtonProps, 'state' | 'className' | 'as'>\n\n/**\n * A button to toggle a dropdown menu open or closed.\n */\nconst MenuButton = polymorphicComponent<'button', MenuButtonProps>(function MenuButton(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuButton\n {...props}\n state={state}\n ref={ref}\n className={classNames('reactist_menubutton', exceptionallySetClassName)}\n />\n )\n})\n\n//\n// MenuList\n//\n\ntype MenuListProps = Omit<Ariakit.MenuProps, 'state' | 'className'>\n\n/**\n * The dropdown menu itself, containing a list of menu items.\n */\nconst MenuList = polymorphicComponent<'div', MenuListProps>(function MenuList(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n\n return state.visible ? (\n <Portal preserveTabOrder>\n <Ariakit.Menu\n {...props}\n state={state}\n ref={ref}\n className={classNames('reactist_menulist', exceptionallySetClassName)}\n />\n </Portal>\n ) : null\n})\n\n//\n// MenuItem\n//\n\ntype MenuItemProps = {\n /**\n * An optional value given to this menu item. It is passed on to the parent `Menu`'s\n * `onItemSelect` when you provide that instead of (or alongside) providing individual\n * `onSelect` callbacks to each menu item.\n */\n value?: string\n /**\n * The content inside the menu item.\n */\n children: React.ReactNode\n /**\n * When `true` the menu item is disabled and won't be selectable or be part of the keyboard\n * navigation across the menu options.\n *\n * @default true\n */\n disabled?: boolean\n /**\n * When `true` the menu will close when the menu item is selected, in addition to performing the\n * action that the menu item is set out to do.\n *\n * Set this to `false` to make sure that a given menu item does not auto-closes the menu when\n * selected. This should be the exception and not the norm, as the default is to auto-close.\n *\n * @default true\n */\n hideOnSelect?: boolean\n /**\n * The action to perform when the menu item is selected.\n *\n * If you return `false` from this function, the menu will not auto-close when this menu item\n * is selected. Though you should use `hideOnSelect` for this purpose, this allows you to\n * achieve the same effect conditionally and dynamically deciding at run time.\n */\n onSelect?: () => unknown\n /**\n * The event handler called when the menu item is clicked.\n *\n * This is similar to `onSelect`, but a bit different. You can certainly use it to trigger the\n * action that the menu item represents. But in general you should prefer `onSelect` for that.\n *\n * The main use for this handler is to get access to the click event. This can be used, for\n * example, to call `event.preventDefault()`, which will effectively prevent the rest of the\n * consequences of the click, including preventing `onSelect` from being called. In particular,\n * this is useful in menu items that are links, and you want the click to not trigger navigation\n * under some circumstances.\n */\n onClick?: (event: React.MouseEvent) => void\n}\n\n/**\n * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`\n * callback.\n */\nconst MenuItem = polymorphicComponent<'button', MenuItemProps>(function MenuItem(\n {\n value,\n children,\n onSelect,\n hideOnSelect = true,\n onClick,\n exceptionallySetClassName,\n as = 'button',\n ...props\n },\n ref,\n) {\n const { handleItemSelect, state } = React.useContext(MenuContext)\n const { hide } = state\n\n const handleClick = React.useCallback(\n function handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event)\n const onSelectResult: unknown =\n onSelect && !event.defaultPrevented ? onSelect() : undefined\n const shouldClose = onSelectResult !== false && hideOnSelect\n handleItemSelect(value)\n if (shouldClose) hide()\n },\n [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value],\n )\n\n return (\n <Ariakit.MenuItem\n {...props}\n as={as}\n state={state}\n ref={ref}\n onClick={handleClick}\n className={exceptionallySetClassName}\n hideOnClick={false}\n >\n {children}\n </Ariakit.MenuItem>\n )\n})\n\n//\n// SubMenu\n//\n\ntype SubMenuProps = Pick<MenuProps, 'children' | 'onItemSelect'>\n\n/**\n * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have\n * a sub-menu.\n *\n * Its children are expected to have the structure of a first level menu (a `MenuButton` and a\n * `MenuList`).\n *\n * ```jsx\n * <MenuItem label=\"Edit profile\" />\n * <SubMenu>\n * <MenuButton>More options</MenuButton>\n * <MenuList>\n * <MenuItem label=\"Preferences\" />\n * <MenuItem label=\"Sign out\" />\n * </MenuList>\n * </SubMenu>\n * ```\n *\n * The `MenuButton` will become a menu item in the current menu items list, and it will lead to\n * opening a sub-menu with the menu items list below it.\n */\nconst SubMenu = React.forwardRef<HTMLButtonElement, SubMenuProps>(function SubMenu(\n { children, onItemSelect },\n ref,\n) {\n const { handleItemSelect: parentMenuItemSelect, state } = React.useContext(MenuContext)\n const { hide: parentMenuHide } = state\n\n const handleSubItemSelect = React.useCallback(\n function handleSubItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n parentMenuItemSelect(value)\n parentMenuHide()\n },\n [parentMenuHide, parentMenuItemSelect, onItemSelect],\n )\n\n const [button, list] = React.Children.toArray(children)\n\n const menuProps = useMenuItem({ state })\n\n return (\n <Menu onItemSelect={handleSubItemSelect}>\n {React.cloneElement(button as React.ReactElement, {\n ...menuProps,\n className: classNames(menuProps.className, 'reactist_submenu_button'),\n ref,\n })}\n {list}\n </Menu>\n )\n})\n\n//\n// MenuGroup\n//\n\ntype MenuGroupProps = Omit<NativeProps<HTMLDivElement>, 'className'> & {\n /**\n * A label to be shown visually and also used to semantically label the group.\n */\n label: string\n}\n\n/**\n * A way to semantically group some menu items.\n *\n * This group does not add any visual separator. You can do that yourself adding `<hr />` elements\n * before and/or after the group if you so wish.\n */\nconst MenuGroup = polymorphicComponent<'div', MenuGroupProps>(function MenuGroup(\n { label, children, exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuGroup {...props} ref={ref} state={state} className={exceptionallySetClassName}>\n {label ? (\n <div role=\"presentation\" className=\"reactist_menugroup__label\">\n {label}\n </div>\n ) : null}\n {children}\n </Ariakit.MenuGroup>\n )\n})\n\nexport { Menu, MenuButton, MenuList, MenuItem, SubMenu, MenuGroup }\nexport type { MenuButtonProps, MenuListProps, MenuItemProps, SubMenuProps, MenuGroupProps }\n"],"names":["MenuContext","React","Menu","children","onItemSelect","props","state","Ariakit","focusLoop","gutter","shift","handleItemSelect","value","Provider","MenuButton","polymorphicComponent","ref","exceptionallySetClassName","className","classNames","MenuList","visible","Portal","preserveTabOrder","MenuItem","onSelect","hideOnSelect","onClick","as","hide","handleClick","event","onSelectResult","defaultPrevented","undefined","shouldClose","hideOnClick","SubMenu","parentMenuItemSelect","parentMenuHide","handleSubItemSelect","button","list","toArray","menuProps","useMenuItem","MenuGroup","label","role"],"mappings":";;;;;;;;;;;;AA2BA,MAAMA,WAAW,gBAAGC,aAAA;AAEhB;AACA;AACA;AACA;AACA,EANgB,CAApB;AA8BA;;;;;;AAKA,SAASC,IAAT;MAAc;IAAEC,QAAF;IAAYC;;MAAiBC;;EACvC,MAAMC,KAAK,GAAGC,YAAA;IAAuBC,SAAS,EAAE,IAAlC;IAAwCC,MAAM,EAAE,CAAhD;IAAmDC,KAAK,EAAE;KAAML,KAAhE,EAAd;EAEA,MAAMM,gBAAgB,GAAGV,WAAA,CACrB,SAASU,gBAAT,CAA0BC,KAA1B;IACI,IAAIR,YAAJ,EAAkBA,YAAY,CAACQ,KAAD,CAAZ;GAFD,EAIrB,CAACR,YAAD,CAJqB,CAAzB;EAOA,MAAMQ,KAAK,GAAqBX,OAAA,CAC5B,OAAO;IACHK,KADG;IAEHK;GAFJ,CAD4B,EAK5B,CAACL,KAAD,EAAQK,gBAAR,CAL4B,CAAhC;EAQA,oBAAOV,aAAA,CAACD,WAAW,CAACa,QAAb;IAAsBD,KAAK,EAAEA;GAA7B,EAAqCT,QAArC,CAAP;AACH;AAQD;;;;;MAGMW,UAAU,gBAAGC,oBAAoB,CAA4B,SAASD,UAAT,QAE/DE,GAF+D;MAC/D;IAAEC;;MAA8BZ;;EAGhC,MAAM;IAAEC;MAAUL,UAAA,CAAiBD,WAAjB,CAAlB;EACA,oBACIC,aAAA,CAACM,Y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0B,IANL,CADJ;AAUH,CA9Be;AA2ChB;;;;;;;MAMMI,SAAS,gBAAG/B,oBAAoB,CAAwB,SAAS+B,SAAT,QAE1D9B,GAF0D;MAC1D;IAAE+B,KAAF;IAAS5C,QAAT;IAAmBc;;MAA8BZ;;EAGjD,MAAM;IAAEC;MAAUL,UAAA,CAAiBD,WAAjB,CAAlB;EACA,oBACIC,aAAA,CAACM,WAAD,oCAAuBF,KAAvB;IAA8BW,GAAG,EAAEA,GAAnC;IAAwCV,KAAK,EAAEA,KAA/C;IAAsDY,SAAS,EAAED;MAC5D8B,KAAK,gBACF9C,aAAA,MAAA;IAAK+C,IAAI,EAAC;IAAe9B,SAAS,EAAC;GAAnC,EACK6B,KADL,CADE,GAIF,IALR,EAMK5C,QANL,CADJ;AAUH,CAfqC;;;;"}
|
|
1
|
+
{"version":3,"file":"menu.js","sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport FocusLock from 'react-focus-lock'\n\nimport { polymorphicComponent } from '../../utils/polymorphism'\n\n//\n// Reactist menu is a thin wrapper around Ariakit's menu components. This may or may not be\n// temporary. Our goal is to make it transparent for the users of Reactist of this implementation\n// detail. We may change in the future the external lib we use, or even implement it all internally,\n// as long as we keep the same outer interface as intact as possible.\n//\n// Around the heavy lifting of the external lib we just add some features to better integrate the\n// menu to Reactist's more opinionated approach (e.g. using our button with its custom variants and\n// other features, easily show keyboard shortcuts in menu items, etc.)\n//\nimport * as Ariakit from 'ariakit/menu'\nimport { Portal } from 'ariakit/portal'\n\nimport './menu.less'\nimport { useMenuItem } from 'ariakit/menu'\n\ntype NativeProps<E extends HTMLElement> = React.DetailedHTMLProps<React.HTMLAttributes<E>, E>\n\ntype MenuContextState = {\n state: Ariakit.MenuState\n handleItemSelect: (value: string | null | undefined) => void\n}\n\nconst MenuContext = React.createContext<MenuContextState>(\n // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn\n // (it is normally obtained by calling useMenuState but we can't call hooks outside components).\n // This is however of little consequence since this value is only used if some of the components\n // are used outside Menu, something that should not happen and we do not support.\n // @ts-expect-error\n {},\n)\n\n//\n// Menu\n//\n\ntype MenuProps = Omit<Ariakit.MenuStateProps, 'visible'> & {\n /**\n * The `Menu` must contain a `MenuList` that defines the menu options. It must also contain a\n * `MenuButton` that triggers the menu to be opened or closed.\n */\n children: React.ReactNode\n\n /**\n * An optional callback that will be called back whenever a menu item is selected. It receives\n * the `value` of the selected `MenuItem`.\n *\n * If you pass down this callback, it is recommended that you properly memoize it so it does not\n * change on every render.\n */\n onItemSelect?: (value: string | null | undefined) => void\n}\n\n/**\n * Wrapper component to control a menu. It does not render anything, only providing the state\n * management for the menu components inside it. Note that if you are relying on the `[role='menu']`\n * attribute to style the menu list, it is applied a `menubar` role instead in Safari.\n */\nfunction Menu({ children, onItemSelect, ...props }: MenuProps) {\n const state = Ariakit.useMenuState({ focusLoop: true, gutter: 8, shift: 4, ...props })\n\n const handleItemSelect = React.useCallback(\n function handleItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n },\n [onItemSelect],\n )\n\n const value: MenuContextState = React.useMemo(\n () => ({\n state,\n handleItemSelect,\n }),\n [state, handleItemSelect],\n )\n\n return <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n}\n\n//\n// MenuButton\n//\n\ntype MenuButtonProps = Omit<Ariakit.MenuButtonProps, 'state' | 'className' | 'as'>\n\n/**\n * A button to toggle a dropdown menu open or closed.\n */\nconst MenuButton = polymorphicComponent<'button', MenuButtonProps>(function MenuButton(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuButton\n {...props}\n state={state}\n ref={ref}\n className={classNames('reactist_menubutton', exceptionallySetClassName)}\n />\n )\n})\n\n//\n// MenuList\n//\n\ntype MenuListProps = Omit<Ariakit.MenuProps, 'state' | 'className'>\n\n/**\n * The dropdown menu itself, containing a list of menu items.\n */\nconst MenuList = polymorphicComponent<'div', MenuListProps>(function MenuList(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n\n return state.visible ? (\n <Portal preserveTabOrder>\n <FocusLock returnFocus>\n <Ariakit.Menu\n {...props}\n state={state}\n ref={ref}\n className={classNames('reactist_menulist', exceptionallySetClassName)}\n />\n </FocusLock>\n </Portal>\n ) : null\n})\n\n//\n// MenuItem\n//\n\ntype MenuItemProps = {\n /**\n * An optional value given to this menu item. It is passed on to the parent `Menu`'s\n * `onItemSelect` when you provide that instead of (or alongside) providing individual\n * `onSelect` callbacks to each menu item.\n */\n value?: string\n /**\n * The content inside the menu item.\n */\n children: React.ReactNode\n /**\n * When `true` the menu item is disabled and won't be selectable or be part of the keyboard\n * navigation across the menu options.\n *\n * @default true\n */\n disabled?: boolean\n /**\n * When `true` the menu will close when the menu item is selected, in addition to performing the\n * action that the menu item is set out to do.\n *\n * Set this to `false` to make sure that a given menu item does not auto-closes the menu when\n * selected. This should be the exception and not the norm, as the default is to auto-close.\n *\n * @default true\n */\n hideOnSelect?: boolean\n /**\n * The action to perform when the menu item is selected.\n *\n * If you return `false` from this function, the menu will not auto-close when this menu item\n * is selected. Though you should use `hideOnSelect` for this purpose, this allows you to\n * achieve the same effect conditionally and dynamically deciding at run time.\n */\n onSelect?: () => unknown\n /**\n * The event handler called when the menu item is clicked.\n *\n * This is similar to `onSelect`, but a bit different. You can certainly use it to trigger the\n * action that the menu item represents. But in general you should prefer `onSelect` for that.\n *\n * The main use for this handler is to get access to the click event. This can be used, for\n * example, to call `event.preventDefault()`, which will effectively prevent the rest of the\n * consequences of the click, including preventing `onSelect` from being called. In particular,\n * this is useful in menu items that are links, and you want the click to not trigger navigation\n * under some circumstances.\n */\n onClick?: (event: React.MouseEvent) => void\n}\n\n/**\n * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`\n * callback.\n */\nconst MenuItem = polymorphicComponent<'button', MenuItemProps>(function MenuItem(\n {\n value,\n children,\n onSelect,\n hideOnSelect = true,\n onClick,\n exceptionallySetClassName,\n as = 'button',\n ...props\n },\n ref,\n) {\n const { handleItemSelect, state } = React.useContext(MenuContext)\n const { hide } = state\n\n const handleClick = React.useCallback(\n function handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event)\n const onSelectResult: unknown =\n onSelect && !event.defaultPrevented ? onSelect() : undefined\n const shouldClose = onSelectResult !== false && hideOnSelect\n handleItemSelect(value)\n if (shouldClose) hide()\n },\n [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value],\n )\n\n return (\n <Ariakit.MenuItem\n {...props}\n as={as}\n state={state}\n ref={ref}\n onClick={handleClick}\n className={exceptionallySetClassName}\n hideOnClick={false}\n >\n {children}\n </Ariakit.MenuItem>\n )\n})\n\n//\n// SubMenu\n//\n\ntype SubMenuProps = Pick<MenuProps, 'children' | 'onItemSelect'>\n\n/**\n * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have\n * a sub-menu.\n *\n * Its children are expected to have the structure of a first level menu (a `MenuButton` and a\n * `MenuList`).\n *\n * ```jsx\n * <MenuItem label=\"Edit profile\" />\n * <SubMenu>\n * <MenuButton>More options</MenuButton>\n * <MenuList>\n * <MenuItem label=\"Preferences\" />\n * <MenuItem label=\"Sign out\" />\n * </MenuList>\n * </SubMenu>\n * ```\n *\n * The `MenuButton` will become a menu item in the current menu items list, and it will lead to\n * opening a sub-menu with the menu items list below it.\n */\nconst SubMenu = React.forwardRef<HTMLButtonElement, SubMenuProps>(function SubMenu(\n { children, onItemSelect },\n ref,\n) {\n const { handleItemSelect: parentMenuItemSelect, state } = React.useContext(MenuContext)\n const { hide: parentMenuHide } = state\n\n const handleSubItemSelect = React.useCallback(\n function handleSubItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n parentMenuItemSelect(value)\n parentMenuHide()\n },\n [parentMenuHide, parentMenuItemSelect, onItemSelect],\n )\n\n const [button, list] = React.Children.toArray(children)\n\n const menuProps = useMenuItem({ state })\n\n return (\n <Menu onItemSelect={handleSubItemSelect}>\n {React.cloneElement(button as React.ReactElement, {\n ...menuProps,\n className: classNames(menuProps.className, 'reactist_submenu_button'),\n ref,\n })}\n {list}\n </Menu>\n )\n})\n\n//\n// MenuGroup\n//\n\ntype MenuGroupProps = Omit<NativeProps<HTMLDivElement>, 'className'> & {\n /**\n * A label to be shown visually and also used to semantically label the group.\n */\n label: string\n}\n\n/**\n * A way to semantically group some menu items.\n *\n * This group does not add any visual separator. You can do that yourself adding `<hr />` elements\n * before and/or after the group if you so wish.\n */\nconst MenuGroup = polymorphicComponent<'div', MenuGroupProps>(function MenuGroup(\n { label, children, exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuGroup {...props} ref={ref} state={state} className={exceptionallySetClassName}>\n {label ? (\n <div role=\"presentation\" className=\"reactist_menugroup__label\">\n {label}\n </div>\n ) : null}\n {children}\n </Ariakit.MenuGroup>\n )\n})\n\nexport { Menu, MenuButton, MenuList, MenuItem, SubMenu, MenuGroup }\nexport type { MenuButtonProps, MenuListProps, MenuItemProps, SubMenuProps, MenuGroupProps }\n"],"names":["MenuContext","React","Menu","children","onItemSelect","props","state","Ariakit","focusLoop","gutter","shift","handleItemSelect","value","Provider","MenuButton","polymorphicComponent","ref","exceptionallySetClassName","className","classNames","MenuList","visible","Portal","preserveTabOrder","FocusLock","returnFocus","MenuItem","onSelect","hideOnSelect","onClick","as","hide","handleClick","event","onSelectResult","defaultPrevented","undefined","shouldClose","hideOnClick","SubMenu","parentMenuItemSelect","parentMenuHide","handleSubItemSelect","button","list","toArray","menuProps","useMenuItem","MenuGroup","label","role"],"mappings":";;;;;;;;;;;;;AA6BA,MAAMA,WAAW,gBAAGC,aAAA;AAEhB;AACA;AACA;AACA;AACA,EANgB,CAApB;AA8BA;;;;;;AAKA,SAASC,IAAT;MAAc;IAAEC,QAAF;IAAYC;;MAAiBC;;EACvC,MAAMC,KAAK,GAAGC,YAAA;IAAuB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/es/index.js
CHANGED
|
@@ -20,10 +20,10 @@ export { SelectField } from './new-components/select-field/select-field.js';
|
|
|
20
20
|
export { SwitchField } from './new-components/switch-field/switch-field.js';
|
|
21
21
|
export { TextArea } from './new-components/text-area/text-area.js';
|
|
22
22
|
export { TextField } from './new-components/text-field/text-field.js';
|
|
23
|
+
export { Avatar } from './new-components/avatar/avatar.js';
|
|
24
|
+
export { Modal, ModalActions, ModalBody, ModalCloseButton, ModalFooter, ModalHeader } from './new-components/modal/modal.js';
|
|
23
25
|
export { usePrevious } from './hooks/use-previous/use-previous.js';
|
|
24
26
|
export { Tab, TabAwareSlot, TabList, TabPanel, Tabs } from './new-components/tabs/tabs.js';
|
|
25
|
-
export { Modal, ModalActions, ModalBody, ModalCloseButton, ModalFooter, ModalHeader } from './new-components/modal/modal.js';
|
|
26
|
-
export { Avatar } from './new-components/avatar/avatar.js';
|
|
27
27
|
export { default as DeprecatedButton } from './components/deprecated-button/index.js';
|
|
28
28
|
export { default as DeprecatedDropdown } from './components/deprecated-dropdown/index.js';
|
|
29
29
|
export { COLORS } from './components/color-picker/color-picker.js';
|
|
@@ -37,4 +37,5 @@ export { Notification } from './components/notification/notification.js';
|
|
|
37
37
|
export { Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu } from './components/menu/menu.js';
|
|
38
38
|
export { default as DeprecatedInput } from './components/deprecated-input/index.js';
|
|
39
39
|
export { default as DeprecatedSelect } from './components/deprecated-select/index.js';
|
|
40
|
+
export { DeprecatedModal, DeprecatedModalActions, DeprecatedModalBody, DeprecatedModalCloseButton, DeprecatedModalFooter, DeprecatedModalHeader } from './new-components/deprecated-modal/modal.js';
|
|
40
41
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { useMemo, createElement, useContext, useState, useEffect, Fragment, createContext } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Box } from '../box/box.js';
|
|
5
|
+
import { Columns, Column } from '../columns/columns.js';
|
|
6
|
+
import { Divider } from '../divider/divider.js';
|
|
7
|
+
import { Inline } from '../inline/inline.js';
|
|
8
|
+
import { Button } from '../button/button.js';
|
|
9
|
+
import { CloseIcon } from '../icons/close-icon.js';
|
|
10
|
+
import FocusLock from 'react-focus-lock';
|
|
11
|
+
import { DialogOverlay, DialogContent } from '@reach/dialog';
|
|
12
|
+
import styles from './modal.module.css.js';
|
|
13
|
+
|
|
14
|
+
const _excluded = ["isOpen", "onDismiss", "height", "width", "exceptionallySetClassName", "autoFocus", "children"],
|
|
15
|
+
_excluded2 = ["children", "button", "withDivider", "exceptionallySetClassName"],
|
|
16
|
+
_excluded3 = ["exceptionallySetClassName", "children"],
|
|
17
|
+
_excluded4 = ["exceptionallySetClassName", "withDivider"],
|
|
18
|
+
_excluded5 = ["children"];
|
|
19
|
+
const ModalContext = /*#__PURE__*/createContext({
|
|
20
|
+
onDismiss: undefined,
|
|
21
|
+
height: 'fitContent'
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function isNotInternalFrame(element) {
|
|
25
|
+
return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe');
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Renders a modal that sits on top of the rest of the content in the entire page.
|
|
29
|
+
*
|
|
30
|
+
* Follows the WAI-ARIA Dialog (Modal) Pattern.
|
|
31
|
+
*
|
|
32
|
+
* @see DeprecatedModalHeader
|
|
33
|
+
* @see DeprecatedModalFooter
|
|
34
|
+
* @see DeprecatedModalBody
|
|
35
|
+
* @deprecated
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function DeprecatedModal(_ref) {
|
|
40
|
+
let {
|
|
41
|
+
isOpen,
|
|
42
|
+
onDismiss,
|
|
43
|
+
height = 'fitContent',
|
|
44
|
+
width = 'medium',
|
|
45
|
+
exceptionallySetClassName,
|
|
46
|
+
autoFocus = true,
|
|
47
|
+
children
|
|
48
|
+
} = _ref,
|
|
49
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
50
|
+
|
|
51
|
+
const contextValue = useMemo(() => ({
|
|
52
|
+
onDismiss,
|
|
53
|
+
height
|
|
54
|
+
}), [onDismiss, height]);
|
|
55
|
+
return /*#__PURE__*/createElement(DialogOverlay, {
|
|
56
|
+
isOpen: isOpen,
|
|
57
|
+
onDismiss: onDismiss,
|
|
58
|
+
dangerouslyBypassFocusLock // We're setting up our own focus lock below
|
|
59
|
+
: true,
|
|
60
|
+
className: classNames(styles.overlay, styles[height], styles[width]),
|
|
61
|
+
"data-testid": "modal-overlay"
|
|
62
|
+
}, /*#__PURE__*/createElement(FocusLock, {
|
|
63
|
+
autoFocus: autoFocus,
|
|
64
|
+
whiteList: isNotInternalFrame,
|
|
65
|
+
returnFocus: true
|
|
66
|
+
}, /*#__PURE__*/createElement(DialogContent, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
67
|
+
as: Box,
|
|
68
|
+
borderRadius: "full",
|
|
69
|
+
background: "default",
|
|
70
|
+
display: "flex",
|
|
71
|
+
flexDirection: "column",
|
|
72
|
+
overflow: "hidden",
|
|
73
|
+
height: height === 'expand' ? 'full' : undefined,
|
|
74
|
+
flexGrow: height === 'expand' ? 1 : 0,
|
|
75
|
+
className: [exceptionallySetClassName, styles.container]
|
|
76
|
+
}), /*#__PURE__*/createElement(ModalContext.Provider, {
|
|
77
|
+
value: contextValue
|
|
78
|
+
}, children))));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The close button rendered by ModalHeader. Provided independently so that consumers can customize
|
|
82
|
+
* the button's label.
|
|
83
|
+
*
|
|
84
|
+
* @see DeprecatedModalHeader
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
function DeprecatedModalCloseButton(props) {
|
|
88
|
+
const {
|
|
89
|
+
onDismiss
|
|
90
|
+
} = useContext(ModalContext);
|
|
91
|
+
const [includeInTabOrder, setIncludeInTabOrder] = useState(false);
|
|
92
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
93
|
+
useEffect(function skipAutoFocus() {
|
|
94
|
+
if (isMounted) {
|
|
95
|
+
setIncludeInTabOrder(true);
|
|
96
|
+
} else {
|
|
97
|
+
setIsMounted(true);
|
|
98
|
+
}
|
|
99
|
+
}, [isMounted]);
|
|
100
|
+
return /*#__PURE__*/createElement(Button, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
101
|
+
variant: "quaternary",
|
|
102
|
+
onClick: onDismiss,
|
|
103
|
+
icon: /*#__PURE__*/createElement(CloseIcon, null),
|
|
104
|
+
tabIndex: includeInTabOrder ? 0 : -1
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Renders a standard modal header area with an optional close button.
|
|
109
|
+
*
|
|
110
|
+
* @see DeprecatedModal
|
|
111
|
+
* @see DeprecatedModalFooter
|
|
112
|
+
* @see DeprecatedModalBody
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
function DeprecatedModalHeader(_ref2) {
|
|
116
|
+
let {
|
|
117
|
+
children,
|
|
118
|
+
button = true,
|
|
119
|
+
withDivider = false,
|
|
120
|
+
exceptionallySetClassName
|
|
121
|
+
} = _ref2,
|
|
122
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
123
|
+
|
|
124
|
+
return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
125
|
+
as: "header",
|
|
126
|
+
paddingLeft: "large",
|
|
127
|
+
paddingRight: button === false || button === null ? 'large' : 'small',
|
|
128
|
+
paddingY: "small",
|
|
129
|
+
className: exceptionallySetClassName
|
|
130
|
+
}), /*#__PURE__*/createElement(Columns, {
|
|
131
|
+
space: "large",
|
|
132
|
+
alignY: "center"
|
|
133
|
+
}, /*#__PURE__*/createElement(Column, {
|
|
134
|
+
width: "auto"
|
|
135
|
+
}, children), button === false || button === null ? /*#__PURE__*/createElement("div", {
|
|
136
|
+
className: styles.headerContent
|
|
137
|
+
}) : /*#__PURE__*/createElement(Column, {
|
|
138
|
+
width: "content",
|
|
139
|
+
exceptionallySetClassName: styles.buttonContainer,
|
|
140
|
+
"data-testid": "button-container"
|
|
141
|
+
}, typeof button === 'boolean' ? /*#__PURE__*/createElement(DeprecatedModalCloseButton, {
|
|
142
|
+
"aria-label": "Close modal",
|
|
143
|
+
autoFocus: false
|
|
144
|
+
}) : button))), withDivider ? /*#__PURE__*/createElement(Divider, null) : null);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Renders the body of a modal.
|
|
148
|
+
*
|
|
149
|
+
* Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other
|
|
150
|
+
* things, that the contet of the modal body expands or contracts depending on the modal height
|
|
151
|
+
* setting or the size of the content. The body content also automatically scrolls when it's too
|
|
152
|
+
* large to fit the available space.
|
|
153
|
+
*
|
|
154
|
+
* @see DeprecatedModal
|
|
155
|
+
* @see DeprecatedModalHeader
|
|
156
|
+
* @see DeprecatedModalFooter
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
function DeprecatedModalBody(_ref3) {
|
|
160
|
+
let {
|
|
161
|
+
exceptionallySetClassName,
|
|
162
|
+
children
|
|
163
|
+
} = _ref3,
|
|
164
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
165
|
+
|
|
166
|
+
const {
|
|
167
|
+
height
|
|
168
|
+
} = useContext(ModalContext);
|
|
169
|
+
return /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
170
|
+
className: exceptionallySetClassName,
|
|
171
|
+
flexGrow: height === 'expand' ? 1 : 0,
|
|
172
|
+
height: height === 'expand' ? 'full' : undefined,
|
|
173
|
+
overflow: "auto"
|
|
174
|
+
}), /*#__PURE__*/createElement(Box, {
|
|
175
|
+
padding: "large",
|
|
176
|
+
paddingBottom: "xxlarge"
|
|
177
|
+
}, children));
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Renders a standard modal footer area.
|
|
181
|
+
*
|
|
182
|
+
* @see DeprecatedModal
|
|
183
|
+
* @see DeprecatedModalHeader
|
|
184
|
+
* @see DeprecatedModalBody
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
function DeprecatedModalFooter(_ref4) {
|
|
188
|
+
let {
|
|
189
|
+
exceptionallySetClassName,
|
|
190
|
+
withDivider = false
|
|
191
|
+
} = _ref4,
|
|
192
|
+
props = _objectWithoutProperties(_ref4, _excluded4);
|
|
193
|
+
|
|
194
|
+
return /*#__PURE__*/createElement(Fragment, null, withDivider ? /*#__PURE__*/createElement(Divider, null) : null, /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({
|
|
195
|
+
as: "footer"
|
|
196
|
+
}, props), {}, {
|
|
197
|
+
className: exceptionallySetClassName,
|
|
198
|
+
padding: "large"
|
|
199
|
+
})));
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).
|
|
203
|
+
* @see DeprecatedModalFooter
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
function DeprecatedModalActions(_ref5) {
|
|
207
|
+
let {
|
|
208
|
+
children
|
|
209
|
+
} = _ref5,
|
|
210
|
+
props = _objectWithoutProperties(_ref5, _excluded5);
|
|
211
|
+
|
|
212
|
+
return /*#__PURE__*/createElement(DeprecatedModalFooter, _objectSpread2({}, props), /*#__PURE__*/createElement(Inline, {
|
|
213
|
+
align: "right",
|
|
214
|
+
space: "large"
|
|
215
|
+
}, children));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { DeprecatedModal, DeprecatedModalActions, DeprecatedModalBody, DeprecatedModalCloseButton, DeprecatedModalFooter, DeprecatedModalHeader };
|
|
219
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../src/new-components/deprecated-modal/modal.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { DialogOverlay, DialogContent } from '@reach/dialog'\nimport FocusLock from 'react-focus-lock'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Column, Columns } from '../columns'\nimport { Inline } from '../inline'\nimport { Divider } from '../divider'\nimport { Box } from '../box'\nimport { Button, ButtonProps } from '../button'\n\nimport styles from './modal.module.css'\n\ntype ModalWidth = 'small' | 'medium' | 'large' | 'xlarge' | 'full'\ntype ModalHeightMode = 'expand' | 'fitContent'\n\n//\n// ModalContext\n//\n\ntype ModalContextValue = {\n onDismiss?(this: void): void\n height: ModalHeightMode\n}\n\nconst ModalContext = React.createContext<ModalContextValue>({\n onDismiss: undefined,\n height: 'fitContent',\n})\n\n//\n// Modal container\n//\n\ntype DivProps = Omit<\n React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLDivElement>, HTMLDivElement>,\n 'className' | 'children' | `aria-label` | `aria-labelledby`\n>\n\nexport type DeprecatedModalProps = DivProps & {\n /**\n * The content of the modal.\n */\n children: React.ReactNode\n /**\n * Whether the modal is open and visible or not.\n */\n isOpen: boolean\n /**\n * Called when the user triggers closing the modal.\n */\n onDismiss?(): void\n /**\n * A descriptive setting for how wide the modal should aim to be, depending on how much space\n * it has on screen.\n * @default 'medium'\n */\n width?: ModalWidth\n /**\n * A descriptive setting for how tall the modal should aim to be.\n *\n * - 'expand': the modal aims to fill most of the available screen height, leaving only a small\n * padding above and below.\n * - 'fitContent': the modal shrinks to the smallest size that allow it to fit its content.\n *\n * In either case, if content does not fit, the content of the main body is set to scroll\n * (provided you use `ModalBody`) so that the modal never has to strech vertically beyond the\n * viewport boundaries.\n *\n * If you do not use `ModalBody`, the modal still prevents overflow, and you are in charge of\n * the inner layout to ensure scroll, or whatever other strategy you may want.\n */\n height?: ModalHeightMode\n /**\n * Whether to set or not the focus initially to the first focusable element inside the modal.\n */\n autoFocus?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n /** Defines a string value that labels the current modal for assistive technologies. */\n 'aria-label'?: string\n /** Identifies the element (or elements) that labels the current modal for assistive technologies. */\n 'aria-labelledby'?: string\n}\n\nfunction isNotInternalFrame(element: HTMLElement) {\n return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe')\n}\n\n/**\n * Renders a modal that sits on top of the rest of the content in the entire page.\n *\n * Follows the WAI-ARIA Dialog (Modal) Pattern.\n *\n * @see DeprecatedModalHeader\n * @see DeprecatedModalFooter\n * @see DeprecatedModalBody\n * @deprecated\n */\nexport function DeprecatedModal({\n isOpen,\n onDismiss,\n height = 'fitContent',\n width = 'medium',\n exceptionallySetClassName,\n autoFocus = true,\n children,\n ...props\n}: DeprecatedModalProps) {\n const contextValue: ModalContextValue = React.useMemo(() => ({ onDismiss, height }), [\n onDismiss,\n height,\n ])\n\n return (\n <DialogOverlay\n isOpen={isOpen}\n onDismiss={onDismiss}\n dangerouslyBypassFocusLock // We're setting up our own focus lock below\n className={classNames(styles.overlay, styles[height], styles[width])}\n data-testid=\"modal-overlay\"\n >\n <FocusLock autoFocus={autoFocus} whiteList={isNotInternalFrame} returnFocus={true}>\n <DialogContent\n {...props}\n as={Box}\n borderRadius=\"full\"\n background=\"default\"\n display=\"flex\"\n flexDirection=\"column\"\n overflow=\"hidden\"\n height={height === 'expand' ? 'full' : undefined}\n flexGrow={height === 'expand' ? 1 : 0}\n className={[exceptionallySetClassName, styles.container]}\n >\n <ModalContext.Provider value={contextValue}>{children}</ModalContext.Provider>\n </DialogContent>\n </FocusLock>\n </DialogOverlay>\n )\n}\n\n//\n// ModalCloseButton\n//\n\nexport type DeprecatedModalCloseButtonProps = Omit<\n ButtonProps,\n | 'type'\n | 'children'\n | 'variant'\n | 'icon'\n | 'startIcon'\n | 'endIcon'\n | 'disabled'\n | 'loading'\n | 'tabIndex'\n | 'width'\n | 'align'\n> & {\n /**\n * The descriptive label of the button.\n */\n 'aria-label': string\n}\n\n/**\n * The close button rendered by ModalHeader. Provided independently so that consumers can customize\n * the button's label.\n *\n * @see DeprecatedModalHeader\n */\nexport function DeprecatedModalCloseButton(props: DeprecatedModalCloseButtonProps) {\n const { onDismiss } = React.useContext(ModalContext)\n const [includeInTabOrder, setIncludeInTabOrder] = React.useState(false)\n const [isMounted, setIsMounted] = React.useState(false)\n\n React.useEffect(\n function skipAutoFocus() {\n if (isMounted) {\n setIncludeInTabOrder(true)\n } else {\n setIsMounted(true)\n }\n },\n [isMounted],\n )\n\n return (\n <Button\n {...props}\n variant=\"quaternary\"\n onClick={onDismiss}\n icon={<CloseIcon />}\n tabIndex={includeInTabOrder ? 0 : -1}\n />\n )\n}\n\n//\n// ModalHeader\n//\n\nexport type DeprecatedModalHeaderProps = DivProps & {\n /**\n * The content of the header.\n */\n children: React.ReactNode\n /**\n * Allows to provide a custom button element, or to omit the close button if set to false.\n * @see DeprecatedModalCloseButton\n */\n button?: React.ReactNode | boolean\n /**\n * Whether to render a divider line below the header.\n * @default false\n */\n withDivider?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders a standard modal header area with an optional close button.\n *\n * @see DeprecatedModal\n * @see DeprecatedModalFooter\n * @see DeprecatedModalBody\n */\nexport function DeprecatedModalHeader({\n children,\n button = true,\n withDivider = false,\n exceptionallySetClassName,\n ...props\n}: DeprecatedModalHeaderProps) {\n return (\n <>\n <Box\n {...props}\n as=\"header\"\n paddingLeft=\"large\"\n paddingRight={button === false || button === null ? 'large' : 'small'}\n paddingY=\"small\"\n className={exceptionallySetClassName}\n >\n <Columns space=\"large\" alignY=\"center\">\n <Column width=\"auto\">{children}</Column>\n {button === false || button === null ? (\n <div className={styles.headerContent} />\n ) : (\n <Column\n width=\"content\"\n exceptionallySetClassName={styles.buttonContainer}\n data-testid=\"button-container\"\n >\n {typeof button === 'boolean' ? (\n <DeprecatedModalCloseButton\n aria-label=\"Close modal\"\n autoFocus={false}\n />\n ) : (\n button\n )}\n </Column>\n )}\n </Columns>\n </Box>\n {withDivider ? <Divider /> : null}\n </>\n )\n}\n\n//\n// ModalBody\n//\n\nexport type DeprecatedModalBodyProps = DivProps & {\n /**\n * The content of the modal body.\n */\n children: React.ReactNode\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders the body of a modal.\n *\n * Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other\n * things, that the contet of the modal body expands or contracts depending on the modal height\n * setting or the size of the content. The body content also automatically scrolls when it's too\n * large to fit the available space.\n *\n * @see DeprecatedModal\n * @see DeprecatedModalHeader\n * @see DeprecatedModalFooter\n */\nexport function DeprecatedModalBody({\n exceptionallySetClassName,\n children,\n ...props\n}: DeprecatedModalBodyProps) {\n const { height } = React.useContext(ModalContext)\n return (\n <Box\n {...props}\n className={exceptionallySetClassName}\n flexGrow={height === 'expand' ? 1 : 0}\n height={height === 'expand' ? 'full' : undefined}\n overflow=\"auto\"\n >\n <Box padding=\"large\" paddingBottom=\"xxlarge\">\n {children}\n </Box>\n </Box>\n )\n}\n\n//\n// ModalFooter\n//\n\nexport type DeprecatedModalFooterProps = DivProps & {\n /**\n * The contant of the modal footer.\n */\n children: React.ReactNode\n /**\n * Whether to render a divider line below the footer.\n * @default false\n */\n withDivider?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders a standard modal footer area.\n *\n * @see DeprecatedModal\n * @see DeprecatedModalHeader\n * @see DeprecatedModalBody\n */\nexport function DeprecatedModalFooter({\n exceptionallySetClassName,\n withDivider = false,\n ...props\n}: DeprecatedModalFooterProps) {\n return (\n <>\n {withDivider ? <Divider /> : null}\n <Box as=\"footer\" {...props} className={exceptionallySetClassName} padding=\"large\" />\n </>\n )\n}\n\n//\n// ModalActions\n//\n\nexport type DeprecatedModalActionsProps = DeprecatedModalFooterProps\n\n/**\n * A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).\n * @see DeprecatedModalFooter\n */\nexport function DeprecatedModalActions({ children, ...props }: DeprecatedModalActionsProps) {\n return (\n <DeprecatedModalFooter {...props}>\n <Inline align=\"right\" space=\"large\">\n {children}\n </Inline>\n </DeprecatedModalFooter>\n )\n}\n"],"names":["ModalContext","React","onDismiss","undefined","height","isNotInternalFrame","element","ownerDocument","document","tagName","toLowerCase","DeprecatedModal","isOpen","width","exceptionallySetClassName","autoFocus","children","props","contextValue","DialogOverlay","dangerouslyBypassFocusLock","className","classNames","styles","overlay","FocusLock","whiteList","returnFocus","DialogContent","as","Box","borderRadius","background","display","flexDirection","overflow","flexGrow","container","Provider","value","DeprecatedModalCloseButton","includeInTabOrder","setIncludeInTabOrder","isMounted","setIsMounted","skipAutoFocus","Button","variant","onClick","icon","CloseIcon","tabIndex","DeprecatedModalHeader","button","withDivider","paddingLeft","paddingRight","paddingY","Columns","space","alignY","Column","headerContent","buttonContainer","Divider","DeprecatedModalBody","padding","paddingBottom","DeprecatedModalFooter","DeprecatedModalActions","Inline","align"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,MAAMA,YAAY,gBAAGC,aAAA,CAAuC;EACxDC,SAAS,EAAEC,SAD6C;EAExDC,MAAM,EAAE;AAFgD,CAAvC,CAArB;;AA8DA,SAASC,kBAAT,CAA4BC,OAA5B;EACI,OAAO,EAAEA,OAAO,CAACC,aAAR,KAA0BC,QAA1B,IAAsCF,OAAO,CAACG,OAAR,CAAgBC,WAAhB,OAAkC,QAA1E,CAAP;AACH;AAED;;;;;;;;;;;;SAUgBC;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}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var modules_8f59d13b = {"reach-portal":"_37bef8d8","fadein":"_77f9687f","fitContent":"bcc4e0a5","container":"d4832c2d","full":"b0c3b021","large":"_573d6aa5","medium":"_8550d996","small":"_43bb18f5","xlarge":"_57b4159d","overlay":"cb63f300","expand":"e741893e","buttonContainer":"bb1ce281","headerContent":"c5ef989c"};
|
|
2
|
+
|
|
3
|
+
export default modules_8f59d13b;
|
|
4
|
+
//# sourceMappingURL=modal.module.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|