@kaizen/components 1.35.1 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Button/GenericButton/GenericButton.cjs +1 -1
- package/dist/cjs/Button/GenericButton/GenericButton.cjs.map +1 -1
- package/dist/cjs/KaizenProvider/KaizenProvider.cjs +6 -1
- package/dist/cjs/KaizenProvider/KaizenProvider.cjs.map +1 -1
- package/dist/cjs/Modal/ContextModal/ContextModal.cjs +9 -6
- package/dist/cjs/Modal/ContextModal/ContextModal.cjs.map +1 -1
- package/dist/cjs/MultiSelect/subcomponents/Popover/Popover.cjs +1 -1
- package/dist/cjs/MultiSelect/subcomponents/Popover/Popover.cjs.map +1 -1
- package/dist/cjs/Notification/ToastNotification/ToastNotification/ToastNotification.cjs +33 -0
- package/dist/cjs/Notification/ToastNotification/ToastNotification/ToastNotification.cjs.map +1 -0
- package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.cjs +36 -0
- package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.cjs.map +1 -0
- package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.module.scss.cjs +7 -0
- package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.module.scss.cjs.map +1 -0
- package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.cjs +42 -0
- package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.cjs.map +1 -0
- package/dist/cjs/Notification/ToastNotification/context/ToastNotificationContext.cjs +72 -0
- package/dist/cjs/Notification/ToastNotification/context/ToastNotificationContext.cjs.map +1 -0
- package/dist/cjs/Notification/ToastNotification/hooks/useToastNotification.cjs +9 -0
- package/dist/cjs/Notification/ToastNotification/hooks/useToastNotification.cjs.map +1 -0
- package/dist/cjs/RichTextEditor/RichTextEditor/RichTextEditor.cjs +6 -2
- package/dist/cjs/RichTextEditor/RichTextEditor/RichTextEditor.cjs.map +1 -1
- package/dist/cjs/__future__/Select/Select.cjs +24 -2
- package/dist/cjs/__future__/Select/Select.cjs.map +1 -1
- package/dist/cjs/dts/Modal/ContextModal/ContextModal.d.ts +2 -1
- package/dist/cjs/dts/MultiSelect/MultiSelect.d.ts +4 -2
- package/dist/cjs/dts/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.d.ts +3 -0
- package/dist/cjs/dts/MultiSelect/types.d.ts +6 -0
- package/dist/cjs/dts/Notification/ToastNotification/ToastNotification/ToastNotification.d.ts +16 -0
- package/dist/cjs/dts/Notification/ToastNotification/ToastNotification/index.d.ts +1 -0
- package/dist/cjs/dts/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.d.ts +4 -0
- package/dist/cjs/dts/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.d.ts +12 -0
- package/dist/cjs/dts/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/index.d.ts +1 -0
- package/dist/cjs/dts/Notification/ToastNotification/context/ToastNotificationContext.d.ts +21 -0
- package/dist/cjs/dts/Notification/ToastNotification/hooks/useToastNotification.d.ts +2 -0
- package/dist/cjs/dts/Notification/ToastNotification/index.d.ts +3 -2
- package/dist/cjs/dts/Notification/ToastNotification/types.d.ts +1 -9
- package/dist/cjs/dts/Notification/index.d.ts +1 -0
- package/dist/cjs/dts/RichTextEditor/RichTextEditor/RichTextEditor.d.ts +1 -1
- package/dist/cjs/dts/__future__/Select/Select.d.ts +5 -1
- package/dist/cjs/index.cjs +6 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.css +4 -3
- package/dist/esm/Button/GenericButton/GenericButton.mjs +1 -1
- package/dist/esm/Button/GenericButton/GenericButton.mjs.map +1 -1
- package/dist/esm/KaizenProvider/KaizenProvider.mjs +6 -1
- package/dist/esm/KaizenProvider/KaizenProvider.mjs.map +1 -1
- package/dist/esm/Modal/ContextModal/ContextModal.mjs +9 -6
- package/dist/esm/Modal/ContextModal/ContextModal.mjs.map +1 -1
- package/dist/esm/MultiSelect/subcomponents/Popover/Popover.mjs +1 -1
- package/dist/esm/MultiSelect/subcomponents/Popover/Popover.mjs.map +1 -1
- package/dist/esm/Notification/ToastNotification/ToastNotification/ToastNotification.mjs +31 -0
- package/dist/esm/Notification/ToastNotification/ToastNotification/ToastNotification.mjs.map +1 -0
- package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.mjs +34 -0
- package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.mjs.map +1 -0
- package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.module.scss.mjs +5 -0
- package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.module.scss.mjs.map +1 -0
- package/dist/esm/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.mjs +40 -0
- package/dist/esm/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.mjs.map +1 -0
- package/dist/esm/Notification/ToastNotification/context/ToastNotificationContext.mjs +69 -0
- package/dist/esm/Notification/ToastNotification/context/ToastNotificationContext.mjs.map +1 -0
- package/dist/esm/Notification/ToastNotification/hooks/useToastNotification.mjs +7 -0
- package/dist/esm/Notification/ToastNotification/hooks/useToastNotification.mjs.map +1 -0
- package/dist/esm/RichTextEditor/RichTextEditor/RichTextEditor.mjs +6 -2
- package/dist/esm/RichTextEditor/RichTextEditor/RichTextEditor.mjs.map +1 -1
- package/dist/esm/__future__/Select/Select.mjs +25 -3
- package/dist/esm/__future__/Select/Select.mjs.map +1 -1
- package/dist/esm/dts/Modal/ContextModal/ContextModal.d.ts +2 -1
- package/dist/esm/dts/MultiSelect/MultiSelect.d.ts +4 -2
- package/dist/esm/dts/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.d.ts +3 -0
- package/dist/esm/dts/MultiSelect/types.d.ts +6 -0
- package/dist/esm/dts/Notification/ToastNotification/ToastNotification/ToastNotification.d.ts +16 -0
- package/dist/esm/dts/Notification/ToastNotification/ToastNotification/index.d.ts +1 -0
- package/dist/esm/dts/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.d.ts +4 -0
- package/dist/esm/dts/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.d.ts +12 -0
- package/dist/esm/dts/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/index.d.ts +1 -0
- package/dist/esm/dts/Notification/ToastNotification/context/ToastNotificationContext.d.ts +21 -0
- package/dist/esm/dts/Notification/ToastNotification/hooks/useToastNotification.d.ts +2 -0
- package/dist/esm/dts/Notification/ToastNotification/index.d.ts +3 -2
- package/dist/esm/dts/Notification/ToastNotification/types.d.ts +1 -9
- package/dist/esm/dts/Notification/index.d.ts +1 -0
- package/dist/esm/dts/RichTextEditor/RichTextEditor/RichTextEditor.d.ts +1 -1
- package/dist/esm/dts/__future__/Select/Select.d.ts +5 -1
- package/dist/esm/index.css +5 -4
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/index.d.ts +50 -3
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/src/Button/Button/_docs/Button.mdx +5 -0
- package/src/Button/Button/_docs/Button.stories.tsx +27 -1
- package/src/Button/GenericButton/GenericButton.spec.tsx +69 -0
- package/src/Button/GenericButton/GenericButton.tsx +1 -1
- package/src/DatePicker/DatePicker.spec.tsx +1 -1
- package/src/KaizenProvider/KaizenProvider.tsx +6 -1
- package/src/Modal/ContextModal/ContextModal.spec.tsx +3 -3
- package/src/Modal/ContextModal/ContextModal.tsx +9 -5
- package/src/MultiSelect/MultiSelect.spec.tsx +56 -1
- package/src/MultiSelect/MultiSelect.tsx +10 -3
- package/src/MultiSelect/_docs/MultiSelect.mdx +10 -0
- package/src/MultiSelect/_docs/MultiSelect.stickersheet.stories.tsx +81 -43
- package/src/MultiSelect/_docs/MultiSelect.stories.tsx +21 -0
- package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.module.scss +9 -0
- package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.tsx +8 -1
- package/src/MultiSelect/subcomponents/MultiSelectToggle/_docs/MultiSelectToggle.stickersheet.stories.tsx +17 -0
- package/src/MultiSelect/subcomponents/Popover/Popover.tsx +1 -1
- package/src/MultiSelect/types.ts +7 -0
- package/src/Notification/ToastNotification/ToastNotification/ToastNotification.spec.tsx +33 -0
- package/src/Notification/ToastNotification/ToastNotification/ToastNotification.tsx +48 -0
- package/src/Notification/ToastNotification/ToastNotification/index.ts +1 -0
- package/src/Notification/ToastNotification/{subcomponents/ToastNotificationsList → ToastNotificationsList}/ToastNotificationsList.module.scss +1 -1
- package/src/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.tsx +40 -0
- package/src/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.tsx +49 -0
- package/src/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/index.ts +1 -0
- package/src/Notification/ToastNotification/_docs/ToastNotification.mdx +19 -14
- package/src/Notification/ToastNotification/_docs/ToastNotification.stickersheet.stories.tsx +33 -70
- package/src/Notification/ToastNotification/_docs/ToastNotification.stories.tsx +123 -93
- package/src/Notification/ToastNotification/context/ToastNotificationContext.tsx +96 -0
- package/src/Notification/ToastNotification/hooks/useToastNotification.ts +9 -0
- package/src/Notification/ToastNotification/index.ts +3 -2
- package/src/Notification/ToastNotification/types.ts +1 -18
- package/src/Notification/index.ts +1 -0
- package/src/RichTextEditor/RichTextEditor/RichTextEditor.tsx +6 -1
- package/src/RichTextEditor/utils/commands/addMark.spec.ts +0 -1
- package/src/Tooltip/Tooltip.spec.tsx +6 -1
- package/src/__future__/Select/Select.spec.tsx +109 -14
- package/src/__future__/Select/Select.tsx +32 -3
- package/src/__future__/Select/_docs/Select.mdx +8 -0
- package/src/__future__/Select/_docs/Select.stories.tsx +29 -0
- package/dist/cjs/dts/Notification/ToastNotification/ToastNotification.d.ts +0 -14
- package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationManager/ToastNotificationManager.d.ts +0 -7
- package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationManager/index.d.ts +0 -1
- package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationsList/ToastNotificationsList.d.ts +0 -11
- package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/ToastNotificationsListContainer.d.ts +0 -7
- package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/index.d.ts +0 -1
- package/dist/esm/dts/Notification/ToastNotification/ToastNotification.d.ts +0 -14
- package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationManager/ToastNotificationManager.d.ts +0 -7
- package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationManager/index.d.ts +0 -1
- package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationsList/ToastNotificationsList.d.ts +0 -11
- package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/ToastNotificationsListContainer.d.ts +0 -7
- package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/index.d.ts +0 -1
- package/src/Notification/ToastNotification/ToastNotification.spec.tsx +0 -31
- package/src/Notification/ToastNotification/ToastNotification.tsx +0 -43
- package/src/Notification/ToastNotification/subcomponents/ToastNotificationManager/ToastNotificationManager.spec.tsx +0 -144
- package/src/Notification/ToastNotification/subcomponents/ToastNotificationManager/ToastNotificationManager.tsx +0 -135
- package/src/Notification/ToastNotification/subcomponents/ToastNotificationManager/index.ts +0 -1
- package/src/Notification/ToastNotification/subcomponents/ToastNotificationsList/ToastNotificationsList.tsx +0 -40
- package/src/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/ToastNotificationsListContainer.spec.tsx +0 -73
- package/src/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/ToastNotificationsListContainer.tsx +0 -31
- package/src/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/index.ts +0 -1
- /package/dist/cjs/dts/Notification/ToastNotification/{subcomponents/ToastNotificationsList → ToastNotificationsList}/index.d.ts +0 -0
- /package/dist/esm/dts/Notification/ToastNotification/{subcomponents/ToastNotificationsList → ToastNotificationsList}/index.d.ts +0 -0
- /package/src/Notification/ToastNotification/{subcomponents/ToastNotificationsList → ToastNotificationsList}/index.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.cjs","sources":["../../../../src/RichTextEditor/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["import React, {\n useState,\n useEffect,\n HTMLAttributes,\n ReactNode,\n useId,\n} from \"react\"\nimport classnames from \"classnames\"\nimport { FieldMessage } from \"~components/FieldMessage\"\nimport { Label } from \"~components/Label\"\nimport { InlineNotification } from \"~components/Notification\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { ToolbarItems, EditorContentArray, EditorRows } from \"../types\"\nimport { useRichTextEditor } from \"../utils/core\"\nimport { createLinkManager } from \"../utils/plugins\"\nimport {\n ProseMirrorCommands,\n ProseMirrorHistory,\n ProseMirrorKeymap,\n ProseMirrorModel,\n ProseMirrorState,\n} from \"../utils/prosemirror\"\nimport { createSchemaFromControls } from \"./schema\"\nimport { ToggleIconButton } from \"./subcomponents/ToggleIconButton\"\nimport { Toolbar } from \"./subcomponents/Toolbar\"\nimport { ToolbarSection } from \"./subcomponents/ToolbarSection\"\nimport { buildControlMap } from \"./utils/controlmap\"\nimport { buildInputRules } from \"./utils/inputrules\"\nimport { buildKeymap } from \"./utils/keymap\"\nimport styles from \"./RichTextEditor.module.scss\"\n\ntype BaseRichTextEditorProps = {\n onChange: (content: ProseMirrorState.EditorState) => void\n defaultValue: EditorContentArray\n controls?: ToolbarItems[]\n /**\n * Sets a default min-height for the editable area in units of body paragraph line height, similar to the 'rows' attribute on <textarea>.\n * The editable area will autogrow, so this only affects the component when the content doesn't exceed this height.\n */\n rows?: EditorRows\n dataError?: React.ReactElement\n onDataError?: () => void\n status?: \"default\" | \"error\" | \"caution\"\n /**\n * A descriptive message for `error` or `caution` states\n */\n validationMessage?: React.ReactNode\n /**\n * A description that provides context\n */\n description?: React.ReactNode\n} & OverrideClassName<\n Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\">\n>\n\ntype WithLabelText = {\n labelText: ReactNode\n \"aria-labelledby\"?: never\n}\n\ntype WithLabelledBy = {\n labelText?: never\n \"aria-labelledby\": string\n}\n\nexport type RichTextEditorProps = BaseRichTextEditorProps &\n (WithLabelText | WithLabelledBy)\n/**\n * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896752/Rich+Text+Editor Guidance} |\n * {@link https://cultureamp.design/?path=/docs/components-richtexteditor--docs Storybook}\n */\nexport const RichTextEditor = ({\n onChange,\n defaultValue,\n labelText,\n \"aria-labelledby\": labelledBy,\n classNameOverride,\n controls,\n rows = 3,\n dataError,\n onDataError,\n validationMessage,\n description,\n status = \"default\",\n ...restProps\n}: RichTextEditorProps): JSX.Element => {\n const reactId = useId()\n const [schema] = useState<ProseMirrorModel.Schema>(\n createSchemaFromControls(controls)\n )\n const [labelId] = useState<string>(labelledBy || reactId)\n const [editorId] = useState<string>(reactId)\n\n const useRichTextEditorResult = (():\n | ReturnType<typeof useRichTextEditor>\n | Error => {\n try {\n return useRichTextEditor(\n ProseMirrorState.EditorState.create({\n doc: ProseMirrorModel.Node.fromJSON(schema, {\n type: \"doc\",\n // we're converting empty arrays to the ProseMirror default \"empty\" state because when\n // given an empty array ProseMirror returns undefined, breaking the type\n content:\n defaultValue?.length > 0 ? defaultValue : [{ type: \"paragraph\" }],\n }),\n schema,\n plugins: getPlugins(controls, schema),\n }),\n { \"aria-labelledby\": labelId, role: \"textbox\" }\n )\n } catch {\n return new Error(\"Bad data error\")\n }\n })()\n\n if (useRichTextEditorResult instanceof Error) {\n onDataError && onDataError()\n return (\n <InlineNotification\n headingProps={{\n children: \"Error\",\n variant: \"heading-6\",\n }}\n type=\"negative\"\n persistent\n >\n {dataError || \"Something went wrong\"}\n </InlineNotification>\n )\n }\n\n const [editorRef, editorState, dispatchTransaction] = useRichTextEditorResult\n\n const controlMap = buildControlMap(schema, editorState, controls)\n\n useEffect(() => {\n onChange(editorState)\n // Including `onContentChange` in the dependencies here will cause a 'Maximum update depth exceeded' issue\n }, [editorState])\n\n const validationMessageAria = validationMessage\n ? `${editorId}-rte-validation-message`\n : \"\"\n const descriptionAria = description ? `${editorId}-rte-description` : \"\"\n\n const ariaDescribedBy = `${validationMessageAria} ${descriptionAria}`\n\n return (\n <>\n {!labelledBy && labelText && <Label id={labelId} labelText={labelText} />}\n {/* TODO: add a bit of margin here once we have a classNameOverride on Label */}\n <div className={classnames(styles.editorWrapper, styles[status])}>\n {controls && (\n <Toolbar\n aria-controls={editorId}\n aria-label=\"Text formatting\"\n classNameOverride={styles.toolbar}\n >\n {controlMap.map((section, index) => (\n <ToolbarSection key={index}>\n {section.map((controlConfig, controlKeyIndex) => (\n <ToggleIconButton\n key={controlKeyIndex}\n icon={controlConfig.icon}\n disabled={controlConfig.disabled}\n label={controlConfig.label}\n isActive={controlConfig.isActive}\n onClick={(): void =>\n dispatchTransaction(controlConfig.action)\n }\n />\n ))}\n </ToolbarSection>\n ))}\n </Toolbar>\n )}\n <div\n id={editorId}\n ref={editorRef}\n className={classnames(\n styles.editor,\n styles[`rows${rows}`],\n classNameOverride,\n controls != null && controls.length > 0 && styles.hasToolbar\n )}\n aria-describedby={ariaDescribedBy}\n {...restProps}\n />\n </div>\n\n {validationMessage && (\n <FieldMessage\n id={validationMessageAria}\n message={validationMessage}\n status={status}\n />\n )}\n\n {description && (\n <FieldMessage id={descriptionAria} message={description} />\n )}\n </>\n )\n}\n\nRichTextEditor.displayName = \"RichTextEditor\"\n\nfunction getPlugins(\n controls: ToolbarItems[] | undefined,\n schema: ProseMirrorModel.Schema\n): Array<\n | ProseMirrorState.Plugin<unknown>\n | ProseMirrorState.Plugin<{\n transform: ProseMirrorState.Transaction\n from: number\n to: number\n text: string\n } | null>\n> {\n const allControlNames: string[] = controls\n ? controls.reduce((acc: string[], c: ToolbarItems) => [...acc, c.name], [])\n : []\n const plugins = [\n ProseMirrorHistory.history(),\n ProseMirrorKeymap.keymap(buildKeymap(schema)),\n ProseMirrorKeymap.keymap(ProseMirrorCommands.baseKeymap),\n buildInputRules(schema),\n ]\n\n if (allControlNames.includes(\"link\")) {\n plugins.push(\n createLinkManager({\n markType: schema.marks.link,\n })\n )\n }\n\n return plugins\n}\n"],"names":["RichTextEditor","_a","onChange","defaultValue","labelText","labelledBy","classNameOverride","controls","_b","rows","dataError","onDataError","validationMessage","description","_c","status","restProps","__rest","reactId","useId","schema","useState","createSchemaFromControls","labelId","editorId","useRichTextEditorResult","useRichTextEditor","ProseMirrorState","EditorState","create","doc","ProseMirrorModel","Node","fromJSON","type","content","length","plugins","getPlugins","role","Error","React","createElement","InlineNotification","headingProps","children","variant","persistent","editorRef","editorState","dispatchTransaction","controlMap","buildControlMap","useEffect","validationMessageAria","concat","descriptionAria","ariaDescribedBy","Fragment","Label","id","className","classnames","styles","editorWrapper","Toolbar","toolbar","map","section","index","ToolbarSection","key","controlConfig","controlKeyIndex","ToggleIconButton","icon","disabled","label","isActive","onClick","action","__assign","ref","editor","hasToolbar","FieldMessage","message","displayName","allControlNames","reduce","acc","c","name","ProseMirrorHistory","history","ProseMirrorKeymap","keymap","buildKeymap","ProseMirrorCommands","baseKeymap","buildInputRules","includes","push","createLinkManager","markType","marks","link"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;;;AAGG;AAHH,MAIaA,cAAc;EAAA,MAAdA,cAAc,GAAG,SAAAA,CAACC,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C,GACzE,EAAE;EACN,IAAMvD,OAAO,GAAG,CACdwD,6BAAkB,CAACC,OAAO,CAAE,CAAA,EAC5BC,4BAAiB,CAACC,MAAM,CAACC,kBAAW,CAAC7E,MAAM,CAAC,CAAC,EAC7C2E,4BAAiB,CAACC,MAAM,CAACE,8BAAmB,CAACC,UAAU,CAAC,EACxDC,UAAAA,CAAAA,eAAe,CAAChF,MAAM,CAAC,CACxB;EAED,IAAIoE,eAAe,CAACa,QAAQ,CAAC,MAAM,CAAC,EAAE;IACpChE,OAAO,CAACiE,IAAI,CACVC,6BAAiB,CAAC;MAChBC,QAAQ,EAAEpF,MAAM,CAACqF,KAAK,CAACC;IACxB,CAAA,CAAC,CACH;EACF;EAED,OAAOrE,OAAO;AAChB;"}
|
|
1
|
+
{"version":3,"file":"RichTextEditor.cjs","sources":["../../../../src/RichTextEditor/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["import React, {\n useState,\n useEffect,\n HTMLAttributes,\n ReactNode,\n useId,\n} from \"react\"\nimport classnames from \"classnames\"\nimport { FieldMessage } from \"~components/FieldMessage\"\nimport { Label } from \"~components/Label\"\nimport { InlineNotification } from \"~components/Notification\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { ToolbarItems, EditorContentArray, EditorRows } from \"../types\"\nimport { useRichTextEditor } from \"../utils/core\"\nimport { createLinkManager } from \"../utils/plugins\"\nimport {\n ProseMirrorCommands,\n ProseMirrorHistory,\n ProseMirrorKeymap,\n ProseMirrorModel,\n ProseMirrorState,\n} from \"../utils/prosemirror\"\nimport { createSchemaFromControls } from \"./schema\"\nimport { ToggleIconButton } from \"./subcomponents/ToggleIconButton\"\nimport { Toolbar } from \"./subcomponents/Toolbar\"\nimport { ToolbarSection } from \"./subcomponents/ToolbarSection\"\nimport { buildControlMap } from \"./utils/controlmap\"\nimport { buildInputRules } from \"./utils/inputrules\"\nimport { buildKeymap } from \"./utils/keymap\"\nimport styles from \"./RichTextEditor.module.scss\"\n\ntype BaseRichTextEditorProps = {\n onChange: (content: ProseMirrorState.EditorState) => void\n defaultValue: EditorContentArray\n controls?: ToolbarItems[]\n /**\n * Sets a default min-height for the editable area in units of body paragraph line height, similar to the 'rows' attribute on <textarea>.\n * The editable area will autogrow, so this only affects the component when the content doesn't exceed this height.\n */\n rows?: EditorRows\n dataError?: React.ReactElement\n onDataError?: () => void\n status?: \"default\" | \"error\" | \"caution\"\n /**\n * A descriptive message for `error` or `caution` states\n */\n validationMessage?: React.ReactNode\n /**\n * A description that provides context\n */\n description?: React.ReactNode\n} & OverrideClassName<\n Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\">\n>\n\ntype WithLabelText = {\n labelText: ReactNode\n \"aria-labelledby\"?: never\n}\n\ntype WithLabelledBy = {\n labelText?: never\n \"aria-labelledby\": string\n}\n\nexport type RichTextEditorProps = BaseRichTextEditorProps &\n (WithLabelText | WithLabelledBy)\n/**\n * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896752/Rich+Text+Editor Guidance} |\n * {@link https://cultureamp.design/?path=/docs/components-richtexteditor--docs Storybook}\n */\nexport const RichTextEditor = ({\n onChange,\n defaultValue,\n labelText,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n classNameOverride,\n controls,\n rows = 3,\n dataError,\n onDataError,\n validationMessage,\n description,\n status = \"default\",\n ...restProps\n}: RichTextEditorProps): JSX.Element => {\n const reactId = useId()\n const [schema] = useState<ProseMirrorModel.Schema>(\n createSchemaFromControls(controls)\n )\n const [labelId] = useState<string>(labelledBy || reactId)\n const [editorId] = useState<string>(reactId)\n\n const useRichTextEditorResult = (():\n | ReturnType<typeof useRichTextEditor>\n | Error => {\n try {\n return useRichTextEditor(\n ProseMirrorState.EditorState.create({\n doc: ProseMirrorModel.Node.fromJSON(schema, {\n type: \"doc\",\n // we're converting empty arrays to the ProseMirror default \"empty\" state because when\n // given an empty array ProseMirror returns undefined, breaking the type\n content:\n defaultValue?.length > 0 ? defaultValue : [{ type: \"paragraph\" }],\n }),\n schema,\n plugins: getPlugins(controls, schema),\n }),\n { \"aria-labelledby\": labelId, role: \"textbox\" }\n )\n } catch {\n return new Error(\"Bad data error\")\n }\n })()\n\n if (useRichTextEditorResult instanceof Error) {\n onDataError && onDataError()\n return (\n <InlineNotification\n headingProps={{\n children: \"Error\",\n variant: \"heading-6\",\n }}\n type=\"negative\"\n persistent\n >\n {dataError || \"Something went wrong\"}\n </InlineNotification>\n )\n }\n\n const [editorRef, editorState, dispatchTransaction] = useRichTextEditorResult\n\n const controlMap = buildControlMap(schema, editorState, controls)\n\n useEffect(() => {\n onChange(editorState)\n // Including `onContentChange` in the dependencies here will cause a 'Maximum update depth exceeded' issue\n }, [editorState])\n\n const validationMessageAria = validationMessage\n ? `${editorId}-rte-validation-message`\n : \"\"\n const descriptionAria = description ? `${editorId}-rte-description` : \"\"\n\n const ariaDescribedBy = classnames(\n validationMessageAria,\n descriptionAria,\n describedBy\n )\n\n return (\n <>\n {!labelledBy && labelText && <Label id={labelId} labelText={labelText} />}\n {/* TODO: add a bit of margin here once we have a classNameOverride on Label */}\n <div className={classnames(styles.editorWrapper, styles[status])}>\n {controls && (\n <Toolbar\n aria-controls={editorId}\n aria-label=\"Text formatting\"\n classNameOverride={styles.toolbar}\n >\n {controlMap.map((section, index) => (\n <ToolbarSection key={index}>\n {section.map((controlConfig, controlKeyIndex) => (\n <ToggleIconButton\n key={controlKeyIndex}\n icon={controlConfig.icon}\n disabled={controlConfig.disabled}\n label={controlConfig.label}\n isActive={controlConfig.isActive}\n onClick={(): void =>\n dispatchTransaction(controlConfig.action)\n }\n />\n ))}\n </ToolbarSection>\n ))}\n </Toolbar>\n )}\n <div\n id={editorId}\n ref={editorRef}\n className={classnames(\n styles.editor,\n styles[`rows${rows}`],\n classNameOverride,\n controls != null && controls.length > 0 && styles.hasToolbar\n )}\n aria-describedby={ariaDescribedBy}\n {...restProps}\n />\n </div>\n\n {validationMessage && (\n <FieldMessage\n id={validationMessageAria}\n message={validationMessage}\n status={status}\n />\n )}\n\n {description && (\n <FieldMessage id={descriptionAria} message={description} />\n )}\n </>\n )\n}\n\nRichTextEditor.displayName = \"RichTextEditor\"\n\nfunction getPlugins(\n controls: ToolbarItems[] | undefined,\n schema: ProseMirrorModel.Schema\n): Array<\n | ProseMirrorState.Plugin<unknown>\n | ProseMirrorState.Plugin<{\n transform: ProseMirrorState.Transaction\n from: number\n to: number\n text: string\n } | null>\n> {\n const allControlNames: string[] = controls\n ? controls.reduce((acc: string[], c: ToolbarItems) => [...acc, c.name], [])\n : []\n const plugins = [\n ProseMirrorHistory.history(),\n ProseMirrorKeymap.keymap(buildKeymap(schema)),\n ProseMirrorKeymap.keymap(ProseMirrorCommands.baseKeymap),\n buildInputRules(schema),\n ]\n\n if (allControlNames.includes(\"link\")) {\n plugins.push(\n createLinkManager({\n markType: schema.marks.link,\n })\n )\n }\n\n return plugins\n}\n"],"names":["RichTextEditor","_a","onChange","defaultValue","labelText","labelledBy","describedBy","classNameOverride","controls","_b","rows","dataError","onDataError","validationMessage","description","_c","status","restProps","__rest","reactId","useId","schema","useState","createSchemaFromControls","labelId","editorId","useRichTextEditorResult","useRichTextEditor","ProseMirrorState","EditorState","create","doc","ProseMirrorModel","Node","fromJSON","type","content","length","plugins","getPlugins","role","Error","React","createElement","InlineNotification","headingProps","children","variant","persistent","editorRef","editorState","dispatchTransaction","controlMap","buildControlMap","useEffect","validationMessageAria","concat","descriptionAria","ariaDescribedBy","classnames","Fragment","Label","id","className","styles","editorWrapper","Toolbar","toolbar","map","section","index","ToolbarSection","key","controlConfig","controlKeyIndex","ToggleIconButton","icon","disabled","label","isActive","onClick","action","__assign","ref","editor","hasToolbar","FieldMessage","message","displayName","allControlNames","reduce","acc","c","name","ProseMirrorHistory","history","ProseMirrorKeymap","keymap","buildKeymap","ProseMirrorCommands","baseKeymap","buildInputRules","includes","push","createLinkManager","markType","marks","link"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,SAASuC,UAAUA,CACjB/B,QAAoC,EACpCa,MAA+B,EAAA;EAU/B,IAAMoE,eAAe,GAAajF,QAAQ,GACtCA,QAAQ,CAACkF,MAAM,CAAC,UAACC,GAAa,EAAEC,CAAe,EAAA;IAAK,mDAAID,GAAG,EAAA,IAAA,CAAA,EAAA,CAAEC,CAAC,CAACC,IAAI;EAAC,CAAA,EAAE,EAAE,CAAC,GACzE,EAAE;EACN,IAAMvD,OAAO,GAAG,CACdwD,6BAAkB,CAACC,OAAO,CAAE,CAAA,EAC5BC,4BAAiB,CAACC,MAAM,CAACC,kBAAW,CAAC7E,MAAM,CAAC,CAAC,EAC7C2E,4BAAiB,CAACC,MAAM,CAACE,8BAAmB,CAACC,UAAU,CAAC,EACxDC,UAAAA,CAAAA,eAAe,CAAChF,MAAM,CAAC,CACxB;EAED,IAAIoE,eAAe,CAACa,QAAQ,CAAC,MAAM,CAAC,EAAE;IACpChE,OAAO,CAACiE,IAAI,CACVC,6BAAiB,CAAC;MAChBC,QAAQ,EAAEpF,MAAM,CAACqF,KAAK,CAACC;IACxB,CAAA,CAAC,CACH;EACF;EAED,OAAOrE,OAAO;AAChB;"}
|
|
@@ -45,11 +45,13 @@ const Select = /*#__PURE__*/function () {
|
|
|
45
45
|
description = _a.description,
|
|
46
46
|
placeholder = _a.placeholder,
|
|
47
47
|
isDisabled = _a.isDisabled,
|
|
48
|
-
|
|
48
|
+
portalContainerId = _a.portalContainerId,
|
|
49
|
+
restProps = tslib.__rest(_a, ["label", "items", "id", "trigger", "children", "status", "validationMessage", "isReversed", "isFullWidth", "disabledValues", "classNameOverride", "selectedKey", "description", "placeholder", "isDisabled", "portalContainerId"]);
|
|
49
50
|
var refs = reactDom.useFloating().refs;
|
|
50
51
|
var triggerRef = refs.reference;
|
|
51
52
|
var id = propsId !== null && propsId !== void 0 ? propsId : React.useId();
|
|
52
53
|
var descriptionId = "".concat(id, "--description");
|
|
54
|
+
var popoverId = "".concat(id, "--popover");
|
|
53
55
|
var disabledKeys = getDisabledKeysFromItems.getDisabledKeysFromItems(items);
|
|
54
56
|
var ariaSelectProps = tslib.__assign({
|
|
55
57
|
label: label,
|
|
@@ -64,11 +66,20 @@ const Select = /*#__PURE__*/function () {
|
|
|
64
66
|
var state = select.useSelectState(ariaSelectProps);
|
|
65
67
|
var _c = select$1.useSelect(ariaSelectProps, state, triggerRef),
|
|
66
68
|
labelProps = _c.labelProps,
|
|
67
|
-
|
|
69
|
+
reactAriaTriggerProps = _c.triggerProps,
|
|
68
70
|
valueProps = _c.valueProps,
|
|
69
71
|
menuProps = _c.menuProps,
|
|
70
72
|
errorMessageProps = _c.errorMessageProps,
|
|
71
73
|
descriptionProps = _c.descriptionProps;
|
|
74
|
+
// Hack incoming:
|
|
75
|
+
// react-aria/useSelect wants to prefix the combobox's accessible name with the value of the select.
|
|
76
|
+
// We use role=combobox, meaning screen readers will read the value.
|
|
77
|
+
// So we're modifying the `aria-labelledby` property to remove the value element id.
|
|
78
|
+
// Issue: https://github.com/adobe/react-spectrum/issues/4091
|
|
79
|
+
var reactAriaLabelledBy = reactAriaTriggerProps["aria-labelledby"];
|
|
80
|
+
var triggerProps = tslib.__assign(tslib.__assign({}, reactAriaTriggerProps), {
|
|
81
|
+
"aria-labelledby": reactAriaLabelledBy === null || reactAriaLabelledBy === void 0 ? void 0 : reactAriaLabelledBy.substring(reactAriaLabelledBy.indexOf(" ") + 1)
|
|
82
|
+
});
|
|
72
83
|
var buttonProps = button.useButton(triggerProps, triggerRef).buttonProps;
|
|
73
84
|
var selectToggleProps = tslib.__assign(tslib.__assign({}, buttonProps), {
|
|
74
85
|
label: label,
|
|
@@ -82,6 +93,15 @@ const Select = /*#__PURE__*/function () {
|
|
|
82
93
|
isReversed: isReversed,
|
|
83
94
|
ref: refs.setReference
|
|
84
95
|
});
|
|
96
|
+
var _d = React.useState(),
|
|
97
|
+
portalContainer = _d[0],
|
|
98
|
+
setPortalContainer = _d[1];
|
|
99
|
+
React.useEffect(function () {
|
|
100
|
+
if (portalContainerId) {
|
|
101
|
+
var portalElement = document.getElementById(portalContainerId);
|
|
102
|
+
portalElement && setPortalContainer(portalElement);
|
|
103
|
+
}
|
|
104
|
+
}, []);
|
|
85
105
|
return React.createElement("div", {
|
|
86
106
|
className: classnames(!isFullWidth && Select_module.notFullWidth, classNameOverride)
|
|
87
107
|
}, React.createElement(select$1.HiddenSelect, {
|
|
@@ -92,6 +112,8 @@ const Select = /*#__PURE__*/function () {
|
|
|
92
112
|
}), React.createElement("div", {
|
|
93
113
|
className: Select_module.container
|
|
94
114
|
}, trigger === undefined ? React.createElement(SelectToggle.SelectToggle, tslib.__assign({}, selectToggleProps)) : trigger(selectToggleProps, selectToggleProps.ref), state.isOpen && React.createElement(Popover.Popover, {
|
|
115
|
+
id: popoverId,
|
|
116
|
+
portalContainer: portalContainer,
|
|
95
117
|
refs: refs,
|
|
96
118
|
focusOnProps: {
|
|
97
119
|
onEscapeKey: state.close,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.cjs","sources":["../../../../src/__future__/Select/Select.tsx"],"sourcesContent":["import React, { useId } from \"react\"\nimport { UseFloatingReturn } from \"@floating-ui/react-dom\"\nimport { useButton } from \"@react-aria/button\"\nimport { HiddenSelect, useSelect } from \"@react-aria/select\"\nimport {\n useSelectState,\n SelectProps as AriaSelectProps,\n} from \"@react-stately/select\"\nimport { Key } from \"@react-types/shared\"\nimport classnames from \"classnames\"\nimport { FieldMessage } from \"~components/FieldMessage\"\nimport {\n Popover,\n useFloating,\n} from \"~components/MultiSelect/subcomponents/Popover\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { SelectProvider } from \"./context\"\nimport {\n ListBox,\n ListBoxSection,\n ListItem,\n Option,\n SectionDivider,\n SelectPopoverContents,\n SelectPopoverContentsProps,\n SelectToggle,\n SelectToggleProps,\n} from \"./subcomponents\"\nimport { SelectItem, SelectOption } from \"./types\"\nimport { getDisabledKeysFromItems } from \"./utils/getDisabledKeysFromItems\"\nimport { transformSelectItemToCollectionElement } from \"./utils/transformSelectItemToCollectionElement\"\nimport styles from \"./Select.module.scss\"\n\ntype OmittedAriaSelectProps = \"children\" | \"items\"\n\nexport type SelectProps<Option extends SelectOption = SelectOption> = {\n /**\n * Item objects in the collection.\n */\n items: Array<SelectItem<Option>>\n id?: string\n trigger?: (\n selectToggleProps: SelectToggleProps & {\n ref: UseFloatingReturn<HTMLButtonElement>[\"refs\"][\"setReference\"]\n },\n // @deprecated: This arg is unnecessary now, but provided for legacy usages\n ref: UseFloatingReturn<HTMLButtonElement>[\"refs\"][\"setReference\"]\n ) => JSX.Element\n children?: SelectPopoverContentsProps<Option>[\"children\"]\n /**\n * Updates the styling of the validation FieldMessage.\n */\n status?: \"error\" | \"caution\"\n /**\n * A descriptive message for the 'status' states.\n */\n validationMessage?: React.ReactNode | undefined\n /**\n * Use the `reversed` styles.\n */\n isReversed?: boolean\n /**\n * Use the `fullWidth` styles.\n */\n isFullWidth?: boolean\n /**\n * @deprecated: Either define `disabled` in your `Option` (in `items`), or use `disabledKeys`\n */\n disabledValues?: Key[]\n} & OverrideClassName<Omit<AriaSelectProps<Option>, OmittedAriaSelectProps>>\n\n/**\n * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896474/Select Guidance} |\n * {@link https://cultureamp.design/?path=/docs/components-select--docs Storybook}\n */\nexport const Select = <Option extends SelectOption = SelectOption>({\n label,\n items,\n id: propsId,\n trigger,\n children,\n status,\n validationMessage,\n isReversed,\n isFullWidth,\n disabledValues,\n classNameOverride,\n selectedKey,\n description,\n placeholder,\n isDisabled,\n ...restProps\n}: SelectProps<Option>): JSX.Element => {\n const { refs } = useFloating<HTMLButtonElement>()\n const triggerRef = refs.reference\n\n const id = propsId ?? useId()\n const descriptionId = `${id}--description`\n\n const disabledKeys = getDisabledKeysFromItems(items)\n\n const ariaSelectProps: AriaSelectProps<SelectItem<Option>> = {\n label,\n items,\n children: transformSelectItemToCollectionElement,\n disabledKeys: disabledValues ?? disabledKeys,\n selectedKey:\n typeof selectedKey === \"number\" ? selectedKey.toString() : selectedKey,\n description,\n placeholder,\n isDisabled,\n ...restProps,\n }\n\n const state = useSelectState(ariaSelectProps)\n\n const {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n errorMessageProps,\n descriptionProps,\n } = useSelect(ariaSelectProps, state, triggerRef)\n\n const { buttonProps } = useButton(triggerProps, triggerRef)\n const selectToggleProps = {\n ...buttonProps,\n label,\n labelProps,\n value: state?.selectedItem?.rendered,\n valueProps,\n isOpen: state.isOpen,\n placeholder,\n status,\n isDisabled: triggerProps.isDisabled,\n isReversed,\n ref: refs.setReference,\n }\n\n return (\n <div\n className={classnames(\n !isFullWidth && styles.notFullWidth,\n classNameOverride\n )}\n >\n <HiddenSelect\n label={label}\n name={id}\n state={state}\n triggerRef={triggerRef}\n />\n\n <div className={styles.container}>\n {trigger === undefined ? (\n <SelectToggle {...selectToggleProps} />\n ) : (\n trigger(selectToggleProps, selectToggleProps.ref)\n )}\n {state.isOpen && (\n <Popover\n refs={refs}\n focusOnProps={{\n onEscapeKey: state.close,\n onClickOutside: state.close,\n noIsolation: true,\n }}\n >\n <SelectProvider<Option> state={state}>\n <SelectPopoverContents menuProps={menuProps}>\n {children}\n </SelectPopoverContents>\n </SelectProvider>\n </Popover>\n )}\n </div>\n\n {validationMessage && (\n <FieldMessage\n {...errorMessageProps}\n message={validationMessage}\n status={status}\n reversed={isReversed}\n />\n )}\n\n {description && (\n <FieldMessage\n {...descriptionProps}\n id={descriptionId}\n message={description}\n reversed={isReversed}\n />\n )}\n </div>\n )\n}\n\nSelect.displayName = \"Select\"\n\nSelect.Section = ListBoxSection\nSelect.SectionDivider = SectionDivider\nSelect.Option = Option\nSelect.ItemDefaultRender = ListItem\n\n// @deprecated Legacy exported aliases\nSelect.TriggerButton = SelectToggle\nSelect.ListBox = ListBox\n"],"names":["Select","_a","label","items","propsId","id","trigger","children","status","validationMessage","isReversed","isFullWidth","disabledValues","classNameOverride","selectedKey","description","placeholder","isDisabled","restProps","__rest","refs","useFloating","triggerRef","reference","useId","descriptionId","concat","disabledKeys","getDisabledKeysFromItems","ariaSelectProps","transformSelectItemToCollectionElement","toString","state","useSelectState","_c","useSelect","labelProps","triggerProps","valueProps","menuProps","errorMessageProps","descriptionProps","buttonProps","useButton","selectToggleProps","__assign","value","selectedItem","_b","rendered","isOpen","ref","setReference","React","createElement","className","classnames","styles","notFullWidth","HiddenSelect","name","container","undefined","SelectToggle","Popover","focusOnProps","onEscapeKey","close","onClickOutside","noIsolation","SelectProvider","SelectPopoverContents","FieldMessage","message","reversed","displayName","Section","ListBoxSection","SectionDivider","Option","ItemDefaultRender","ListItem","TriggerButton","ListBox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuEA;;;AAGG;AAHH,MAIaA,MAAM;EAAA,MAANA,MAAM,GAAG,SAAAA,CAA6CC,EAiB7C,EAAA;;IAhBpB,IAAAC,KAAK,WAAA;MACLC,KAAK,WAAA;MACDC,OAAO,GAAAH,EAAA,CAAAI,EAAA;MACXC,OAAO,GAAAL,EAAA,CAAAK,OAAA;MACPC,QAAQ,GAAAN,EAAA,CAAAM,QAAA;MACRC,MAAM,GAAAP,EAAA,CAAAO,MAAA;MACNC,iBAAiB,GAAAR,EAAA,CAAAQ,iBAAA;MACjBC,UAAU,GAAAT,EAAA,CAAAS,UAAA;MACVC,WAAW,GAAAV,EAAA,CAAAU,WAAA;MACXC,cAAc,GAAAX,EAAA,CAAAW,cAAA;MACdC,iBAAiB,GAAAZ,EAAA,CAAAY,iBAAA;MACjBC,WAAW,GAAAb,EAAA,CAAAa,WAAA;MACXC,WAAW,iBAAA;MACXC,WAAW,iBAAA;MACXC,UAAU,gBAAA;MACPC,SAAS,GAhBqDC,KAAAA,CAAAA,MAAA,CAAAlB,EAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,IAAA,EAAA,SAAA,EAAA,UAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,YAAA,E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AAAA,CAAAA,QAAQ;EAEnC;EACAjF,MAAM,CAACkF,aAAa,GAAGnB,YAAAA,CAAAA,YAAY;EACnC/D,MAAM,CAACmF,OAAO,GAAGA,OAAO,CAAAA,OAAA;EAAA,OArIXnF,MAAM;AAAA;"}
|
|
1
|
+
{"version":3,"file":"Select.cjs","sources":["../../../../src/__future__/Select/Select.tsx"],"sourcesContent":["import React, { useEffect, useId, useState } from \"react\"\nimport { UseFloatingReturn } from \"@floating-ui/react-dom\"\nimport { useButton } from \"@react-aria/button\"\nimport { HiddenSelect, useSelect } from \"@react-aria/select\"\nimport {\n useSelectState,\n SelectProps as AriaSelectProps,\n} from \"@react-stately/select\"\nimport { Key } from \"@react-types/shared\"\nimport classnames from \"classnames\"\nimport { FieldMessage } from \"~components/FieldMessage\"\nimport {\n Popover,\n useFloating,\n} from \"~components/MultiSelect/subcomponents/Popover\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { SelectProvider } from \"./context\"\nimport {\n ListBox,\n ListBoxSection,\n ListItem,\n Option,\n SectionDivider,\n SelectPopoverContents,\n SelectPopoverContentsProps,\n SelectToggle,\n SelectToggleProps,\n} from \"./subcomponents\"\nimport { SelectItem, SelectOption } from \"./types\"\nimport { getDisabledKeysFromItems } from \"./utils/getDisabledKeysFromItems\"\nimport { transformSelectItemToCollectionElement } from \"./utils/transformSelectItemToCollectionElement\"\nimport styles from \"./Select.module.scss\"\n\ntype OmittedAriaSelectProps = \"children\" | \"items\"\n\nexport type SelectProps<Option extends SelectOption = SelectOption> = {\n /**\n * Item objects in the collection.\n */\n items: Array<SelectItem<Option>>\n id?: string\n trigger?: (\n selectToggleProps: SelectToggleProps & {\n ref: UseFloatingReturn<HTMLButtonElement>[\"refs\"][\"setReference\"]\n },\n // @deprecated: This arg is unnecessary now, but provided for legacy usages\n ref: UseFloatingReturn<HTMLButtonElement>[\"refs\"][\"setReference\"]\n ) => JSX.Element\n children?: SelectPopoverContentsProps<Option>[\"children\"]\n /**\n * Updates the styling of the validation FieldMessage.\n */\n status?: \"error\" | \"caution\"\n /**\n * A descriptive message for the 'status' states.\n */\n validationMessage?: React.ReactNode | undefined\n /**\n * Use the `reversed` styles.\n */\n isReversed?: boolean\n /**\n * Use the `fullWidth` styles.\n */\n isFullWidth?: boolean\n /**\n * @deprecated: Either define `disabled` in your `Option` (in `items`), or use `disabledKeys`\n */\n disabledValues?: Key[]\n /**\n * Creates a portal for the Popover to the matching element id\n */\n portalContainerId?: string\n} & OverrideClassName<Omit<AriaSelectProps<Option>, OmittedAriaSelectProps>>\n\n/**\n * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896474/Select Guidance} |\n * {@link https://cultureamp.design/?path=/docs/components-select--docs Storybook}\n */\nexport const Select = <Option extends SelectOption = SelectOption>({\n label,\n items,\n id: propsId,\n trigger,\n children,\n status,\n validationMessage,\n isReversed,\n isFullWidth,\n disabledValues,\n classNameOverride,\n selectedKey,\n description,\n placeholder,\n isDisabled,\n portalContainerId,\n ...restProps\n}: SelectProps<Option>): JSX.Element => {\n const { refs } = useFloating<HTMLButtonElement>()\n const triggerRef = refs.reference\n const id = propsId ?? useId()\n const descriptionId = `${id}--description`\n const popoverId = `${id}--popover`\n\n const disabledKeys = getDisabledKeysFromItems(items)\n\n const ariaSelectProps: AriaSelectProps<SelectItem<Option>> = {\n label,\n items,\n children: transformSelectItemToCollectionElement,\n disabledKeys: disabledValues ?? disabledKeys,\n selectedKey:\n typeof selectedKey === \"number\" ? selectedKey.toString() : selectedKey,\n description,\n placeholder,\n isDisabled,\n ...restProps,\n }\n\n const state = useSelectState(ariaSelectProps)\n\n const {\n labelProps,\n triggerProps: reactAriaTriggerProps,\n valueProps,\n menuProps,\n errorMessageProps,\n descriptionProps,\n } = useSelect(ariaSelectProps, state, triggerRef)\n\n // Hack incoming:\n // react-aria/useSelect wants to prefix the combobox's accessible name with the value of the select.\n // We use role=combobox, meaning screen readers will read the value.\n // So we're modifying the `aria-labelledby` property to remove the value element id.\n // Issue: https://github.com/adobe/react-spectrum/issues/4091\n const reactAriaLabelledBy = reactAriaTriggerProps[\"aria-labelledby\"]\n const triggerProps = {\n ...reactAriaTriggerProps,\n \"aria-labelledby\": reactAriaLabelledBy?.substring(\n reactAriaLabelledBy.indexOf(\" \") + 1\n ),\n }\n\n const { buttonProps } = useButton(triggerProps, triggerRef)\n const selectToggleProps = {\n ...buttonProps,\n label,\n labelProps,\n value: state?.selectedItem?.rendered,\n valueProps,\n isOpen: state.isOpen,\n placeholder,\n status,\n isDisabled: triggerProps.isDisabled,\n isReversed,\n ref: refs.setReference,\n }\n\n const [portalContainer, setPortalContainer] = useState<HTMLElement>()\n\n useEffect(() => {\n if (portalContainerId) {\n const portalElement = document.getElementById(portalContainerId)\n portalElement && setPortalContainer(portalElement)\n }\n }, [])\n\n return (\n <div\n className={classnames(\n !isFullWidth && styles.notFullWidth,\n classNameOverride\n )}\n >\n <HiddenSelect\n label={label}\n name={id}\n state={state}\n triggerRef={triggerRef}\n />\n\n <div className={styles.container}>\n {trigger === undefined ? (\n <SelectToggle {...selectToggleProps} />\n ) : (\n trigger(selectToggleProps, selectToggleProps.ref)\n )}\n {state.isOpen && (\n <Popover\n id={popoverId}\n portalContainer={portalContainer}\n refs={refs}\n focusOnProps={{\n onEscapeKey: state.close,\n onClickOutside: state.close,\n noIsolation: true,\n }}\n >\n <SelectProvider<Option> state={state}>\n <SelectPopoverContents menuProps={menuProps}>\n {children}\n </SelectPopoverContents>\n </SelectProvider>\n </Popover>\n )}\n </div>\n\n {validationMessage && (\n <FieldMessage\n {...errorMessageProps}\n message={validationMessage}\n status={status}\n reversed={isReversed}\n />\n )}\n\n {description && (\n <FieldMessage\n {...descriptionProps}\n id={descriptionId}\n message={description}\n reversed={isReversed}\n />\n )}\n </div>\n )\n}\n\nSelect.displayName = \"Select\"\n\nSelect.Section = ListBoxSection\nSelect.SectionDivider = SectionDivider\nSelect.Option = Option\nSelect.ItemDefaultRender = ListItem\n\n// @deprecated Legacy exported aliases\nSelect.TriggerButton = SelectToggle\nSelect.ListBox = ListBox\n"],"names":["Select","_a","label","items","propsId","id","trigger","children","status","validationMessage","isReversed","isFullWidth","disabledValues","classNameOverride","selectedKey","description","placeholder","isDisabled","portalContainerId","restProps","__rest","refs","useFloating","triggerRef","reference","useId","descriptionId","concat","popoverId","disabledKeys","getDisabledKeysFromItems","ariaSelectProps","transformSelectItemToCollectionElement","toString","state","useSelectState","_c","useSelect","labelProps","reactAriaTriggerProps","triggerProps","valueProps","menuProps","errorMessageProps","descriptionProps","reactAriaLabelledBy","__assign","substring","indexOf","buttonProps","useButton","selectToggleProps","value","selectedItem","_b","rendered","isOpen","ref","setReference","_d","useState","portalContainer","setPortalContainer","useEffect","portalElement","document","getElementById","React","createElement","className","classnames","styles","notFullWidth","HiddenSelect","name","container","undefined","SelectToggle","Popover","focusOnProps","onEscapeKey","close","onClickOutside","noIsolation","SelectProvider","SelectPopoverContents","FieldMessage","message","reversed","displayName","Section","ListBoxSection","SectionDivider","Option","ItemDefaultRender","ListItem","TriggerButton","ListBox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2EA;;;AAGG;AAHH,MAIaA,MAAM;EAAA,MAANA,MAAM,GAAG,SAAAA,CAA6CC,EAkB7C,EAAA;;IAjBpB,IAAAC,KAAK,WAAA;MACLC,KAAK,WAAA;MACDC,OAAO,GAAAH,EAAA,CAAAI,EAAA;MACXC,OAAO,GAAAL,EAAA,CAAAK,OAAA;MACPC,QAAQ,GAAAN,EAAA,CAAAM,QAAA;MACRC,MAAM,GAAAP,EAAA,CAAAO,MAAA;MACNC,iBAAiB,GAAAR,EAAA,CAAAQ,iBAAA;MACjBC,UAAU,GAAAT,EAAA,CAAAS,UAAA;MACVC,WAAW,iBAAA;MACXC,cAAc,GAAAX,EAAA,CAAAW,cAAA;MACdC,iBAAiB,GAAAZ,EAAA,CAAAY,iBAAA;MACjBC,WAAW,GAAAb,EAAA,CAAAa,WAAA;MACXC,WAAW,GAAAd,EA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M,CAACiG,OAAO,GAAGA,OAAO,CAAAA,OAAA;EAAA,OA9JXjG,MAAM;AAAA;"}
|
|
@@ -4,6 +4,7 @@ export type ContextModalSecondaryActionProps = {
|
|
|
4
4
|
onSecondaryAction: () => void;
|
|
5
5
|
} | {
|
|
6
6
|
secondaryLabel?: undefined;
|
|
7
|
+
onSecondaryAction?: never;
|
|
7
8
|
};
|
|
8
9
|
export type ContextModalProps = Readonly<{
|
|
9
10
|
isOpen: boolean;
|
|
@@ -35,6 +36,6 @@ export type ContextModalProps = Readonly<{
|
|
|
35
36
|
* {@link https://cultureamp.design/?path=/docs/components-modals--contextmodal--docs Storybook}
|
|
36
37
|
*/
|
|
37
38
|
export declare const ContextModal: {
|
|
38
|
-
({ isOpen, unpadded, layout, title, onConfirm, onAfterLeave, confirmLabel, confirmWorking, renderBackground, children, contentHeader, image, ...props }: ContextModalProps): JSX.Element;
|
|
39
|
+
({ isOpen, unpadded, layout, title, onConfirm, onDismiss: propsOnDismiss, onAfterLeave, confirmLabel, confirmWorking, renderBackground, children, contentHeader, image, secondaryLabel, onSecondaryAction, ...props }: ContextModalProps): JSX.Element;
|
|
39
40
|
displayName: string;
|
|
40
41
|
};
|
|
@@ -2,7 +2,7 @@ import { HTMLAttributes } from "react";
|
|
|
2
2
|
import { FieldMessageProps } from "../FieldMessage";
|
|
3
3
|
import { OverrideClassName } from "../types/OverrideClassName";
|
|
4
4
|
import { MultiSelectOptionsProps } from "./subcomponents/MultiSelectOptions";
|
|
5
|
-
import { MultiSelectOption } from "./types";
|
|
5
|
+
import { MultiSelectOption, ValidationMessage } from "./types";
|
|
6
6
|
export type MultiSelectProps = {
|
|
7
7
|
label: string;
|
|
8
8
|
items: MultiSelectOptionsProps["options"];
|
|
@@ -14,8 +14,10 @@ export type MultiSelectProps = {
|
|
|
14
14
|
onSelectedValuesChange: MultiSelectOptionsProps["onChange"];
|
|
15
15
|
isOpen: boolean;
|
|
16
16
|
onOpenChange: (isOpen: boolean) => void;
|
|
17
|
+
/** A status and message to provide context to the validation issue */
|
|
18
|
+
validationMessage?: ValidationMessage;
|
|
17
19
|
} & OverrideClassName<HTMLAttributes<HTMLDivElement>>;
|
|
18
20
|
export declare const MultiSelect: {
|
|
19
|
-
({ id: propsId, label, items, selectedValues, description, onSelectedValuesChange, isOpen, onOpenChange, classNameOverride, ...restProps }: MultiSelectProps): JSX.Element;
|
|
21
|
+
({ id: propsId, label, items, selectedValues, description, onSelectedValuesChange, isOpen, onOpenChange, classNameOverride, validationMessage, ...restProps }: MultiSelectProps): JSX.Element;
|
|
20
22
|
displayName: string;
|
|
21
23
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from "react";
|
|
2
|
+
import { FieldMessageProps } from "../../../FieldMessage";
|
|
2
3
|
import { OverrideClassName } from "../../../types/OverrideClassName";
|
|
3
4
|
import { MultiSelectOption } from "../../types";
|
|
4
5
|
export type MultiSelectToggleProps = {
|
|
@@ -7,6 +8,7 @@ export type MultiSelectToggleProps = {
|
|
|
7
8
|
["aria-controls"]: string;
|
|
8
9
|
selectedOptions: MultiSelectOption[];
|
|
9
10
|
isOpen?: boolean;
|
|
11
|
+
status?: FieldMessageProps["status"];
|
|
10
12
|
onRemoveOption: (optionValue: MultiSelectOption["value"]) => void;
|
|
11
13
|
onRemoveAllOptions: () => void;
|
|
12
14
|
} & OverrideClassName<HTMLAttributes<HTMLDivElement>>;
|
|
@@ -16,6 +18,7 @@ export declare const MultiSelectToggle: React.ForwardRefExoticComponent<{
|
|
|
16
18
|
"aria-controls": string;
|
|
17
19
|
selectedOptions: MultiSelectOption[];
|
|
18
20
|
isOpen?: boolean | undefined;
|
|
21
|
+
status?: FieldMessageProps["status"];
|
|
19
22
|
onRemoveOption: (optionValue: MultiSelectOption["value"]) => void;
|
|
20
23
|
onRemoveAllOptions: () => void;
|
|
21
24
|
} & Omit<React.HTMLAttributes<HTMLDivElement>, "className"> & {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FieldMessageStatus } from "../FieldMessage";
|
|
1
3
|
export type MultiSelectOption = {
|
|
2
4
|
label: string;
|
|
3
5
|
value: string | number;
|
|
4
6
|
};
|
|
7
|
+
export type ValidationMessage = {
|
|
8
|
+
status?: Extract<FieldMessageStatus, "error" | "caution">;
|
|
9
|
+
message: string | React.ReactElement;
|
|
10
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ToastNotificationObj } from "../types";
|
|
3
|
+
export type ToastNotificationProps = Omit<ToastNotificationObj, "id" | "message" | "persistent"> & {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
id?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Removes the dismiss trigger. Functions the same as `persistent` in `addToastNotification`.
|
|
8
|
+
* If this is true you will need to manage the removal of notifications manually.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
hideCloseIcon?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const ToastNotification: {
|
|
14
|
+
({ id: propsId, hideCloseIcon, type, title, onHide, children, ...restProps }: ToastNotificationProps): null;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ToastNotification";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
import { OverrideClassName } from "../../../../../types/OverrideClassName";
|
|
3
|
+
import { ToastNotificationObj } from "../../../types";
|
|
4
|
+
export type ToastNotificationsMapProps = {
|
|
5
|
+
notifications: ToastNotificationObj[];
|
|
6
|
+
onHide: (notificationId: string) => void;
|
|
7
|
+
container: Element | null;
|
|
8
|
+
} & OverrideClassName<HTMLAttributes<HTMLDivElement>>;
|
|
9
|
+
export declare const ToastNotificationsMap: {
|
|
10
|
+
({ notifications, onHide: defaultOnHide, container, }: ToastNotificationsMapProps): JSX.Element | null;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ToastNotificationsMap";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ToastNotificationObj } from "../types";
|
|
3
|
+
type ToastNotificationObjOptionalId = Omit<ToastNotificationObj, "id"> & {
|
|
4
|
+
id?: string;
|
|
5
|
+
};
|
|
6
|
+
export type ToastNotificationContextValue = {
|
|
7
|
+
notifications: ToastNotificationObj[];
|
|
8
|
+
addToastNotification: (notification: ToastNotificationObjOptionalId) => void;
|
|
9
|
+
updateToastNotification: (notification: ToastNotificationObj) => void;
|
|
10
|
+
removeToastNotification: (notificationId: string) => void;
|
|
11
|
+
clearToastNotifications: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const useToastNotificationContext: () => ToastNotificationContextValue;
|
|
14
|
+
type ToastNotificationProviderProps = {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export declare const ToastNotificationProvider: {
|
|
18
|
+
({ children, }: ToastNotificationProviderProps): JSX.Element | null;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from "./ToastNotification";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
2
|
+
export * from "./ToastNotificationsList";
|
|
3
|
+
export * from "./hooks/useToastNotification";
|
|
4
|
+
export * from "./types";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataAttributes } from "../../types/DataAttributes";
|
|
3
3
|
import { NotificationType } from "../types";
|
|
4
|
-
type
|
|
5
|
-
export type ToastNotification = {
|
|
4
|
+
export type ToastNotificationObj = {
|
|
6
5
|
id: string;
|
|
7
6
|
type: NotificationType;
|
|
8
7
|
title: string;
|
|
@@ -14,10 +13,3 @@ export type ToastNotification = {
|
|
|
14
13
|
*/
|
|
15
14
|
persistent?: boolean;
|
|
16
15
|
} & DataAttributes;
|
|
17
|
-
export type ToastNotificationWithOptionals = Modify<ToastNotification, {
|
|
18
|
-
id?: string;
|
|
19
|
-
}>;
|
|
20
|
-
export type AddToastNotification = (notification: ToastNotificationWithOptionals) => void;
|
|
21
|
-
export type RemoveToastNotification = (notificationId: string) => void;
|
|
22
|
-
export type ClearToastNotifications = () => void;
|
|
23
|
-
export {};
|
|
@@ -37,7 +37,7 @@ export type RichTextEditorProps = BaseRichTextEditorProps & (WithLabelText | Wit
|
|
|
37
37
|
* {@link https://cultureamp.design/?path=/docs/components-richtexteditor--docs Storybook}
|
|
38
38
|
*/
|
|
39
39
|
export declare const RichTextEditor: {
|
|
40
|
-
({ onChange, defaultValue, labelText, "aria-labelledby": labelledBy, classNameOverride, controls, rows, dataError, onDataError, validationMessage, description, status, ...restProps }: RichTextEditorProps): JSX.Element;
|
|
40
|
+
({ onChange, defaultValue, labelText, "aria-labelledby": labelledBy, "aria-describedby": describedBy, classNameOverride, controls, rows, dataError, onDataError, validationMessage, description, status, ...restProps }: RichTextEditorProps): JSX.Element;
|
|
41
41
|
displayName: string;
|
|
42
42
|
};
|
|
43
43
|
export {};
|
|
@@ -36,13 +36,17 @@ export type SelectProps<Option extends SelectOption = SelectOption> = {
|
|
|
36
36
|
* @deprecated: Either define `disabled` in your `Option` (in `items`), or use `disabledKeys`
|
|
37
37
|
*/
|
|
38
38
|
disabledValues?: Key[];
|
|
39
|
+
/**
|
|
40
|
+
* Creates a portal for the Popover to the matching element id
|
|
41
|
+
*/
|
|
42
|
+
portalContainerId?: string;
|
|
39
43
|
} & OverrideClassName<Omit<AriaSelectProps<Option>, OmittedAriaSelectProps>>;
|
|
40
44
|
/**
|
|
41
45
|
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896474/Select Guidance} |
|
|
42
46
|
* {@link https://cultureamp.design/?path=/docs/components-select--docs Storybook}
|
|
43
47
|
*/
|
|
44
48
|
export declare const Select: {
|
|
45
|
-
<Option extends SelectOption = SelectOption>({ label, items, id: propsId, trigger, children, status, validationMessage, isReversed, isFullWidth, disabledValues, classNameOverride, selectedKey, description, placeholder, isDisabled, ...restProps }: SelectProps<Option>): JSX.Element;
|
|
49
|
+
<Option extends SelectOption = SelectOption>({ label, items, id: propsId, trigger, children, status, validationMessage, isReversed, isFullWidth, disabledValues, classNameOverride, selectedKey, description, placeholder, isDisabled, portalContainerId, ...restProps }: SelectProps<Option>): JSX.Element;
|
|
46
50
|
displayName: string;
|
|
47
51
|
Section: {
|
|
48
52
|
<Option_1 extends SelectOption = SelectOption>({ section, }: import("./subcomponents").ListBoxSectionProps<Option_1>): JSX.Element;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -334,6 +334,9 @@ var ModalBody = require('./Modal/GenericModal/subcomponents/ModalBody/ModalBody.
|
|
|
334
334
|
var InputEditModal = require('./Modal/InputEditModal/InputEditModal.cjs');
|
|
335
335
|
var InlineNotification = require('./Notification/InlineNotification/InlineNotification.cjs');
|
|
336
336
|
var GlobalNotification = require('./Notification/GlobalNotification/GlobalNotification.cjs');
|
|
337
|
+
var ToastNotification = require('./Notification/ToastNotification/ToastNotification/ToastNotification.cjs');
|
|
338
|
+
var ToastNotificationsList = require('./Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.cjs');
|
|
339
|
+
var useToastNotification = require('./Notification/ToastNotification/hooks/useToastNotification.cjs');
|
|
337
340
|
var Pagination = require('./Pagination/Pagination.cjs');
|
|
338
341
|
var DirectionalLink = require('./Pagination/subcomponents/DirectionalLink/DirectionalLink.cjs');
|
|
339
342
|
var PaginationLink = require('./Pagination/subcomponents/PaginationLink/PaginationLink.cjs');
|
|
@@ -943,6 +946,9 @@ exports.ModalBody = ModalBody.ModalBody;
|
|
|
943
946
|
exports.InputEditModal = InputEditModal.InputEditModal;
|
|
944
947
|
exports.InlineNotification = InlineNotification.InlineNotification;
|
|
945
948
|
exports.GlobalNotification = GlobalNotification.GlobalNotification;
|
|
949
|
+
exports.ToastNotification = ToastNotification.ToastNotification;
|
|
950
|
+
exports.ToastNotificationsList = ToastNotificationsList.ToastNotificationsList;
|
|
951
|
+
exports.useToastNotification = useToastNotification.useToastNotification;
|
|
946
952
|
exports.Pagination = Pagination.Pagination;
|
|
947
953
|
exports.DirectionalLink = DirectionalLink.DirectionalLink;
|
|
948
954
|
exports.PaginationLink = PaginationLink.PaginationLink;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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