@pega/cosmos-react-core 4.0.0-dev.19.1 → 4.0.0-dev.19.3
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/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +18 -31
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +1 -1
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/Drawer.d.ts.map +1 -1
- package/lib/components/AppShell/Drawer.js +25 -12
- package/lib/components/AppShell/Drawer.js.map +1 -1
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationList.js +3 -3
- package/lib/components/AppShell/NavigationList.js.map +1 -1
- package/lib/components/AppShell/Operator.d.ts +2 -2
- package/lib/components/AppShell/Operator.d.ts.map +1 -1
- package/lib/components/Avatar/Avatar.d.ts +2 -2
- package/lib/components/Avatar/Avatar.d.ts.map +1 -1
- package/lib/components/Backdrop/Backdrop.d.ts +3 -3
- package/lib/components/Backdrop/Backdrop.d.ts.map +1 -1
- package/lib/components/Backdrop/Backdrop.js.map +1 -1
- package/lib/components/Card/CardContent.d.ts +2 -2
- package/lib/components/Card/CardContent.d.ts.map +1 -1
- package/lib/components/Card/CardContent.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.styles.d.ts +1 -1
- package/lib/components/DateTime/utils.d.ts +9 -4
- package/lib/components/DateTime/utils.d.ts.map +1 -1
- package/lib/components/DateTime/utils.js +129 -67
- package/lib/components/DateTime/utils.js.map +1 -1
- package/lib/components/File/FileInput.d.ts +1 -1
- package/lib/components/File/FileInput.d.ts.map +1 -1
- package/lib/components/FormControl/FormControl.d.ts +1 -1
- package/lib/components/FormField/FormField.d.ts +2 -2
- package/lib/components/FormField/FormField.d.ts.map +1 -1
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/Icon/iconNames.d.ts +1 -1
- package/lib/components/Icon/iconNames.d.ts.map +1 -1
- package/lib/components/Icon/iconNames.js +2 -0
- package/lib/components/Icon/iconNames.js.map +1 -1
- package/lib/components/Icon/icons/semitruck-solid.icon.d.ts +5 -0
- package/lib/components/Icon/icons/semitruck-solid.icon.d.ts.map +1 -0
- package/lib/components/Icon/icons/semitruck-solid.icon.js +7 -0
- package/lib/components/Icon/icons/semitruck-solid.icon.js.map +1 -0
- package/lib/components/Icon/icons/semitruck.icon.d.ts +5 -0
- package/lib/components/Icon/icons/semitruck.icon.d.ts.map +1 -0
- package/lib/components/Icon/icons/semitruck.icon.js +7 -0
- package/lib/components/Icon/icons/semitruck.icon.js.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts +2 -2
- package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
- package/lib/components/Modal/Modal.styles.d.ts +1 -1
- package/lib/components/Modal/Modal.styles.d.ts.map +1 -1
- package/lib/components/Modal/ModalManager.js.map +1 -1
- package/lib/components/Number/NumberInput.styles.d.ts +2 -2
- package/lib/components/Text/Text.d.ts +1 -1
- package/lib/components/Text/Text.d.ts.map +1 -1
- package/lib/components/Tree/Tree.d.ts +2 -11
- package/lib/components/Tree/Tree.d.ts.map +1 -1
- package/lib/components/Tree/Tree.js.map +1 -1
- package/lib/theme/ThemeMachine.d.ts +1 -1
- package/lib/theme/ThemeMachine.d.ts.map +1 -1
- package/lib/theme/ThemeMachine.js.map +1 -1
- package/lib/theme/theme.d.ts +549 -549
- package/lib/theme/themes/aries2023DarkTheme.json +1 -0
- package/lib/types/types.d.ts +14 -6
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semitruck.icon.js","sourceRoot":"","sources":["../../../../src/components/Icon/icons/semitruck.icon.tsx"],"names":[],"mappings":";AAAA,+DAA+D;AAE/D,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC;AAE7B,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAC;AAEhC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CAC7B,eACE,CAAC,EAAC,umDAAumD,EACzmD,IAAI,EAAC,cAAc,EACnB,QAAQ,EAAC,SAAS,GAClB,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC","sourcesContent":["// This file is autogenerated. Any changes will be overwritten.\n\nexport const set = 'budicon';\n\nexport const name = 'semitruck';\n\nexport const Component = () => (\n <path\n d='m1 16c-.552284 0-1-.4477-1-1v-7c0-.55228.447715-1 1-1h16.6652c.3612 0 .6944.19486.8715.50974l.5516.98052c.1771.31488.5103.50974.8715.50974h.6027c.3148 0 .6111.14819.8.4l1.65 2.2c.1889.2518.4852.4.8.4h.1875c.5523 0 1 .4477 1 1v2c0 .5523-.4477 1-1 1h-1.063c-.222.8626-1.0051 1.5-1.937 1.5s-1.715-.6374-1.937-1.5h-3.126c-.222.8626-1.0051 1.5-1.937 1.5-.5973 0-1.1335-.2619-1.5-.6771-.3665.4152-.9027.6771-1.5.6771-.9319 0-1.71497-.6374-1.93699-1.5h-1.12602c-.22203.8626-1.0051 1.5-1.93699 1.5-.59735 0-1.13353-.2619-1.5-.6771-.36647.4152-.90266.6771-1.49999.6771-.93192 0-1.71498-.6374-1.937-1.5zm18.063-1c.222-.8626 1.0051-1.5 1.937-1.5s1.715.6374 1.937 1.5h1.063v-2h-4.5c-.2761 0-.5-.2239-.5-.5v-2.74538c-.3229-.17664-.5965-.44199-.7833-.7741l-.5515-.98052h-.6652v7zm-3.063 0h-.063c-.222-.8626-1.0051-1.5-1.937-1.5-.5973 0-1.1335.2619-1.5.6771-.3665-.4152-.9027-.6771-1.5-.6771-.9319 0-1.71497.6374-1.93699 1.5h-1.12602c-.22203-.8626-1.0051-1.5-1.93699-1.5-.59735 0-1.13353.2619-1.5.6771-.36647-.4152-.90266-.6771-1.49999-.6771-.93192 0-1.71498.6374-1.937 1.5h-.06301v-7h15zm-3 .5v.0043c.0023.5503.4491.9957 1 .9957.5523 0 1-.4477 1-1s-.4477-1-1-1c-.5512 0-.9982.446-1 .9968zm-2-1c.5512 0 .9983.446 1 .9968v.0032.0043c-.0023.5503-.4491.9957-1 .9957-.5523 0-1-.4477-1-1s.4477-1 1-1zm-5.99999 1v.0043c.00234.5503.44915.9957.99999.9957.55227 0 1-.4477 1-1s-.44773-1-1-1c-.55121 0-.99824.446-.99999.9968zm-2-1c.55119 0 .99825.446 1 .9968l-.00001.0032v.0043c-.00233.5503-.44917.9957-.99999.9957-.5523 0-1.00001-.4477-1.00001-1s.44771-1 1.00001-1zm16.99999-2.5h2.0625l-1.5-2h-.5625zm0 3.5c0-.5523.4477-1 1-1s1 .4477 1 1-.4477 1-1 1-1-.4477-1-1z'\n fill='currentColor'\n fillRule='evenodd'\n />\n);\n\nexport const viewBox = '0 0 25 25';\n"]}
|
|
@@ -2,7 +2,7 @@ import { MouseEvent, Ref, ComponentType, ReactNode } from 'react';
|
|
|
2
2
|
import { FormControlProps } from '@pega/cosmos-react-core/lib/components/FormControl';
|
|
3
3
|
import { SearchInputProps } from '../SearchInput';
|
|
4
4
|
import { MenuGroupProps, MenuProps } from '../Menu';
|
|
5
|
-
import { Action, BaseProps, HeadingTag, TestIdProp } from '../../types';
|
|
5
|
+
import { Action, BaseProps, ExcludeStrict, HeadingTag, TestIdProp } from '../../types';
|
|
6
6
|
import { AvatarProps } from '../Avatar';
|
|
7
7
|
export interface ViewProps {
|
|
8
8
|
/** Unique, stable identifier of this view. */
|
|
@@ -53,7 +53,7 @@ export interface QueryOptionDialogProps extends QueryOption {
|
|
|
53
53
|
/** Optionally provide query option presets. */
|
|
54
54
|
export interface PresetMenuProps extends QueryOption {
|
|
55
55
|
/** Mode defining whether menu selection is single or multi mode. */
|
|
56
|
-
mode?:
|
|
56
|
+
mode?: ExcludeStrict<MenuProps['mode'], 'action'>;
|
|
57
57
|
/** Items of the menu. */
|
|
58
58
|
items: {
|
|
59
59
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.types.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAEtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ListToolbar.types.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAEtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,WAAW,SAAS;IACxB,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,QAAQ,EAAE,OAAO,CAAC;IAClB,yDAAyD;IACzD,KAAK,CAAC,EAAE,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|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.types.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.types.ts"],"names":[],"mappings":"","sourcesContent":["import { MouseEvent, Ref, ComponentType, ReactNode } from 'react';\n\nimport { FormControlProps } from '@pega/cosmos-react-core/lib/components/FormControl';\n\nimport { SearchInputProps } from '../SearchInput';\nimport { MenuGroupProps, MenuProps } from '../Menu';\nimport { Action, BaseProps, HeadingTag, TestIdProp } from '../../types';\nimport { AvatarProps } from '../Avatar';\n\nexport interface ViewProps {\n /** Unique, stable identifier of this view. */\n id: string;\n /** Label text of this view. */\n text: string;\n /** Flag indicating whether this view is currently selected. */\n selected: boolean;\n /** A count to assist with number of associated items. */\n count?: number;\n /** A visual to assist identifying an item. */\n visual?: Pick<AvatarProps, 'name' | 'icon' | 'imageSrc' | 'status'>;\n}\n\nexport interface ViewGroupProps {\n /** Label text of the group. */\n text: MenuGroupProps['label'];\n /** Array of items belonging to the group. */\n items: ViewProps[];\n}\n\nexport interface ViewSelectorProps {\n /** A list of pre-defined data views. */\n views: (ViewProps | ViewGroupProps)[];\n /** Called when a view is selected. */\n onViewSelect: MenuProps['onItemClick'];\n /** Determines which view is the default. */\n defaultId?: string;\n /** Determines which view is the default in the app. */\n appDefaultId?: string;\n}\n\nexport interface QueryOption {\n /** A count representing the number of applied conditions within the query option. */\n count?: number;\n}\n\nexport interface QueryOptionDialogProps extends QueryOption {\n /** A component to render the content portion of the query option dialog. */\n renderer: ComponentType;\n /**\n * Called when the user explicitly or implicitly cancels(closes) the query dialog.\n * Returning false will block the dialog from closing.\n */\n onCancel: () => boolean | void;\n /**\n * Called when the user explicitly applies the query option conditions.\n * Returning false will block the dialog from closing.\n */\n onSubmit: () => boolean | void;\n}\n\n/** Optionally provide query option presets. */\nexport interface PresetMenuProps extends QueryOption {\n /** Mode defining whether menu selection is single or multi mode. */\n mode?:
|
|
1
|
+
{"version":3,"file":"ListToolbar.types.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.types.ts"],"names":[],"mappings":"","sourcesContent":["import { MouseEvent, Ref, ComponentType, ReactNode } from 'react';\n\nimport { FormControlProps } from '@pega/cosmos-react-core/lib/components/FormControl';\n\nimport { SearchInputProps } from '../SearchInput';\nimport { MenuGroupProps, MenuProps } from '../Menu';\nimport { Action, BaseProps, ExcludeStrict, HeadingTag, TestIdProp } from '../../types';\nimport { AvatarProps } from '../Avatar';\n\nexport interface ViewProps {\n /** Unique, stable identifier of this view. */\n id: string;\n /** Label text of this view. */\n text: string;\n /** Flag indicating whether this view is currently selected. */\n selected: boolean;\n /** A count to assist with number of associated items. */\n count?: number;\n /** A visual to assist identifying an item. */\n visual?: Pick<AvatarProps, 'name' | 'icon' | 'imageSrc' | 'status'>;\n}\n\nexport interface ViewGroupProps {\n /** Label text of the group. */\n text: MenuGroupProps['label'];\n /** Array of items belonging to the group. */\n items: ViewProps[];\n}\n\nexport interface ViewSelectorProps {\n /** A list of pre-defined data views. */\n views: (ViewProps | ViewGroupProps)[];\n /** Called when a view is selected. */\n onViewSelect: MenuProps['onItemClick'];\n /** Determines which view is the default. */\n defaultId?: string;\n /** Determines which view is the default in the app. */\n appDefaultId?: string;\n}\n\nexport interface QueryOption {\n /** A count representing the number of applied conditions within the query option. */\n count?: number;\n}\n\nexport interface QueryOptionDialogProps extends QueryOption {\n /** A component to render the content portion of the query option dialog. */\n renderer: ComponentType;\n /**\n * Called when the user explicitly or implicitly cancels(closes) the query dialog.\n * Returning false will block the dialog from closing.\n */\n onCancel: () => boolean | void;\n /**\n * Called when the user explicitly applies the query option conditions.\n * Returning false will block the dialog from closing.\n */\n onSubmit: () => boolean | void;\n}\n\n/** Optionally provide query option presets. */\nexport interface PresetMenuProps extends QueryOption {\n /** Mode defining whether menu selection is single or multi mode. */\n mode?: ExcludeStrict<MenuProps['mode'], 'action'>;\n /** Items of the menu. */\n items: { id: string; text: string; selected: boolean; icon?: string }[];\n /** Callback invoked on item selection. Passes the item id as an argument. */\n onItemClick: MenuProps['onItemClick'];\n}\nexport type QueryOptionId = 'filter' | 'sort' | 'group';\n\nexport interface ListToolbarProps extends BaseProps, TestIdProp {\n /** Renders a simple text name of table */\n name: string;\n /**\n * Uses specific heading tag for header.\n * @default h3\n */\n headingTag?: HeadingTag;\n /** Renders a simple view heading text or view selection menu. */\n viewSelector?: ViewSelectorProps;\n /** Props related to list used as a form control. */\n formControlProps?: Pick<FormControlProps, 'required'>;\n /** Props related to new item creation button. */\n createNew?: {\n /** Label of the new item creation button. */\n label?: string;\n /** Callback that will render a Create new button and is fired when that button is clicked. */\n onClick: (e: MouseEvent) => void;\n };\n /** Props related to the Search Input. */\n search?: SearchInputProps;\n /** Total returned results related for a given search. Optional indication of a selected item count. */\n count?: {\n total?: number;\n /**\n * If true renders + next to total number.\n * @default false\n */\n totalHasMore?: boolean;\n selected?: number;\n };\n /** Additional actions region */\n additionalActions?: ReactNode;\n /** Custom Rendering or available presets for filtering. */\n filter?: QueryOptionDialogProps | PresetMenuProps;\n /** Custom Rendering or available presets for sorting. */\n sort?: QueryOptionDialogProps | PresetMenuProps;\n /** Custom Rendering or available presets for grouping. */\n group?: QueryOptionDialogProps | PresetMenuProps;\n /** Top level dataset actions. */\n actions?: Action[];\n /** Ref for the actions button element. */\n actionsButtonRef?: Ref<HTMLButtonElement>;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|
|
@@ -5,5 +5,5 @@ export declare const StyledModalHeader: import("styled-components").StyledCompon
|
|
|
5
5
|
}, never>;
|
|
6
6
|
export declare const StyledModalContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
7
7
|
export declare const StyledModalActions: import("styled-components").StyledComponent<"footer", import("styled-components").DefaultTheme, {}, never>;
|
|
8
|
-
export declare const StyledModal: import("styled-components").StyledComponent<"article", import("styled-components").DefaultTheme, Partial<import("../Card").CardProps> &
|
|
8
|
+
export declare const StyledModal: import("styled-components").StyledComponent<"article", import("styled-components").DefaultTheme, Partial<import("../Card").CardProps> & Pick<ModalProps, "progress" | "children" | "as" | "heading" | "className" | "actions" | "count" | "forwardedAs" | "defaultFocus" | "onBeforeOpen" | "onAfterOpen" | "onBeforeClose" | "onAfterClose" | "onRequestDismiss" | "onRequestMinimize" | "onRequestMaximize" | "onRequestDock" | "onRequestActivate"> & Required<Pick<ModalProps, "stretch" | "center" | "autoWidth">> & Pick<ModalContextValue, "alert" | "state">, never>;
|
|
9
9
|
//# sourceMappingURL=Modal.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/Modal.styles.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI9D,eAAO,MAAM,uBAAuB,yGAAe,CAAC;AAEpD,eAAO,MAAM,iBAAiB;;SAyB7B,CAAC;AAIF,eAAO,MAAM,kBAAkB,yGAc7B,CAAC;AAIH,eAAO,MAAM,kBAAkB,4GAI7B,CAAC;AAIH,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Modal.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/Modal.styles.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI9D,eAAO,MAAM,uBAAuB,yGAAe,CAAC;AAEpD,eAAO,MAAM,iBAAiB;;SAyB7B,CAAC;AAIF,eAAO,MAAM,kBAAkB,yGAc7B,CAAC;AAIH,eAAO,MAAM,kBAAkB,4GAI7B,CAAC;AAIH,eAAO,MAAM,WAAW,8iBAoFtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalManager.js","sourceRoot":"","sources":["../../../src/components/Modal/ModalManager.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,SAAS,E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,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAErC,yCAAyC;IACzC,IAAI,QAAQ,CAAC,WAAW;QAAE,OAAO,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAoB,CAAC;IAElG,OAAO,CACL,MAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,aACnC,QAAQ,EACR,MAAM,CAAC,MAAM,GAAG,CAAC;gBAChB,YAAY;gBACZ,YAAY,CAAC,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,EAAE,YAAY,CAAC,IAC7C,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n useReducer,\n useMemo,\n useEffect,\n useContext,\n FunctionComponent,\n ComponentType,\n Dispatch,\n Context,\n memo\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { createUID, getActiveElement, windowIsAvailable } from '../../utils';\nimport { useConfiguration, useScrollToggle } from '../../hooks';\nimport { OmitStrict } from '../../types';\nimport '../../init';\n\nimport DockedModals from './DockedModals';\nimport {\n ModalMethods,\n ModalOptions,\n ModalObject,\n ModalManagerProps,\n ModalState,\n ModalManagerContextValue\n} from './Modal.types';\nimport { ModalContext, ModalManagerContext } from './Contexts';\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n modalManagerContext?: Context<ModalManagerContextValue>;\n }\n}\n\ntype ModalAction =\n | 'create'\n | 'update'\n | 'minimize'\n | 'maximize'\n | 'dock'\n | 'activate'\n | 'dismiss'\n | 'unmount';\n\ntype ModalReducerPayload<P extends object> =\n | { action: 'create'; modal: ModalObject<P> }\n | {\n action: 'update';\n modal: Partial<OmitStrict<ModalObject<P>, 'props'>> &\n Pick<ModalObject, 'id'> & { props: Partial<ModalObject<P>['props']> };\n }\n | {\n action: Exclude<ModalAction, 'create' | 'update'>;\n modal: Pick<ModalObject, 'id'>;\n };\n\nconst reducer = <P extends object>(\n modals: ModalObject[],\n payload: ModalReducerPayload<P>\n): ModalObject<any>[] => {\n switch (payload.action) {\n case 'create':\n return [\n ...modals.map(modal => {\n if (\n (!payload.modal.options.alert &&\n payload.modal.state === 'open' &&\n !modal.options.alert &&\n modal.state === 'open' &&\n modal.options.minimizable) ||\n payload.modal.options.dockable\n ) {\n modal.state = 'minimized';\n }\n\n return modal;\n }),\n payload.modal\n ];\n\n case 'unmount':\n return modals.filter(modal => modal.id !== payload.modal.id);\n\n case 'dismiss':\n return modals.map(modal => {\n modal.state = modal.id === payload.modal.id ? 'closed' : modal.state;\n return modal;\n });\n\n case 'update':\n return modals.map(modal => {\n modal.props =\n modal.id === payload.modal.id ? { ...modal.props, ...payload.modal.props } : modal.props;\n return modal;\n });\n\n case 'activate':\n return modals.map(modal => {\n if (modal.id === payload.modal.id && !modal.options.dockable) {\n modal.state = 'open';\n } else if (modal.id === payload.modal.id && modal.options.dockable) {\n modal.state = 'docked';\n } else if (!modal.options.alert && modal.state === 'open' && modal.options.minimizable) {\n modal.state = 'minimized';\n }\n\n return modal;\n });\n\n case 'minimize':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.minimizable ? 'minimized' : modal.state;\n return modal;\n });\n\n case 'maximize':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.maximizable ? 'maximized' : modal.state;\n return modal;\n });\n\n case 'dock':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.dockable ? 'docked' : 'minimized';\n return modal;\n });\n\n default:\n return modals;\n }\n};\n\nconst WrappedModal = memo(\n ({\n Component,\n id,\n options: { alert, dismissible, dockable, minimizable, maximizable },\n state,\n methods,\n props,\n top\n }: ModalObject & { top: boolean }) => (\n <ModalContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n id,\n alert,\n dismissible,\n minimizable,\n maximizable,\n dockable,\n state,\n top,\n initialized: true,\n ...methods\n }}\n >\n <Component {...props} />\n </ModalContext.Provider>\n )\n);\n\nconst RenderModals = ({ modals }: { modals: ModalObject[] }) => {\n const { open, minimized, alerts } = modals.reduce<{\n open: ModalObject[];\n minimized: ModalObject[];\n alerts: ModalObject[];\n }>(\n (obj, modal) => {\n if (modal.options.alert) obj.alerts.push(modal);\n else if (modal.state === 'minimized' || modal.state === 'docked') {\n obj.minimized.push(modal);\n } else obj.open.push(modal);\n\n return obj;\n },\n { open: [], minimized: [], alerts: [] }\n );\n\n return (\n <>\n {open.map((modal, i) => (\n <WrappedModal\n {...modal}\n top={alerts.length === 0 && i === open.length - 1}\n key={modal.id}\n />\n ))}\n {minimized.length > 0 && (\n <DockedModals>\n {minimized.map(modal => (\n <WrappedModal {...modal} top={false} key={modal.id} />\n ))}\n </DockedModals>\n )}\n {alerts.map((modal, i) => (\n <WrappedModal {...modal} top={i === open.length - 1} key={modal.id} />\n ))}\n </>\n );\n};\n\nconst ModalManager: FunctionComponent<ModalManagerProps> = ({ children }) => {\n const [modals, dispatch] = useReducer(reducer, []);\n const { disableScroll, enableScroll } = useScrollToggle();\n\n const providerValue = useMemo(\n () => ({\n create: <P extends object>(\n Component: ComponentType<P>,\n props?: P,\n options?: ModalOptions\n ) => {\n const id = options?.id || createUID();\n const activeElement = getActiveElement();\n const initiatorRef = activeElement ? new WeakRef(activeElement) : null;\n\n const methods: ModalMethods<P> = {\n dismiss: () => {\n dispatch({ action: 'dismiss', modal: { id } });\n options?.onDismiss?.(id);\n const initiator = initiatorRef?.deref();\n if (\n initiator?.isConnected &&\n (initiator instanceof HTMLElement || initiator instanceof SVGElement)\n ) {\n initiator.focus();\n }\n },\n update: updateProps => {\n (dispatch as Dispatch<ModalReducerPayload<P>>)({\n action: 'update',\n modal: { id, props: updateProps }\n });\n },\n minimize: () => {\n dispatch({ action: 'minimize', modal: { id } });\n options?.onMinimize?.(id);\n },\n maximize: () => {\n dispatch({ action: 'maximize', modal: { id } });\n options?.onMaximize?.(id);\n },\n dock: () => {\n dispatch({ action: 'dock', modal: { id } });\n options?.onDock?.(id);\n },\n activate: () => {\n dispatch({ action: 'activate', modal: { id } });\n options?.onActivate?.(id);\n },\n unmount: () => {\n dispatch({ action: 'unmount', modal: { id } });\n }\n };\n\n let defaultState: ModalState;\n if (options?.defaultMinimized) {\n defaultState = 'minimized';\n } else if (options?.dockable) {\n defaultState = 'docked';\n } else {\n defaultState = 'open';\n }\n\n (dispatch as Dispatch<ModalReducerPayload<P>>)({\n action: 'create',\n modal: {\n id,\n methods,\n Component,\n props,\n state: defaultState,\n options: {\n alert: false,\n minimizable: false,\n maximizable: false,\n dockable: false,\n defaultMinimized: false,\n unmountWhenMinimized: true,\n ...options,\n dismissible: !!(options?.alert ? false : options?.dismissible ?? true)\n }\n }\n });\n\n return methods;\n },\n ModalContext,\n initialized: true\n }),\n []\n );\n\n useEffect(() => {\n if (modals.some(modal => modal.state === 'open' && !modal.options.dockable)) {\n disableScroll();\n } else {\n enableScroll();\n }\n }, [modals]);\n\n const { portalTarget } = useConfiguration();\n\n const context = windowIsAvailable\n ? window.cosmos.modalManagerContext ?? ModalManagerContext\n : ModalManagerContext;\n const priorCtx = useContext(context);\n\n // Don't create additional Modal portals.\n if (priorCtx.initialized) return <context.Provider value={priorCtx}>{children}</context.Provider>;\n\n return (\n <context.Provider value={providerValue}>\n {children}\n {modals.length > 0 &&\n portalTarget &&\n createPortal(<RenderModals modals={modals} />, portalTarget)}\n </context.Provider>\n );\n};\n\nexport default ModalManager;\n"]}
|
|
1
|
+
{"version":3,"file":"ModalManager.js","sourceRoot":"","sources":["../../../src/components/Modal/ModalManager.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,SAAS,EACT,UAAU,EAKV,IAAI,EACL,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE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OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,aACnC,QAAQ,EACR,MAAM,CAAC,MAAM,GAAG,CAAC;gBAChB,YAAY;gBACZ,YAAY,CAAC,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,EAAE,YAAY,CAAC,IAC7C,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n useReducer,\n useMemo,\n useEffect,\n useContext,\n FunctionComponent,\n ComponentType,\n Dispatch,\n Context,\n memo\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { createUID, getActiveElement, windowIsAvailable } from '../../utils';\nimport { useConfiguration, useScrollToggle } from '../../hooks';\nimport { ExcludeStrict, OmitStrict } from '../../types';\nimport '../../init';\n\nimport DockedModals from './DockedModals';\nimport {\n ModalMethods,\n ModalOptions,\n ModalObject,\n ModalManagerProps,\n ModalState,\n ModalManagerContextValue\n} from './Modal.types';\nimport { ModalContext, ModalManagerContext } from './Contexts';\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n modalManagerContext?: Context<ModalManagerContextValue>;\n }\n}\n\ntype ModalAction =\n | 'create'\n | 'update'\n | 'minimize'\n | 'maximize'\n | 'dock'\n | 'activate'\n | 'dismiss'\n | 'unmount';\n\ntype ModalReducerPayload<P extends object> =\n | { action: 'create'; modal: ModalObject<P> }\n | {\n action: 'update';\n modal: Partial<OmitStrict<ModalObject<P>, 'props'>> &\n Pick<ModalObject, 'id'> & { props: Partial<ModalObject<P>['props']> };\n }\n | {\n action: ExcludeStrict<ModalAction, 'create' | 'update'>;\n modal: Pick<ModalObject, 'id'>;\n };\n\nconst reducer = <P extends object>(\n modals: ModalObject[],\n payload: ModalReducerPayload<P>\n): ModalObject<any>[] => {\n switch (payload.action) {\n case 'create':\n return [\n ...modals.map(modal => {\n if (\n (!payload.modal.options.alert &&\n payload.modal.state === 'open' &&\n !modal.options.alert &&\n modal.state === 'open' &&\n modal.options.minimizable) ||\n payload.modal.options.dockable\n ) {\n modal.state = 'minimized';\n }\n\n return modal;\n }),\n payload.modal\n ];\n\n case 'unmount':\n return modals.filter(modal => modal.id !== payload.modal.id);\n\n case 'dismiss':\n return modals.map(modal => {\n modal.state = modal.id === payload.modal.id ? 'closed' : modal.state;\n return modal;\n });\n\n case 'update':\n return modals.map(modal => {\n modal.props =\n modal.id === payload.modal.id ? { ...modal.props, ...payload.modal.props } : modal.props;\n return modal;\n });\n\n case 'activate':\n return modals.map(modal => {\n if (modal.id === payload.modal.id && !modal.options.dockable) {\n modal.state = 'open';\n } else if (modal.id === payload.modal.id && modal.options.dockable) {\n modal.state = 'docked';\n } else if (!modal.options.alert && modal.state === 'open' && modal.options.minimizable) {\n modal.state = 'minimized';\n }\n\n return modal;\n });\n\n case 'minimize':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.minimizable ? 'minimized' : modal.state;\n return modal;\n });\n\n case 'maximize':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.maximizable ? 'maximized' : modal.state;\n return modal;\n });\n\n case 'dock':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.dockable ? 'docked' : 'minimized';\n return modal;\n });\n\n default:\n return modals;\n }\n};\n\nconst WrappedModal = memo(\n ({\n Component,\n id,\n options: { alert, dismissible, dockable, minimizable, maximizable },\n state,\n methods,\n props,\n top\n }: ModalObject & { top: boolean }) => (\n <ModalContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n id,\n alert,\n dismissible,\n minimizable,\n maximizable,\n dockable,\n state,\n top,\n initialized: true,\n ...methods\n }}\n >\n <Component {...props} />\n </ModalContext.Provider>\n )\n);\n\nconst RenderModals = ({ modals }: { modals: ModalObject[] }) => {\n const { open, minimized, alerts } = modals.reduce<{\n open: ModalObject[];\n minimized: ModalObject[];\n alerts: ModalObject[];\n }>(\n (obj, modal) => {\n if (modal.options.alert) obj.alerts.push(modal);\n else if (modal.state === 'minimized' || modal.state === 'docked') {\n obj.minimized.push(modal);\n } else obj.open.push(modal);\n\n return obj;\n },\n { open: [], minimized: [], alerts: [] }\n );\n\n return (\n <>\n {open.map((modal, i) => (\n <WrappedModal\n {...modal}\n top={alerts.length === 0 && i === open.length - 1}\n key={modal.id}\n />\n ))}\n {minimized.length > 0 && (\n <DockedModals>\n {minimized.map(modal => (\n <WrappedModal {...modal} top={false} key={modal.id} />\n ))}\n </DockedModals>\n )}\n {alerts.map((modal, i) => (\n <WrappedModal {...modal} top={i === open.length - 1} key={modal.id} />\n ))}\n </>\n );\n};\n\nconst ModalManager: FunctionComponent<ModalManagerProps> = ({ children }) => {\n const [modals, dispatch] = useReducer(reducer, []);\n const { disableScroll, enableScroll } = useScrollToggle();\n\n const providerValue = useMemo(\n () => ({\n create: <P extends object>(\n Component: ComponentType<P>,\n props?: P,\n options?: ModalOptions\n ) => {\n const id = options?.id || createUID();\n const activeElement = getActiveElement();\n const initiatorRef = activeElement ? new WeakRef(activeElement) : null;\n\n const methods: ModalMethods<P> = {\n dismiss: () => {\n dispatch({ action: 'dismiss', modal: { id } });\n options?.onDismiss?.(id);\n const initiator = initiatorRef?.deref();\n if (\n initiator?.isConnected &&\n (initiator instanceof HTMLElement || initiator instanceof SVGElement)\n ) {\n initiator.focus();\n }\n },\n update: updateProps => {\n (dispatch as Dispatch<ModalReducerPayload<P>>)({\n action: 'update',\n modal: { id, props: updateProps }\n });\n },\n minimize: () => {\n dispatch({ action: 'minimize', modal: { id } });\n options?.onMinimize?.(id);\n },\n maximize: () => {\n dispatch({ action: 'maximize', modal: { id } });\n options?.onMaximize?.(id);\n },\n dock: () => {\n dispatch({ action: 'dock', modal: { id } });\n options?.onDock?.(id);\n },\n activate: () => {\n dispatch({ action: 'activate', modal: { id } });\n options?.onActivate?.(id);\n },\n unmount: () => {\n dispatch({ action: 'unmount', modal: { id } });\n }\n };\n\n let defaultState: ModalState;\n if (options?.defaultMinimized) {\n defaultState = 'minimized';\n } else if (options?.dockable) {\n defaultState = 'docked';\n } else {\n defaultState = 'open';\n }\n\n (dispatch as Dispatch<ModalReducerPayload<P>>)({\n action: 'create',\n modal: {\n id,\n methods,\n Component,\n props,\n state: defaultState,\n options: {\n alert: false,\n minimizable: false,\n maximizable: false,\n dockable: false,\n defaultMinimized: false,\n unmountWhenMinimized: true,\n ...options,\n dismissible: !!(options?.alert ? false : options?.dismissible ?? true)\n }\n }\n });\n\n return methods;\n },\n ModalContext,\n initialized: true\n }),\n []\n );\n\n useEffect(() => {\n if (modals.some(modal => modal.state === 'open' && !modal.options.dockable)) {\n disableScroll();\n } else {\n enableScroll();\n }\n }, [modals]);\n\n const { portalTarget } = useConfiguration();\n\n const context = windowIsAvailable\n ? window.cosmos.modalManagerContext ?? ModalManagerContext\n : ModalManagerContext;\n const priorCtx = useContext(context);\n\n // Don't create additional Modal portals.\n if (priorCtx.initialized) return <context.Provider value={priorCtx}>{children}</context.Provider>;\n\n return (\n <context.Provider value={providerValue}>\n {children}\n {modals.length > 0 &&\n portalTarget &&\n createPortal(<RenderModals modals={modals} />, portalTarget)}\n </context.Provider>\n );\n};\n\nexport default ModalManager;\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
interface StyledStepperProps {
|
|
2
2
|
size: number;
|
|
3
3
|
}
|
|
4
|
-
export declare const StyledStepperInput: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("
|
|
4
|
+
export declare const StyledStepperInput: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Pick<import("../FormControl").FormControlProps, keyof import("../FormControl").FormControlProps> & Required<Pick<import("../FormControl").FormControlProps, never>> & {
|
|
5
5
|
hasSuggestion?: boolean | undefined;
|
|
6
6
|
} & StyledStepperProps, never>;
|
|
7
|
-
declare const StyledNumberInput: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("
|
|
7
|
+
declare const StyledNumberInput: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Pick<import("../FormControl").FormControlProps, keyof import("../FormControl").FormControlProps> & Required<Pick<import("../FormControl").FormControlProps, never>> & {
|
|
8
8
|
hasSuggestion?: boolean | undefined;
|
|
9
9
|
}, never>;
|
|
10
10
|
export default StyledNumberInput;
|
|
@@ -13,7 +13,7 @@ export interface TextProps extends BaseProps, AsProp {
|
|
|
13
13
|
/** Ref for the wrapping element. */
|
|
14
14
|
ref?: Ref<HTMLSpanElement | HTMLHeadingElement>;
|
|
15
15
|
}
|
|
16
|
-
export declare const StyledText: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme,
|
|
16
|
+
export declare const StyledText: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, Pick<TextProps, "children" | "ref" | "as" | "status" | "className" | "forwardedAs"> & Required<Pick<TextProps, "variant">>, never>;
|
|
17
17
|
declare const Text: FunctionComponent<TextProps & ForwardProps>;
|
|
18
18
|
export default Text;
|
|
19
19
|
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAc,GAAG,EAAmB,MAAM,OAAO,CAAC;AAIvF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAK7F,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,MAAM;IAClD,oBAAoB;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;IAC/C,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IACzC,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,GAAG,kBAAkB,CAAC,CAAC;CACjD;AAID,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAc,GAAG,EAAmB,MAAM,OAAO,CAAC;AAIvF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAK7F,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,MAAM;IAClD,oBAAoB;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;IAC/C,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IACzC,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,GAAG,kBAAkB,CAAC,CAAC;CACjD;AAID,eAAO,MAAM,UAAU,kOAoCrB,CAAC;AAIH,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CASrD,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Ref, ComponentType, ReactNode } from 'react';
|
|
2
|
-
import { BaseProps, NoChildrenProp, ForwardProps } from '../../types';
|
|
3
|
-
export type OldTreeNode<T extends object = Record<string, unknown>> = {
|
|
4
|
-
/** The id of the Node. Used as the key for the li element wrapping the Node. */
|
|
5
|
-
id: string;
|
|
6
|
-
/** Child nodes. */
|
|
7
|
-
nodes?: OldTreeNode<T>[];
|
|
8
|
-
/** Props to apply to the li. */
|
|
9
|
-
listItemProps?: ForwardProps;
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
} & T;
|
|
2
|
+
import { BaseProps, NoChildrenProp, ForwardProps, OmitStrict } from '../../types';
|
|
12
3
|
export type TreeNode = {
|
|
13
4
|
/** The id of the Node. Used as the key for the li element wrapping the Node. */
|
|
14
5
|
id: string;
|
|
@@ -26,7 +17,7 @@ export interface TreeProps<T extends TreeNode = TreeNode> extends BaseProps, NoC
|
|
|
26
17
|
depth: number;
|
|
27
18
|
subTree?: ReactNode;
|
|
28
19
|
hasParentSibling: TreeItemProps['hasParentSibling'];
|
|
29
|
-
} &
|
|
20
|
+
} & OmitStrict<T, 'listItemProps'>>;
|
|
30
21
|
/** Ref for the wrapping element. */
|
|
31
22
|
ref?: Ref<HTMLUListElement>;
|
|
32
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../../src/components/Tree/Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGnF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../../src/components/Tree/Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGnF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAElF,MAAM,MAAM,QAAQ,GAAG;IACrB,gFAAgF;IAChF,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB;IACnB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,gCAAgC;IAChC,aAAa,CAAC,EAAE,YAAY,CAAC;IAE7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,CAAE,SAAQ,SAAS,EAAE,cAAc;IACzF,6EAA6E;IAC7E,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,wEAAwE;IACxE,YAAY,CAAC,EAAE,aAAa,CAC1B;QACE,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,SAAS,CAAC;QACpB,gBAAgB,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;KACrD,GAAG,UAAU,CAAC,CAAC,EAAE,eAAe,CAAC,CACnC,CAAC;IACF,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED,eAAO,MAAM,kBAAkB,wGAAc,CAAC;AAE9C,eAAO,MAAM,cAAc,wGAU1B,CAAC;AAWF,UAAU,aAAc,SAAQ,QAAQ;IACtC,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAkDD,QAAA,MAAM,IAAI,yEAOkE,WAAW,GAAG,IAAI,CAAC;AAE/F,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../src/components/Tree/Tree.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAkD,MAAM,OAAO,CAAC;AACnF,OAAO,MAAM,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../src/components/Tree/Tree.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAkD,MAAM,OAAO,CAAC;AACnF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AA8BvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAA,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAA;;;;;;;IAOnC,kBAAkB;;;CAGrB,CAAC;AAEF,MAAM,mBAAmB,GAA8B,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IAC3E,OAAO,CACL,8BACG,IAAI,EACJ,OAAO,IAC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CACE,EAAE,YAAY,GAAG,mBAAmB,EAAE,GAAG,SAAS,EAA8B,EAChF,GAAqB,EACrB,EAAE;IACF,OAAO,KAAC,QAAQ,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,YAAY,GAAI,CAAC;AACrF,CAAC,CAC2F,CAAC;AAE/F,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, Ref, ComponentType, ReactNode } from 'react';\nimport styled from 'styled-components';\n\nimport { BaseProps, NoChildrenProp, ForwardProps, OmitStrict } from '../../types';\n\nexport type TreeNode = {\n /** The id of the Node. Used as the key for the li element wrapping the Node. */\n id: string;\n /** Child nodes. */\n nodes?: TreeNode[];\n /** Props to apply to the li. */\n listItemProps?: ForwardProps;\n\n [key: string]: unknown;\n};\n\nexport interface TreeProps<T extends TreeNode = TreeNode> extends BaseProps, NoChildrenProp {\n /** An array of ParentNodes and Nodes that compose the layout of the Tree. */\n nodes: T[];\n /** A function that allows custom styling and behavior for all Nodes. */\n nodeRenderer?: ComponentType<\n {\n depth: number;\n subTree?: ReactNode;\n hasParentSibling: TreeItemProps['hasParentSibling'];\n } & OmitStrict<T, 'listItemProps'>\n >;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLUListElement>;\n}\n\nexport const StyledTreeListItem = styled.li``;\n\nexport const StyledTreeList = styled.ul`\n &,\n & & {\n list-style: none;\n position: relative;\n }\n\n ${StyledTreeListItem} {\n position: relative;\n }\n`;\n\nconst DefaultNodeRenderer: TreeProps['nodeRenderer'] = ({ data, subTree }) => {\n return (\n <>\n {data}\n {subTree}\n </>\n );\n};\n\ninterface TreeItemProps extends TreeNode {\n nodeRenderer: NonNullable<TreeProps['nodeRenderer']>;\n depth: number;\n hasParentSibling: boolean;\n}\n\ninterface TreeListProps extends Pick<TreeProps, 'nodes' | 'ref'> {\n nodeRenderer: NonNullable<TreeProps['nodeRenderer']>;\n depth: number;\n}\n\nlet TreeList: ComponentType<TreeListProps>;\n\nconst TreeItem = ({\n listItemProps,\n depth,\n nodes,\n nodeRenderer: NodeRenderer,\n ...restProps\n}: TreeItemProps) => {\n return (\n <StyledTreeListItem {...listItemProps}>\n <NodeRenderer\n {...restProps}\n depth={depth}\n nodes={nodes}\n subTree={nodes && <TreeList depth={depth + 1} nodes={nodes} nodeRenderer={NodeRenderer} />}\n />\n </StyledTreeListItem>\n );\n};\n\nTreeList = forwardRef(\n (\n { nodes, depth, nodeRenderer, ...restProps }: PropsWithoutRef<TreeListProps>,\n ref?: TreeProps['ref']\n ) => {\n const hasParentSibling = nodes.some(node => !!node.nodes);\n return nodes.length > 0 ? (\n <StyledTreeList {...restProps} ref={ref} role={depth === 0 ? 'tree' : 'group'}>\n {nodes.map(node => (\n <TreeItem\n {...node}\n key={node.id}\n depth={depth}\n nodeRenderer={nodeRenderer}\n hasParentSibling={hasParentSibling}\n />\n ))}\n </StyledTreeList>\n ) : null;\n }\n);\n\nconst Tree = forwardRef(\n (\n { nodeRenderer = DefaultNodeRenderer, ...restProps }: PropsWithoutRef<TreeProps>,\n ref: TreeProps['ref']\n ) => {\n return <TreeList {...restProps} ref={ref} depth={0} nodeRenderer={nodeRenderer} />;\n }\n) as <T extends TreeNode = TreeNode>(props: TreeProps<T> & ForwardProps) => JSX.Element | null;\n\nexport default Tree;\n"]}
|
|
@@ -9,7 +9,7 @@ export type ThemeDefinition = {
|
|
|
9
9
|
[key: string]: ThemeLeaf<unknown> | ThemeDefinition;
|
|
10
10
|
};
|
|
11
11
|
export type ToThemeIFace<Node, Extension = never> = Node extends ThemeLeaf<infer LeafVal> ? (LeafVal extends null ? LeafVal | string : LeafVal) | Extension : Node extends object ? {
|
|
12
|
-
readonly [Key in
|
|
12
|
+
readonly [Key in keyof Node as Key extends '$comment' ? never : Key]: ToThemeIFace<Node[Key], Extension>;
|
|
13
13
|
} : Node | Extension;
|
|
14
14
|
export type SettableTheme<Def extends ThemeDefinition> = DeepPartial<ToThemeIFace<Def, symbol>>;
|
|
15
15
|
export declare const resetToInitial: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeMachine.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeMachine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,SAAS,CAAC,KAAK;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,IAAI,IAAI,SAAS,SAAS,CAAC,MAAM,OAAO,CAAC,GACrF,CAAC,OAAO,SAAS,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,GAC/D,IAAI,SAAS,MAAM,GACnB;IACE,QAAQ,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"ThemeMachine.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeMachine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,SAAS,CAAC,KAAK;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,IAAI,EAAE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gBAyD9D,EACV,KAAuC,EACvC,MAAM,EACN,UAAU,EACX,EACG;QACE,KAAK,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QAClC,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACrC,UAAU,CAAC,EAAE,KAAK,CAAC;KACpB,GACD;QAAE,KAAK,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE;CAMlF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeMachine.js","sourceRoot":"","sources":["../../src/theme/ThemeMachine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ThemeMachine.js","sourceRoot":"","sources":["../../src/theme/ThemeMachine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AA2BtD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;AAYzF,MAAM,YAAY;IAShB,cAAc,CAAC,IAAc;QAC3B,IAAI,QAAQ,GAAwC,IAAI,CAAC;QACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEhC,OAAO,QAAQ,EAAE;YACf,0CAA0C;YAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAE9B,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChF,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC;SAC5B;QAED,OAAO,K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,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;iBAChF;gBAED,uCAAuC;qBAClC,IAAI,OAAO,CAAC,KAAK,KAAK,WAAW,EAAE;oBACtC,4DAA4D;oBAC5D,iBAAiB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBACzF;gBAED,qCAAqC;qBAChC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE;oBACpC,6CAA6C;oBAC7C,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;iBACjC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;QAEF,OAAO,gBAAgB,EAA8B,CAAC;IACxD,CAAC;IAED,YAAY,EACV,KAAK,GAAG,EAA+B,EACvC,MAAM,EACN,UAAU,EAOqE;QA1FjF;;;;;WAA4C;QAE5C;;;;;WAAuB;QAEvB;;;;;WAAgC;QAEvB;;;;;WAAgC;QAqFvC,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;QAC1D,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,eAAe,YAAY,CAAC","sourcesContent":["import { deepGet, defineSmartGetter } from '../utils';\nimport { DeepPartial } from '../types';\n\nexport interface ThemeLeaf<Value> {\n $type: string;\n $value: Value;\n $constant?: boolean;\n $comment?: string;\n}\n\nexport type ThemeDefinition = {\n [key: string]: ThemeLeaf<unknown> | ThemeDefinition;\n};\n\nexport type ToThemeIFace<Node, Extension = never> = Node extends ThemeLeaf<infer LeafVal>\n ? (LeafVal extends null ? LeafVal | string : LeafVal) | Extension\n : Node extends object\n ? {\n readonly [Key in keyof Node as Key extends '$comment' ? never : Key]: ToThemeIFace<\n Node[Key],\n Extension\n >;\n }\n : Node | Extension;\n\nexport type SettableTheme<Def extends ThemeDefinition> = DeepPartial<ToThemeIFace<Def, symbol>>;\n\nexport const resetToInitial = Symbol.for('@pega/cosmos-react-core.theme.resetToInitial');\n\nexport interface ThemeMachineLike<Definition extends ThemeDefinition> {\n parent: ThemeMachineLike<Definition> | null;\n\n definition: Definition;\n\n overrides: Map<string, boolean>;\n\n readonly theme: ToThemeIFace<Definition>;\n}\n\nclass ThemeMachine<Definition extends ThemeDefinition> implements ThemeMachineLike<Definition> {\n parent: ThemeMachineLike<Definition> | null;\n\n definition: Definition;\n\n overrides: Map<string, boolean>;\n\n readonly theme: ToThemeIFace<Definition>;\n\n overrideInTree(keys: string[]): boolean {\n let ancestor: ThemeMachineLike<Definition> | null = this;\n const fullProp = keys.join('.');\n\n while (ancestor) {\n // Trigger getters in the ancestor themes.\n deepGet(ancestor.theme, keys);\n\n if (ancestor.overrides.has(fullProp)) return !!ancestor.overrides.get(fullProp);\n ancestor = ancestor.parent;\n }\n\n return false;\n }\n\n constructTheme(theme: SettableTheme<Definition>): ToThemeIFace<Definition> {\n const constructForNode = (keys: string[] = []) => {\n const themeNode: Record<string, any> = {};\n\n Object.keys(deepGet(this.definition, keys)).forEach(key => {\n // Ignore comment nodes.\n if (key === '$comment') return;\n\n const propKeys = [...keys, key];\n const defNode: Record<string, any> = deepGet(this.definition, propKeys);\n\n // If it is not a leaf node of the theme definition...\n if (defNode.$type === undefined) {\n // recursively run for child nodes.\n defineSmartGetter(themeNode, key, () => constructForNode(propKeys));\n return;\n }\n\n const themeValue = deepGet(theme, propKeys);\n\n // If a theme value was set for this ThemeMachine...\n if (themeValue !== undefined) {\n // set overrides to true, unless it is being reset.\n this.overrides.set(propKeys.join('.'), themeValue !== resetToInitial);\n }\n\n // If a theme value was set for this ThemeMachine, is not being reset, and is for a non-constant property...\n if (themeValue !== undefined && themeValue !== resetToInitial && !defNode.$constant) {\n // set to the provided value.\n themeNode[key] = themeValue;\n }\n\n // If the property has been overridden in the tree (and not reset)...\n else if (this.overrideInTree(propKeys)) {\n // set to the value in the parent theme.\n defineSmartGetter(themeNode, key, () => deepGet(this.parent!.theme, propKeys));\n }\n\n // If the property type is inherited...\n else if (defNode.$type === 'inherited') {\n // set to the value of the inherited property in this theme.\n defineSmartGetter(themeNode, key, () => deepGet(this.theme, defNode.$value.split('.')));\n }\n\n // If the property type is literal...\n else if (defNode.$type === 'literal') {\n // set to the value listed in the definition.\n themeNode[key] = defNode.$value;\n }\n });\n\n return themeNode;\n };\n\n return constructForNode() as ToThemeIFace<Definition>;\n }\n\n constructor({\n theme = {} as SettableTheme<Definition>,\n parent,\n definition\n }:\n | {\n theme?: SettableTheme<Definition>;\n parent: ThemeMachineLike<Definition>;\n definition?: never;\n }\n | { theme?: SettableTheme<Definition>; parent?: never; definition: Definition }) {\n this.parent = parent ?? null;\n this.definition = parent ? parent.definition : definition;\n this.overrides = new Map();\n this.theme = this.constructTheme(theme);\n }\n}\n\nexport default ThemeMachine;\n"]}
|