@transferwise/components 0.0.0-experimental-ddeb968 → 0.0.0-experimental-80dda9c
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 +8 -0
- package/build/common/panel/Panel.js +2 -1
- package/build/common/panel/Panel.js.map +1 -1
- package/build/common/panel/Panel.mjs +2 -1
- package/build/common/panel/Panel.mjs.map +1 -1
- package/build/select/Select.js +125 -41
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +121 -41
- package/build/select/Select.mjs.map +1 -1
- package/build/select/index.js +8 -0
- package/build/select/index.js.map +1 -0
- package/build/select/index.mjs +6 -0
- package/build/select/index.mjs.map +1 -0
- package/build/snackbar/Snackbar.js +2 -1
- package/build/snackbar/Snackbar.js.map +1 -1
- package/build/snackbar/Snackbar.mjs +2 -1
- package/build/snackbar/Snackbar.mjs.map +1 -1
- package/build/types/index.d.ts +0 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/select/Select.d.ts +94 -64
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/select/index.d.ts +2 -2
- package/build/types/select/index.d.ts.map +1 -1
- package/build/types/select/option/index.d.ts +1 -1
- package/build/types/select/option/index.d.ts.map +1 -1
- package/build/types/select/searchBox/index.d.ts +1 -1
- package/build/types/select/searchBox/index.d.ts.map +1 -1
- package/build/types/snackbar/Snackbar.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/index.ts +0 -6
- package/src/select/{Select.tsx → Select.js} +155 -137
- package/src/select/{Select.spec.tsx → Select.spec.js} +6 -8
- package/src/select/index.js +3 -0
- package/src/snackbar/Snackbar.tsx +7 -1
- package/src/select/index.ts +0 -7
- /package/src/select/option/{index.ts → index.js} +0 -0
- /package/src/select/searchBox/{SearchBox.spec.tsx → SearchBox.spec.js} +0 -0
- /package/src/select/searchBox/{index.ts → index.js} +0 -0
package/README.md
CHANGED
|
@@ -40,6 +40,14 @@ export default function Hello() {
|
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
### TypeScript | Type Declarations
|
|
44
|
+
|
|
45
|
+
This package exposes [type declarations](https://www.typescriptlang.org/docs/handbook/2/type-declarations.html) for all components.
|
|
46
|
+
|
|
47
|
+
Note: types for some of components are not 100% accurate (some of them will be just [`any`](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)), this is due to fact that many of components written on JavaScript and types generated by [react-to-typescript-definitions](https://www.npmjs.com/package/react-to-typescript-definitions) based of components `PropTypes` and unfortunatly the library doesn't resolve all `PropTypes` features and use cases (e.g custom validators, `PropTypes.objectOf`, etc). But bear with us as eventually it would be fully on TypeScript.
|
|
48
|
+
|
|
49
|
+
Please follow [rules for JS components](https://github.com/transferwise/neptune-web/blob/main/packages/components/CONTRIBUTING.md#js-component-rules) in order to generate accurate types for them.
|
|
50
|
+
|
|
43
51
|
### Mocks for testing
|
|
44
52
|
|
|
45
53
|
We expose reusable mocks for Jest and Vitest under an isolated entry point. They can be applied by passing the testing framework as the parameter:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.js","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n // eslint-disable-next-line react/forbid-dom-props\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={clsx('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div\n ref={reference}\n /* eslint-disable-next-line react/forbid-dom-props */\n style={contentStyle}\n className={clsx('np-panel__content')}\n >\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div\n ref={setArrowElement}\n className={clsx('np-panel__arrow')}\n // eslint-disable-next-line react/forbid-dom-props\n style={styles.arrow}\n />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","role","style","popper","className","clsx","_jsxs"],"mappings":";;;;;;;;;;AAkBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,iBAAQ,CAACC,GAAG,GAAG,CAACD,iBAAQ,CAACE,MAAM,EAAEF,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,iBAAQ,CAACE,MAAM,GAAG,CAACF,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACI,I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,EAAA,IAAA;IAACC,kBAAkB,EAAA,IAAA;IAACC,iBAAiB,EAAA,IAAA;AAACrC,IAAAA,OAAO,EAAEA,OAAQ;AAAAF,IAAAA,QAAA,eACpFmC,cAAA,CAAA,KAAA,EAAA;AACEK,MAAAA,EAAE,EAAER,SAAU;AAAA,MAAA,GACV1B,IAAI;AACRmC,MAAAA,GAAG,EAAE7B,gBAAiB;AACtB8B,MAAAA,IAAI,EAAC,QAAA;AACL;AAAA;AACAC,MAAAA,KAAK,EAAE;AAAE,QAAA,GAAGtB,MAAM,CAACuB,MAAAA;OAAS;MAAA,GACxBtB,UAAU,CAACsB,MAAM;AACrBC,MAAAA,SAAS,EAAEC,SAAI,CAAC,UAAU,EAAE;AAAE,QAAA,gBAAgB,EAAE7C,IAAAA;AAAI,OAAE,EAAEK,IAAI,CAACuC,SAAS,CAAE;AAAA7C,MAAAA,QAAA,eAExE+C,eAAA,CAAA,KAAA,EAAA;AACEN,QAAAA,GAAG,EAAElC,SAAAA;AACL;AACAoC,QAAAA,KAAK,EAAEf,YAAa;AACpBiB,QAAAA,SAAS,EAAEC,SAAI,CAAC,mBAAmB,CAAE;AAAA9C,QAAAA,QAAA,EAEpCA,CAAAA,QAAQ,EAERH,KAAK,iBACJsC,cAAA,CAAA,KAAA,EAAA;AACEM,UAAAA,GAAG,EAAEhC,eAAgB;UACrBoC,SAAS,EAAEC,SAAI,CAAC,iBAAiB,CAAA;AACjC;AAAA;UACAH,KAAK,EAAEtB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CAEvB,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Panel.js","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n // eslint-disable-next-line react/forbid-dom-props\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={clsx('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div\n ref={reference}\n /* eslint-disable-next-line react/forbid-dom-props */\n style={contentStyle}\n className={clsx('np-panel__content')}\n >\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div\n ref={setArrowElement}\n className={clsx('np-panel__arrow')}\n // eslint-disable-next-line react/forbid-dom-props\n style={styles.arrow}\n />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","role","style","popper","className","clsx","_jsxs"],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EC,SAAI,CAAC,iBAAiB,CAAA;AACjC;AAAA;UACAH,KAAK,EAAEtB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CAEvB,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC,CAAC,CAAA;AAEF,cAAeF,KAAK;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.mjs","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n // eslint-disable-next-line react/forbid-dom-props\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={clsx('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div\n ref={reference}\n /* eslint-disable-next-line react/forbid-dom-props */\n style={contentStyle}\n className={clsx('np-panel__content')}\n >\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div\n ref={setArrowElement}\n className={clsx('np-panel__arrow')}\n // eslint-disable-next-line react/forbid-dom-props\n style={styles.arrow}\n />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","role","style","popper","className","clsx","_jsxs"],"mappings":";;;;;;;;AAkBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,QAAQ,CAACC,GAAG,GAAG,CAACD,QAAQ,CAACE,MAAM,EAAEF,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACE,MAAM,GAAG,CAACF,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACI,IAAI,GAAG,CAACJ,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACE,MAAM,CAAC;AAChE,EAAA,CAACF,QAAQ,CAACG,KAAK,GAAG,CAACH,QAAQ,CAACI,IAAI,EAAEJ,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACE,MAAM,CAAA;CAChE,CAAA;AAcD,MAAMG,KAAK,gBAAGC,UAAU,CAA6B,SAASD,KAAKA,CACjE;AACEE,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,IAAI,GAAG,IAAI;AACXC,EAAAA,OAAO,GAAG,KAAK;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E;AAAE,QAAA,gBAAgB,EAAE7C,IAAAA;AAAI,OAAE,EAAEK,IAAI,CAACuC,SAAS,CAAE;AAAA7C,MAAAA,QAAA,eAExE+C,IAAA,CAAA,KAAA,EAAA;AACEN,QAAAA,GAAG,EAAElC,SAAAA;AACL;AACAoC,QAAAA,KAAK,EAAEf,YAAa;AACpBiB,QAAAA,SAAS,EAAEC,IAAI,CAAC,mBAAmB,CAAE;AAAA9C,QAAAA,QAAA,EAEpCA,CAAAA,QAAQ,EAERH,KAAK,iBACJsC,GAAA,CAAA,KAAA,EAAA;AACEM,UAAAA,GAAG,EAAEhC,eAAgB;UACrBoC,SAAS,EAAEC,IAAI,CAAC,iBAAiB,CAAA;AACjC;AAAA;UACAH,KAAK,EAAEtB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CAEvB,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Panel.mjs","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n // eslint-disable-next-line react/forbid-dom-props\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={clsx('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div\n ref={reference}\n /* eslint-disable-next-line react/forbid-dom-props */\n style={contentStyle}\n className={clsx('np-panel__content')}\n >\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div\n ref={setArrowElement}\n className={clsx('np-panel__arrow')}\n // eslint-disable-next-line react/forbid-dom-props\n style={styles.arrow}\n />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","role","style","popper","className","clsx","_jsxs"],"mappings":";;;;;;;;AAkBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,QAAQ,CAACC,GAAG,GAAG,CAACD,QAAQ,CAACE,MAAM,EAAEF,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACE,MAAM,GAAG,CAACF,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACI,IAAI,GAAG,CAACJ,QAAQ,CAACG,KAA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OAAQ;AAAAF,IAAAA,QAAA,eACpFmC,GAAA,CAAA,KAAA,EAAA;AACEK,MAAAA,EAAE,EAAER,SAAU;AAAA,MAAA,GACV1B,IAAI;AACRmC,MAAAA,GAAG,EAAE7B,gBAAiB;AACtB8B,MAAAA,IAAI,EAAC,QAAA;AACL;AAAA;AACAC,MAAAA,KAAK,EAAE;AAAE,QAAA,GAAGtB,MAAM,CAACuB,MAAAA;OAAS;MAAA,GACxBtB,UAAU,CAACsB,MAAM;AACrBC,MAAAA,SAAS,EAAEC,IAAI,CAAC,UAAU,EAAE;AAAE,QAAA,gBAAgB,EAAE7C,IAAAA;AAAI,OAAE,EAAEK,IAAI,CAACuC,SAAS,CAAE;AAAA7C,MAAAA,QAAA,eAExE+C,IAAA,CAAA,KAAA,EAAA;AACEN,QAAAA,GAAG,EAAElC,SAAAA;AACL;AACAoC,QAAAA,KAAK,EAAEf,YAAa;AACpBiB,QAAAA,SAAS,EAAEC,IAAI,CAAC,mBAAmB,CAAE;AAAA9C,QAAAA,QAAA,EAEpCA,CAAAA,QAAQ,EAERH,KAAK,iBACJsC,GAAA,CAAA,KAAA,EAAA;AACEM,UAAAA,GAAG,EAAEhC,eAAgB;UACrBoC,SAAS,EAAEC,IAAI,CAAC,iBAAiB,CAAA;AACjC;AAAA;UACAH,KAAK,EAAEtB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CAEvB,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC,CAAC,CAAA;AAEF,cAAeF,KAAK;;;;"}
|
package/build/select/Select.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var componentsTheming = require('@wise/components-theming');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
|
+
var PropTypes = require('prop-types');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var reactIntl = require('react-intl');
|
|
7
8
|
var Button = require('../button/Button.js');
|
|
@@ -13,11 +14,15 @@ var Drawer = require('../drawer/Drawer.js');
|
|
|
13
14
|
var contexts = require('../inputs/contexts.js');
|
|
14
15
|
var Select_messages = require('./Select.messages.js');
|
|
15
16
|
var Option = require('./option/Option.js');
|
|
16
|
-
var SearchBox = require('./searchBox/SearchBox.js');
|
|
17
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
18
18
|
var useLayout = require('../common/hooks/useLayout/useLayout.js');
|
|
19
|
+
var SearchBox = require('./searchBox/SearchBox.js');
|
|
19
20
|
var position = require('../common/propsValues/position.js');
|
|
20
21
|
|
|
22
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
+
|
|
24
|
+
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
25
|
+
|
|
21
26
|
const DEFAULT_SEARCH_VALUE = '';
|
|
22
27
|
const DEFAULT_OPTIONS_PAGE_SIZE = 1000;
|
|
23
28
|
const includesString = (string1, string2) => string1.toLowerCase().includes(string2.toLowerCase());
|
|
@@ -32,7 +37,7 @@ function defaultFilterFunction(option, searchValue) {
|
|
|
32
37
|
currency,
|
|
33
38
|
searchStrings
|
|
34
39
|
} = option;
|
|
35
|
-
return
|
|
40
|
+
return !!label && includesString(label, searchValue) || !!note && includesString(note, searchValue) || !!secondary && includesString(secondary, searchValue) || !!currency && includesString(currency, searchValue) || !!searchStrings && searchStrings.some(string => includesString(string, searchValue));
|
|
36
41
|
}
|
|
37
42
|
function isActionableOption(option) {
|
|
38
43
|
return !option.header && !option.separator && !option.disabled;
|
|
@@ -46,6 +51,7 @@ function isSeparatorOption(option) {
|
|
|
46
51
|
function clamp(from, to, value) {
|
|
47
52
|
return Math.max(Math.min(to, value), from);
|
|
48
53
|
}
|
|
54
|
+
|
|
49
55
|
/**
|
|
50
56
|
* No option or placeholder option is selected
|
|
51
57
|
*/
|
|
@@ -56,15 +62,14 @@ function isPlaceholderOption(option) {
|
|
|
56
62
|
function isSearchableOption(option) {
|
|
57
63
|
return !isHeaderOption(option) && !isSeparatorOption(option) && !isPlaceholderOption(option);
|
|
58
64
|
}
|
|
59
|
-
const getUniqueIdForOption = (parentId, option) => {
|
|
65
|
+
const getUniqueIdForOption = (parentId = '', option) => {
|
|
60
66
|
if (option == null) {
|
|
61
67
|
return undefined;
|
|
62
68
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return `option-${parentId ?? ''}-${uniqueOptionId}`;
|
|
69
|
+
const uniqueOptionId = option.value || (option.label?.replace(/\s/g, '') ?? '');
|
|
70
|
+
return `option-${parentId}-${uniqueOptionId}`;
|
|
66
71
|
};
|
|
67
|
-
|
|
72
|
+
|
|
68
73
|
/**
|
|
69
74
|
* @deprecated Use `SelectInput` instead (https://neptune.wise.design/blog/2023-11-28-adopting-our-new-selectinput)
|
|
70
75
|
*/
|
|
@@ -75,8 +80,8 @@ function Select({
|
|
|
75
80
|
disabled,
|
|
76
81
|
inverse,
|
|
77
82
|
dropdownWidth,
|
|
78
|
-
size
|
|
79
|
-
block
|
|
83
|
+
size,
|
|
84
|
+
block,
|
|
80
85
|
selected,
|
|
81
86
|
search,
|
|
82
87
|
onChange,
|
|
@@ -84,9 +89,10 @@ function Select({
|
|
|
84
89
|
onBlur,
|
|
85
90
|
options: defaultOptions,
|
|
86
91
|
onSearchChange,
|
|
87
|
-
searchValue: initSearchValue
|
|
92
|
+
searchValue: initSearchValue,
|
|
88
93
|
searchPlaceholder,
|
|
89
|
-
|
|
94
|
+
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
95
|
+
classNames: classNamesProp,
|
|
90
96
|
dropdownUp,
|
|
91
97
|
dropdownProps,
|
|
92
98
|
buttonProps
|
|
@@ -101,9 +107,9 @@ function Select({
|
|
|
101
107
|
const s = className => classNamesProp[className] || className;
|
|
102
108
|
const [open, setOpen] = React.useState(false);
|
|
103
109
|
const [searchValue, setSearchValue] = React.useState(DEFAULT_SEARCH_VALUE);
|
|
104
|
-
const [keyboardFocusedOptionIndex, setKeyboardFocusedOptionIndex] = React.useState(
|
|
105
|
-
const keyboardFocusedReference = React.useRef(
|
|
106
|
-
const previousKeyboardFocusedOptionIndex = React.useRef(
|
|
110
|
+
const [keyboardFocusedOptionIndex, setKeyboardFocusedOptionIndex] = React.useState(null);
|
|
111
|
+
const keyboardFocusedReference = React.useRef();
|
|
112
|
+
const previousKeyboardFocusedOptionIndex = React.useRef();
|
|
107
113
|
const [numberOfOptionsShown, setNumberOfOptionsShown] = React.useState(DEFAULT_OPTIONS_PAGE_SIZE);
|
|
108
114
|
const searchBoxReference = React.useRef(null);
|
|
109
115
|
const selectReference = React.useRef(null);
|
|
@@ -132,7 +138,7 @@ function Select({
|
|
|
132
138
|
isMobile
|
|
133
139
|
} = useLayout.useLayout();
|
|
134
140
|
React.useEffect(() => {
|
|
135
|
-
let cancelled
|
|
141
|
+
let cancelled;
|
|
136
142
|
if (keyboardFocusedOptionIndex >= 0) {
|
|
137
143
|
requestAnimationFrame(() => {
|
|
138
144
|
if (!cancelled) {
|
|
@@ -159,7 +165,9 @@ function Select({
|
|
|
159
165
|
}
|
|
160
166
|
};
|
|
161
167
|
const handleOnFocus = event => {
|
|
162
|
-
onFocus
|
|
168
|
+
if (onFocus) {
|
|
169
|
+
onFocus(event);
|
|
170
|
+
}
|
|
163
171
|
};
|
|
164
172
|
const handleOnBlur = event => {
|
|
165
173
|
const {
|
|
@@ -168,16 +176,20 @@ function Select({
|
|
|
168
176
|
if (nativeEvent) {
|
|
169
177
|
const elementReceivingFocus = nativeEvent.relatedTarget;
|
|
170
178
|
const select = event.currentTarget;
|
|
171
|
-
if (select && elementReceivingFocus
|
|
179
|
+
if (select && elementReceivingFocus && select.contains(elementReceivingFocus)) {
|
|
172
180
|
return;
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
|
-
onBlur
|
|
183
|
+
if (onBlur) {
|
|
184
|
+
onBlur(event);
|
|
185
|
+
}
|
|
176
186
|
};
|
|
177
187
|
const handleSearchChange = event => {
|
|
178
188
|
setNumberOfOptionsShown(DEFAULT_OPTIONS_PAGE_SIZE);
|
|
179
189
|
setSearchValue(event.target.value);
|
|
180
|
-
onSearchChange
|
|
190
|
+
if (onSearchChange) {
|
|
191
|
+
onSearchChange(event.target.value);
|
|
192
|
+
}
|
|
181
193
|
};
|
|
182
194
|
const handleKeyDown = event => {
|
|
183
195
|
switch (event.key) {
|
|
@@ -220,24 +232,24 @@ function Select({
|
|
|
220
232
|
}
|
|
221
233
|
};
|
|
222
234
|
function selectKeyboardFocusedOption() {
|
|
223
|
-
if (keyboardFocusedOptionIndex
|
|
235
|
+
if (keyboardFocusedOptionIndex != null && selectableOptions.length > 0) {
|
|
224
236
|
selectOption(selectableOptions[keyboardFocusedOptionIndex]);
|
|
225
237
|
}
|
|
226
238
|
}
|
|
227
239
|
function moveFocusWithDifference(difference) {
|
|
228
240
|
const selectedOptionIndex = selectableOptions.reduce((optionIndex, current, index) => {
|
|
229
|
-
if (optionIndex
|
|
241
|
+
if (optionIndex != null) {
|
|
230
242
|
return optionIndex;
|
|
231
243
|
}
|
|
232
244
|
if (isOptionSelected(selected, current)) {
|
|
233
245
|
return index;
|
|
234
246
|
}
|
|
235
|
-
return
|
|
236
|
-
},
|
|
237
|
-
const previousFocusedIndex = previousKeyboardFocusedOptionIndex.current;
|
|
247
|
+
return null;
|
|
248
|
+
}, null);
|
|
249
|
+
const previousFocusedIndex = previousKeyboardFocusedOptionIndex.current ?? -1;
|
|
238
250
|
let indexToStartMovingFrom = previousFocusedIndex;
|
|
239
|
-
if (previousFocusedIndex
|
|
240
|
-
if (selectedOptionIndex
|
|
251
|
+
if (previousFocusedIndex === -1) {
|
|
252
|
+
if (selectedOptionIndex == null) {
|
|
241
253
|
setKeyboardFocusedOptionIndex(0);
|
|
242
254
|
} else {
|
|
243
255
|
indexToStartMovingFrom = selectedOptionIndex;
|
|
@@ -253,18 +265,18 @@ function Select({
|
|
|
253
265
|
if (isSearchEnabled && searchBoxReference.current) {
|
|
254
266
|
searchBoxReference.current.focus();
|
|
255
267
|
}
|
|
256
|
-
if (!isSearchEnabled && optionsListReference.current && previousKeyboardFocusedOptionIndex.current
|
|
268
|
+
if (!isSearchEnabled && optionsListReference.current && (previousKeyboardFocusedOptionIndex.current == null || Number.isNaN(previousKeyboardFocusedOptionIndex.current))) {
|
|
257
269
|
optionsListReference.current.focus();
|
|
258
270
|
}
|
|
259
271
|
}
|
|
260
272
|
previousKeyboardFocusedOptionIndex.current = keyboardFocusedOptionIndex;
|
|
261
273
|
} else {
|
|
262
|
-
previousKeyboardFocusedOptionIndex.current =
|
|
274
|
+
previousKeyboardFocusedOptionIndex.current = null;
|
|
263
275
|
}
|
|
264
276
|
}, [open, searchValue, isSearchEnabled, isMobile, keyboardFocusedOptionIndex]);
|
|
265
277
|
const handleCloseOptions = () => {
|
|
266
278
|
setOpen(false);
|
|
267
|
-
setKeyboardFocusedOptionIndex(
|
|
279
|
+
setKeyboardFocusedOptionIndex(null);
|
|
268
280
|
if (dropdownButtonReference.current) {
|
|
269
281
|
dropdownButtonReference.current.focus();
|
|
270
282
|
}
|
|
@@ -280,7 +292,7 @@ function Select({
|
|
|
280
292
|
handleCloseOptions();
|
|
281
293
|
}
|
|
282
294
|
function renderOptionsList({
|
|
283
|
-
className
|
|
295
|
+
className
|
|
284
296
|
} = {}) {
|
|
285
297
|
const dropdownClass = clsx.clsx(s('np-dropdown-menu'), {
|
|
286
298
|
[s('np-dropdown-menu-desktop')]: !isMobile,
|
|
@@ -292,8 +304,8 @@ function Select({
|
|
|
292
304
|
id: listboxId,
|
|
293
305
|
role: "listbox",
|
|
294
306
|
"aria-orientation": "vertical",
|
|
295
|
-
"aria-activedescendant": getUniqueIdForOption(id, selected
|
|
296
|
-
tabIndex: -1,
|
|
307
|
+
"aria-activedescendant": getUniqueIdForOption(id, selected),
|
|
308
|
+
tabIndex: "-1",
|
|
297
309
|
className: dropdownClass,
|
|
298
310
|
...dropdownProps,
|
|
299
311
|
children: [showPlaceholder && /*#__PURE__*/jsxRuntime.jsx(PlaceHolderOption, {}), isSearchEnabled && /*#__PURE__*/jsxRuntime.jsx(SearchBox, {
|
|
@@ -343,6 +355,7 @@ function Select({
|
|
|
343
355
|
})
|
|
344
356
|
);
|
|
345
357
|
}
|
|
358
|
+
|
|
346
359
|
// eslint-disable-next-line react/prop-types
|
|
347
360
|
function SeparatorOption() {
|
|
348
361
|
return /*#__PURE__*/jsxRuntime.jsx("li", {
|
|
@@ -350,6 +363,7 @@ function Select({
|
|
|
350
363
|
"aria-hidden": true
|
|
351
364
|
});
|
|
352
365
|
}
|
|
366
|
+
|
|
353
367
|
// eslint-disable-next-line react/prop-types
|
|
354
368
|
function HeaderOption({
|
|
355
369
|
children
|
|
@@ -393,15 +407,13 @@ function Select({
|
|
|
393
407
|
"aria-selected": isActive,
|
|
394
408
|
"aria-disabled": option.disabled,
|
|
395
409
|
role: "option",
|
|
396
|
-
tabIndex: -1,
|
|
410
|
+
tabIndex: "-1",
|
|
397
411
|
className: className,
|
|
398
412
|
onClick: handleOnClick,
|
|
399
413
|
onKeyPress: handleOnClick,
|
|
400
414
|
children: /*#__PURE__*/jsxRuntime.jsx("a", {
|
|
401
415
|
disabled: selectOption.disabled,
|
|
402
416
|
children: /*#__PURE__*/jsxRuntime.jsx(Option, {
|
|
403
|
-
label: undefined,
|
|
404
|
-
value: undefined,
|
|
405
417
|
...selectOption,
|
|
406
418
|
classNames: classNamesProp
|
|
407
419
|
})
|
|
@@ -419,11 +431,11 @@ function Select({
|
|
|
419
431
|
}
|
|
420
432
|
const hasActiveOptions = !!defaultOptions.length;
|
|
421
433
|
if (open && (initSearchValue || searchValue)) {
|
|
422
|
-
if (hasActiveOptions && keyboardFocusedOptionIndex
|
|
434
|
+
if (hasActiveOptions && keyboardFocusedOptionIndex == null) {
|
|
423
435
|
setKeyboardFocusedOptionIndex(0);
|
|
424
436
|
}
|
|
425
|
-
if (!hasActiveOptions && keyboardFocusedOptionIndex
|
|
426
|
-
setKeyboardFocusedOptionIndex(
|
|
437
|
+
if (!hasActiveOptions && keyboardFocusedOptionIndex != null) {
|
|
438
|
+
setKeyboardFocusedOptionIndex(null);
|
|
427
439
|
}
|
|
428
440
|
}
|
|
429
441
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
@@ -444,15 +456,14 @@ function Select({
|
|
|
444
456
|
className: clsx.clsx(s('np-dropdown-toggle'), s('np-text-body-large'), inverse ? s('np-dropdown-toggle-navy') : null)
|
|
445
457
|
// reset Button's styles
|
|
446
458
|
,
|
|
447
|
-
type:
|
|
448
|
-
priority:
|
|
459
|
+
type: null,
|
|
460
|
+
priority: null,
|
|
449
461
|
disabled: disabled,
|
|
450
462
|
"aria-controls": listboxId,
|
|
451
463
|
"aria-expanded": open,
|
|
452
464
|
onClick: handleOnClick,
|
|
453
465
|
...buttonProps,
|
|
454
466
|
children: [selected ? /*#__PURE__*/jsxRuntime.jsx(Option, {
|
|
455
|
-
label: undefined,
|
|
456
467
|
...selected,
|
|
457
468
|
classNames: classNamesProp,
|
|
458
469
|
selected: true
|
|
@@ -489,6 +500,79 @@ function Select({
|
|
|
489
500
|
})]
|
|
490
501
|
});
|
|
491
502
|
}
|
|
503
|
+
Select.propTypes = {
|
|
504
|
+
placeholder: PropTypes__default.default.string,
|
|
505
|
+
id: PropTypes__default.default.string,
|
|
506
|
+
required: PropTypes__default.default.bool,
|
|
507
|
+
disabled: PropTypes__default.default.bool,
|
|
508
|
+
inverse: PropTypes__default.default.bool,
|
|
509
|
+
dropdownRight: PropTypes__default.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
|
|
510
|
+
dropdownWidth: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
511
|
+
size: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
512
|
+
block: PropTypes__default.default.bool,
|
|
513
|
+
selected: PropTypes__default.default.shape({
|
|
514
|
+
value: PropTypes__default.default.any.isRequired,
|
|
515
|
+
label: PropTypes__default.default.node,
|
|
516
|
+
icon: PropTypes__default.default.node,
|
|
517
|
+
currency: PropTypes__default.default.string,
|
|
518
|
+
note: PropTypes__default.default.node,
|
|
519
|
+
secondary: PropTypes__default.default.node
|
|
520
|
+
}),
|
|
521
|
+
/**
|
|
522
|
+
* Search toggle
|
|
523
|
+
* if `true` default search functionality being enabled (not case sensitive search in option labels & currency props)
|
|
524
|
+
* if `function` you can define your own search function to implement custom search experience. This search function used while filtering the options array. The custom search function takes two parameters. First is the option the second is the keyword.
|
|
525
|
+
*/
|
|
526
|
+
search: PropTypes__default.default.oneOfType([PropTypes__default.default.bool, PropTypes__default.default.func]),
|
|
527
|
+
options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
528
|
+
value: PropTypes__default.default.any,
|
|
529
|
+
label: PropTypes__default.default.node,
|
|
530
|
+
header: PropTypes__default.default.node,
|
|
531
|
+
icon: PropTypes__default.default.node,
|
|
532
|
+
currency: PropTypes__default.default.string,
|
|
533
|
+
note: PropTypes__default.default.node,
|
|
534
|
+
secondary: PropTypes__default.default.node,
|
|
535
|
+
separator: PropTypes__default.default.bool,
|
|
536
|
+
disabled: PropTypes__default.default.bool,
|
|
537
|
+
searchStrings: PropTypes__default.default.arrayOf(PropTypes__default.default.string)
|
|
538
|
+
})).isRequired,
|
|
539
|
+
searchValue: PropTypes__default.default.string,
|
|
540
|
+
searchPlaceholder: PropTypes__default.default.string,
|
|
541
|
+
classNames: PropTypes__default.default.objectOf(PropTypes__default.default.string),
|
|
542
|
+
dropdownUp: PropTypes__default.default.bool,
|
|
543
|
+
buttonProps: PropTypes__default.default.object,
|
|
544
|
+
dropdownProps: PropTypes__default.default.object,
|
|
545
|
+
onChange: PropTypes__default.default.func.isRequired,
|
|
546
|
+
onFocus: PropTypes__default.default.func,
|
|
547
|
+
onBlur: PropTypes__default.default.func,
|
|
548
|
+
/**
|
|
549
|
+
* To have full control of your search value and response use `onSearchChange` function combined with `searchValue` and custom filtering on the options array.
|
|
550
|
+
* DO NOT USE TOGETHER WITH `search` PROPERTY
|
|
551
|
+
*/
|
|
552
|
+
onSearchChange: PropTypes__default.default.func
|
|
553
|
+
};
|
|
554
|
+
Select.defaultProps = {
|
|
555
|
+
id: undefined,
|
|
556
|
+
placeholder: undefined,
|
|
557
|
+
size: 'md',
|
|
558
|
+
dropdownRight: null,
|
|
559
|
+
dropdownWidth: null,
|
|
560
|
+
inverse: false,
|
|
561
|
+
required: false,
|
|
562
|
+
disabled: false,
|
|
563
|
+
block: true,
|
|
564
|
+
selected: null,
|
|
565
|
+
onFocus: null,
|
|
566
|
+
onBlur: null,
|
|
567
|
+
onSearchChange: undefined,
|
|
568
|
+
search: false,
|
|
569
|
+
searchValue: '',
|
|
570
|
+
searchPlaceholder: undefined,
|
|
571
|
+
classNames: {},
|
|
572
|
+
dropdownUp: false,
|
|
573
|
+
buttonProps: {},
|
|
574
|
+
dropdownProps: {}
|
|
575
|
+
};
|
|
492
576
|
|
|
493
577
|
module.exports = Select;
|
|
494
578
|
//# sourceMappingURL=Select.js.map
|