@doist/reactist 12.0.2 → 12.1.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 +99 -32
- 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/menu/menu.js +3 -2
- package/es/components/menu/menu.js.map +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/menu/menu.d.ts +2 -1
- package/lib/components/menu/menu.js +1 -1
- package/lib/components/menu/menu.js.map +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/base-field.css +4 -3
- package/styles/base-field.module.css.css +1 -1
- package/styles/checkbox-field.css +1 -1
- package/styles/menu.css +1 -1
- package/styles/password-field.css +5 -4
- package/styles/password-field.module.css.css +1 -1
- package/styles/reactist.css +8 -8
- 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
|
@@ -18,7 +18,8 @@ const MenuContext = /*#__PURE__*/createContext( // Ariakit gives us no means to
|
|
|
18
18
|
{});
|
|
19
19
|
/**
|
|
20
20
|
* Wrapper component to control a menu. It does not render anything, only providing the state
|
|
21
|
-
* management for the menu components inside it.
|
|
21
|
+
* management for the menu components inside it. Note that if you are relying on the `[role='menu']`
|
|
22
|
+
* attribute to style the menu list, it is applied a `menubar` role instead in Safari.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
function Menu(_ref) {
|
|
@@ -31,7 +32,7 @@ function Menu(_ref) {
|
|
|
31
32
|
const state = useMenuState(_objectSpread2({
|
|
32
33
|
focusLoop: true,
|
|
33
34
|
gutter: 8,
|
|
34
|
-
shift:
|
|
35
|
+
shift: 4
|
|
35
36
|
}, props));
|
|
36
37
|
const handleItemSelect = useCallback(function handleItemSelect(value) {
|
|
37
38
|
if (onItemSelect) onItemSelect(value);
|
|
@@ -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.\n */\nfunction Menu({ children, onItemSelect, ...props }: MenuProps) {\n const state = Ariakit.useMenuState({ focusLoop: true, gutter: 8, shift: 8, ...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;;;;;AAIA,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,QA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mBwC,MAAnB,oCACMG,SADN;IAEG1B,SAAS,EAAEC,UAAU,CAACyB,SAAS,CAAC1B,SAAX,EAAsB,yBAAtB,CAFxB;IAGGF;KAJR,EAMK0B,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 { 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;IAAY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 +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;IAAaC,IAAI,EAAC,WAAlB;IAA8BC,IAAI,EAAC;KAAWL,KAA9C,EAAP;AACH;;AAED,SAASM,WAAT,CAAqBN,KAArB;EACI,oBACIC,aAAA,MAAA;IACIM,KAAK,EAAC,IADV;IAEIC,MAAM,EAAC,IAFX;IAGIC,OAAO,EAAC,WAHZ;IAIIC,IAAI,EAAC,MAJT;IAKIC,KAAK,EAAC;KACFX,KANR,gBAQIC,aAAA,OAAA;IACIW,QAAQ,EAAC;IACTC,QAAQ,EAAC;IACTC,CAAC,EAAC;IACFJ,IAAI,EAAC;GAJT,CARJ,CADJ;AAiBH;;AAQD,SAASK,YAAT,CAAsB;EAAEC,EAAF;EAAMC,QAAN;EAAgBb;AAAhB,CAAtB;EACI,MAAMc,QAAQ,GAAGd,IAAI,KAAK,OAAT,GAAmB,QAAnB,GAA8BA,IAAI,KAAK,SAAT,GAAqB,UAArB,GAAkC,QAAjF;EACA,oBACIH,aAAA,CAACC,IAAD;IAAMC,EAAE,EAAC;IAAIC,IAAI,EAAEc;IAAUb,IAAI,EAAC;IAAOW,EAAE,EAAEA;GAA7C,e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AyBJ,MAAM,CAAC2B,QAAhC,GAA2C,IAJpC;IAMXjB,QAAQ,EAAEA;GAPd,eASIhC,aAAA,CAACkB,GAAD;IAAKhB,EAAE,EAAC;IAAOkB,OAAO,EAAC;IAAO8B,cAAc,EAAC;IAAeC,UAAU,EAAC;GAAvE,eACInD,aAAA,CAACC,IAAD;IACIG,IAAI,EAAEsB,OAAO,KAAK,UAAZ,GAAyB,SAAzB,GAAqC;IAC3CxB,EAAE,EAAC;IACHkD,OAAO,EAAErC;GAHb,EAKKY,KAAK,gBAAG3B,aAAA,OAAA;IAAMqB,SAAS,EAAEC,MAAM,CAAC+B;GAAxB,EAAuC1B,KAAvC,CAAH,GAA0D,IALpE,EAMKC,cAAc,gBACX5B,aAAA,OAAA;IAAMqB,SAAS,EAAEC,MAAM,CAACM;GAAxB,WAAA,EAAgDA,cAAhD,KAAA,CADW,GAEX,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,GA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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;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var modules_a9637dd3 = {"text":"
|
|
1
|
+
var modules_a9637dd3 = {"text":"a83bd4e0","size-caption":"_266d6623","size-copy":"a8d37c6e","size-subtitle":"_39f4eb1f","weight-semibold":"_7be5c531","weight-bold":"e214ff2e","tone-secondary":"_6a3e5ade","tone-danger":"_8f5b5f2b","tone-positive":"_9ae47ae4","lineClampMultipleLines":"_969f18f7","lineClamp-1":"_2f303ac3","lineClamp-2":"d3e04245","lineClamp-3":"_33411704","lineClamp-4":"bfc32640","lineClamp-5":"f813c82f"};
|
|
2
2
|
|
|
3
3
|
export default modules_a9637dd3;
|
|
4
4
|
//# sourceMappingURL=text.module.css.js.map
|
|
@@ -4,29 +4,36 @@ import { Box } from '../box/box.js';
|
|
|
4
4
|
import { BaseField } from '../base-field/base-field.js';
|
|
5
5
|
import styles from './text-area.module.css.js';
|
|
6
6
|
|
|
7
|
-
const _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "maxWidth"];
|
|
7
|
+
const _excluded = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth"];
|
|
8
8
|
|
|
9
9
|
function TextArea(_ref) {
|
|
10
10
|
let {
|
|
11
|
+
variant = 'default',
|
|
11
12
|
id,
|
|
12
13
|
label,
|
|
13
14
|
secondaryLabel,
|
|
14
15
|
auxiliaryLabel,
|
|
15
16
|
hint,
|
|
17
|
+
message,
|
|
18
|
+
tone,
|
|
16
19
|
maxWidth
|
|
17
20
|
} = _ref,
|
|
18
21
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
22
|
|
|
20
23
|
return /*#__PURE__*/createElement(BaseField, {
|
|
24
|
+
variant: variant,
|
|
21
25
|
id: id,
|
|
22
26
|
label: label,
|
|
23
27
|
secondaryLabel: secondaryLabel,
|
|
24
28
|
auxiliaryLabel: auxiliaryLabel,
|
|
25
29
|
hint: hint,
|
|
26
|
-
|
|
30
|
+
message: message,
|
|
31
|
+
tone: tone,
|
|
32
|
+
className: [styles.container, tone === 'error' ? styles.error : null, variant === 'bordered' ? styles.bordered : null],
|
|
27
33
|
maxWidth: maxWidth
|
|
28
34
|
}, extraProps => /*#__PURE__*/createElement(Box, {
|
|
29
|
-
width: "full"
|
|
35
|
+
width: "full",
|
|
36
|
+
display: "flex"
|
|
30
37
|
}, /*#__PURE__*/createElement("textarea", _objectSpread2(_objectSpread2({}, props), extraProps))));
|
|
31
38
|
}
|
|
32
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-area.js","sources":["../../../src/new-components/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ntype TextAreaProps = FieldComponentProps<HTMLTextAreaElement> & {\n
|
|
1
|
+
{"version":3,"file":"text-area.js","sources":["../../../src/new-components/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ntype TextAreaProps = FieldComponentProps<HTMLTextAreaElement> &\n BaseFieldVariantProps & {\n rows?: number\n }\n\nfunction TextArea({\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n ...props\n}: TextAreaProps) {\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 className={[\n styles.container,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box width=\"full\" display=\"flex\">\n <textarea {...props} {...extraProps} />\n </Box>\n )}\n </BaseField>\n )\n}\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","props","React","BaseField","className","styles","container","error","bordered","extraProps","Box","width","display"],"mappings":";;;;;;;;AAUA,SAASA,QAAT;MAAkB;IACdC,OAAO,GAAG,SADI;IAEdC,EAFc;IAGdC,KAHc;IAIdC,cAJc;IAKdC,cALc;IAMdC,IANc;IAOdC,OAPc;IAQdC,IARc;IASdC;;MACGC;;EAEH,oBACIC,aAAA,CAACC,SAAD;IACIX,OAAO,EAAEA;IACTC,EAAE,EAAEA;IACJC,KAAK,EAAEA;IACPC,cAAc,EAAEA;IAChBC,cAAc,EAAEA;IAChBC,IAAI,EAAEA;IACNC,OAAO,EAAEA;IACTC,IAAI,EAAEA;IACNK,SAAS,EAAE,CACPC,MAAM,CAACC,SADA,EAEPP,IAAI,KAAK,OAAT,GAAmBM,MAAM,CAACE,KAA1B,GAAkC,IAF3B,EAGPf,OAAO,KAAK,UAAZ,GAAyBa,MAAM,CAACG,QAAhC,GAA2C,IAHpC;IAKXR,QAAQ,EAAEA;GAdd,EAgBMS,UAAD,iBACGP,aAAA,CAACQ,GAAD;IAAKC,KAAK,EAAC;IAAOC,OAAO,EAAC;GAA1B,eACIV,aAAA,WAAA,oCAAcD,KAAd,GAAyBQ,UAAzB,EADJ,CAjBR,CADJ;AAwBH;;;;"}
|
|
@@ -4,14 +4,17 @@ import { Box } from '../box/box.js';
|
|
|
4
4
|
import { BaseField } from '../base-field/base-field.js';
|
|
5
5
|
import styles from './text-field.module.css.js';
|
|
6
6
|
|
|
7
|
-
const _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "type", "maxWidth", "hidden", "aria-describedby"];
|
|
7
|
+
const _excluded = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "type", "maxWidth", "hidden", "aria-describedby"];
|
|
8
8
|
const TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
|
|
9
9
|
let {
|
|
10
|
+
variant = 'default',
|
|
10
11
|
id,
|
|
11
12
|
label,
|
|
12
13
|
secondaryLabel,
|
|
13
14
|
auxiliaryLabel,
|
|
14
15
|
hint,
|
|
16
|
+
message,
|
|
17
|
+
tone,
|
|
15
18
|
type = 'text',
|
|
16
19
|
maxWidth,
|
|
17
20
|
hidden,
|
|
@@ -20,16 +23,19 @@ const TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
|
|
|
20
23
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
24
|
|
|
22
25
|
return /*#__PURE__*/createElement(BaseField, {
|
|
26
|
+
variant: variant,
|
|
23
27
|
id: id,
|
|
24
28
|
label: label,
|
|
25
29
|
secondaryLabel: secondaryLabel,
|
|
26
30
|
auxiliaryLabel: auxiliaryLabel,
|
|
27
31
|
hint: hint,
|
|
32
|
+
message: message,
|
|
33
|
+
tone: tone,
|
|
28
34
|
maxWidth: maxWidth,
|
|
29
35
|
hidden: hidden,
|
|
30
36
|
"aria-describedby": ariaDescribedBy
|
|
31
37
|
}, extraProps => /*#__PURE__*/createElement(Box, {
|
|
32
|
-
className: styles.inputWrapper
|
|
38
|
+
className: [styles.inputWrapper, tone === 'error' ? styles.error : null, variant === 'bordered' ? styles.bordered : null]
|
|
33
39
|
}, /*#__PURE__*/createElement("input", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
|
|
34
40
|
type: type,
|
|
35
41
|
ref: ref
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.js","sources":["../../../src/new-components/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ntype TextFieldProps = Omit<FieldComponentProps<HTMLInputElement>, 'type'> & {\n
|
|
1
|
+
{"version":3,"file":"text-field.js","sources":["../../../src/new-components/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ntype TextFieldProps = Omit<FieldComponentProps<HTMLInputElement>, 'type'> &\n BaseFieldVariantProps & {\n type?: TextFieldType\n }\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\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 className={[\n styles.inputWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n >\n <input {...props} {...extraProps} type={type} ref={ref} />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","type","maxWidth","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","inputWrapper","error","bordered"],"mappings":";;;;;;;MAaMA,SAAS,gBAAGC,UAAA,CAAmD,SAASD,SAAT,OAgBjEE,GAhBiE;MACjE;IACIC,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,cAJJ;IAKIC,cALJ;IAMIC,IANJ;IAOIC,OAPJ;IAQIC,IARJ;IASIC,IAAI,GAAG,MATX;IAUIC,QAVJ;IAWIC,MAXJ;IAYI,oBAAoBC;;MACjBC;;EAIP,oBACId,aAAA,CAACe,SAAD;IACIb,OAAO,EAAEA;IACTC,EAAE,EAAEA;IACJC,KAAK,EAAEA;IACPC,cAAc,EAAEA;IAChBC,cAAc,EAAEA;IAChBC,IAAI,EAAEA;IACNC,OAAO,EAAEA;IACTC,IAAI,EAAEA;IACNE,QAAQ,EAAEA;IACVC,MAAM,EAAEA;wBACUC;GAXtB,EAaMG,UAAD,iBACGhB,aAAA,CAACiB,GAAD;IACIC,SAAS,EAAE,CACPC,MAAM,CAACC,YADA,EAEPX,IAAI,KAAK,OAAT,GAAmBU,MAAM,CAACE,KAA1B,GAAkC,IAF3B,EAGPnB,OAAO,KAAK,UAAZ,GAAyBiB,MAAM,CAACG,QAAhC,GAA2C,IAHpC;GADf,eAOItB,aAAA,QAAA,mDAAWc,KAAX,GAAsBE,UAAtB;IAAkCN,IAAI,EAAEA,IAAxC;IAA8CT,GAAG,EAAEA;KAPvD,CAdR,CADJ;AA2BH,CA7CiB;;;;"}
|
|
@@ -19,7 +19,8 @@ declare type MenuProps = Omit<Ariakit.MenuStateProps, 'visible'> & {
|
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* Wrapper component to control a menu. It does not render anything, only providing the state
|
|
22
|
-
* management for the menu components inside it.
|
|
22
|
+
* management for the menu components inside it. Note that if you are relying on the `[role='menu']`
|
|
23
|
+
* attribute to style the menu list, it is applied a `menubar` role instead in Safari.
|
|
23
24
|
*/
|
|
24
25
|
declare function Menu({ children, onItemSelect, ...props }: MenuProps): JSX.Element;
|
|
25
26
|
declare type MenuButtonProps = Omit<Ariakit.MenuButtonProps, 'state' | 'className' | 'as'>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js"),n=require("react"),o=(e(n),e(require("classnames"))),l=require("../../utils/polymorphism.js"),r=require("ariakit/menu"),a=require("ariakit/portal");const c=["children","onItemSelect"],s=["exceptionallySetClassName"],u=["exceptionallySetClassName"],i=["value","children","onSelect","hideOnSelect","onClick","exceptionallySetClassName","as"],p=["label","children","exceptionallySetClassName"],m=n.createContext({});function d(e){let{children:o,onItemSelect:l}=e,a=t.objectWithoutProperties(e,c);const s=r.useMenuState(t.objectSpread2({focusLoop:!0,gutter:8,shift:
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js"),n=require("react"),o=(e(n),e(require("classnames"))),l=require("../../utils/polymorphism.js"),r=require("ariakit/menu"),a=require("ariakit/portal");const c=["children","onItemSelect"],s=["exceptionallySetClassName"],u=["exceptionallySetClassName"],i=["value","children","onSelect","hideOnSelect","onClick","exceptionallySetClassName","as"],p=["label","children","exceptionallySetClassName"],m=n.createContext({});function d(e){let{children:o,onItemSelect:l}=e,a=t.objectWithoutProperties(e,c);const s=r.useMenuState(t.objectSpread2({focusLoop:!0,gutter:8,shift:4},a)),u=n.useCallback((function(e){l&&l(e)}),[l]),i=n.useMemo(()=>({state:s,handleItemSelect:u}),[s,u]);return n.createElement(m.Provider,{value:i},o)}const b=l.polymorphicComponent((function(e,l){let{exceptionallySetClassName:a}=e,c=t.objectWithoutProperties(e,s);const{state:u}=n.useContext(m);return n.createElement(r.MenuButton,t.objectSpread2(t.objectSpread2({},c),{},{state:u,ref:l,className:o("reactist_menubutton",a)}))})),S=l.polymorphicComponent((function(e,l){let{exceptionallySetClassName:c}=e,s=t.objectWithoutProperties(e,u);const{state:i}=n.useContext(m);return i.visible?n.createElement(a.Portal,{preserveTabOrder:!0},n.createElement(r.Menu,t.objectSpread2(t.objectSpread2({},s),{},{state:i,ref:l,className:o("reactist_menulist",c)}))):null})),h=l.polymorphicComponent((function(e,o){let{value:l,children:a,onSelect:c,hideOnSelect:s=!0,onClick:u,exceptionallySetClassName:p,as:d="button"}=e,b=t.objectWithoutProperties(e,i);const{handleItemSelect:S,state:h}=n.useContext(m),{hide:C}=h,f=n.useCallback((function(e){null==u||u(e);const t=!1!==(c&&!e.defaultPrevented?c():void 0)&&s;S(l),t&&C()}),[c,u,S,s,C,l]);return n.createElement(r.MenuItem,t.objectSpread2(t.objectSpread2({},b),{},{as:d,state:h,ref:o,onClick:f,className:p,hideOnClick:!1}),a)})),C=n.forwardRef((function({children:e,onItemSelect:l},a){const{handleItemSelect:c,state:s}=n.useContext(m),{hide:u}=s,i=n.useCallback((function(e){l&&l(e),c(e),u()}),[u,c,l]),[p,b]=n.Children.toArray(e),S=r.useMenuItem({state:s});return n.createElement(d,{onItemSelect:i},n.cloneElement(p,t.objectSpread2(t.objectSpread2({},S),{},{className:o(S.className,"reactist_submenu_button"),ref:a})),b)})),f=l.polymorphicComponent((function(e,o){let{label:l,children:a,exceptionallySetClassName:c}=e,s=t.objectWithoutProperties(e,p);const{state:u}=n.useContext(m);return n.createElement(r.MenuGroup,t.objectSpread2(t.objectSpread2({},s),{},{ref:o,state:u,className:c}),l?n.createElement("div",{role:"presentation",className:"reactist_menugroup__label"},l):null,a)}));exports.Menu=d,exports.MenuButton=b,exports.MenuGroup=f,exports.MenuItem=h,exports.MenuList=S,exports.SubMenu=C;
|
|
2
2
|
//# sourceMappingURL=menu.js.map
|