@pega/cosmos-react-core 3.0.0-dev.4.0 → 3.0.0-dev.4.1
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/FieldGroup/FieldGroup.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.js +10 -2
- package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.js +16 -13
- package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts +6 -0
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.js +110 -0
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts +4 -0
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.styles.js +29 -0
- package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts +73 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.types.js +2 -0
- package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -0
- package/lib/components/ListToolbar/QueryOptionPopover.d.ts +12 -0
- package/lib/components/ListToolbar/QueryOptionPopover.d.ts.map +1 -0
- package/lib/components/ListToolbar/QueryOptionPopover.js +66 -0
- package/lib/components/ListToolbar/QueryOptionPopover.js.map +1 -0
- package/lib/components/ListToolbar/index.d.ts +3 -0
- package/lib/components/ListToolbar/index.d.ts.map +1 -0
- package/lib/components/ListToolbar/index.js +2 -0
- package/lib/components/ListToolbar/index.js.map +1 -0
- package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
- package/lib/components/MenuButton/MenuButton.js +1 -0
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/Popover/Popover.styles.d.ts.map +1 -1
- package/lib/components/Popover/Popover.styles.js +2 -2
- package/lib/components/Popover/Popover.styles.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +22 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +22 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +23 -0
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +44 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroup.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,iBAAiB,EAAmB,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASjG,OAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMtD,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,sCAAsC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAChC,2CAA2C;IAC3C,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;CAChC;AAQD,eAAO,MAAM,sBAAsB;UAAyB,OAAO;
|
|
1
|
+
{"version":3,"file":"FieldGroup.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,iBAAiB,EAAmB,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASjG,OAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMtD,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,sCAAsC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAChC,2CAA2C;IAC3C,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;CAChC;AAQD,eAAO,MAAM,sBAAsB;UAAyB,OAAO;SAsClE,CAAC;AAIF,eAAO,MAAM,gBAAgB,8GAqC5B,CAAC;AAoBF,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAgEjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { forwardRef, useState } from 'react';
|
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import Button, { StyledButton } from '../Button';
|
|
5
5
|
import ExpandCollapse from '../ExpandCollapse';
|
|
6
|
-
import Flex from '../Flex';
|
|
6
|
+
import Flex, { StyledFlex } from '../Flex';
|
|
7
7
|
import HTML from '../HTML';
|
|
8
8
|
import Icon, { StyledIcon, registerIcon } from '../Icon';
|
|
9
9
|
import * as caretRightIcon from '../Icon/icons/caret-right.icon';
|
|
@@ -12,7 +12,7 @@ import { defaultThemeProp } from '../../theme';
|
|
|
12
12
|
import { useI18n, useUID } from '../../hooks';
|
|
13
13
|
import { calculateFontSize } from '../../styles';
|
|
14
14
|
registerIcon(caretRightIcon);
|
|
15
|
-
export const StyledFieldGroupLegend = styled.legend(({ open, theme: { base: { spacing, animation } } }) => css `
|
|
15
|
+
export const StyledFieldGroupLegend = styled.legend(({ open, theme: { base: { spacing, animation, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger } } } }) => css `
|
|
16
16
|
width: 100%;
|
|
17
17
|
margin-bottom: 0;
|
|
18
18
|
${open &&
|
|
@@ -31,6 +31,14 @@ export const StyledFieldGroupLegend = styled.legend(({ open, theme: { base: { sp
|
|
|
31
31
|
button[aria-expanded='false'] ${StyledIcon} {
|
|
32
32
|
transform: rotate(0);
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
> ${StyledFlex} {
|
|
36
|
+
min-height: ${hitAreaMouse};
|
|
37
|
+
|
|
38
|
+
@media (pointer: 'coarse') {
|
|
39
|
+
min-height: ${hitAreaFinger};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
34
42
|
`);
|
|
35
43
|
StyledFieldGroupLegend.defaultProps = defaultThemeProp;
|
|
36
44
|
export const StyledFieldGroup = styled.fieldset(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale }, components: { text } } }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAsD,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,I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O,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;oBACvB,CAAC,mBACc,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,gBAC1B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,YAE7D,MAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAC/D,WAAW,EAAC,MAAM,aAElB,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,WAAG,EAC3B,yBAAO,IAAI,WAAQ,YACd,WACA,CACV,CAAC,CAAC,CAAC,CACF,yBAAO,IAAI,WAAQ,CACpB,WACgB,CACpB,EACA,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,cAAc,IAAC,SAAS,EAAE,CAAC,IAAI,YAAG,eAAe,WAAkB,CACrE,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,YACgB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useState, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button, { StyledButton } from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex, { StyledFlex } from '../Flex';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport Actions, { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, FontSize } from '../../styles';\n\nregisterIcon(caretRightIcon);\n\nexport interface FieldGroupProps extends BaseProps {\n /** The content of the Field Group. */\n children: ReactNode;\n /** A description of the field group to be displayed above the controls. */\n description?: string;\n /**\n * If true, the Field Group will be able to collapse the content of its children by clicking on the name.\n * @default false\n */\n collapsible?: boolean;\n /**\n * If true, the Field Group will be collapsed on the first render.\n * @default false\n */\n defaultCollapsed?: boolean;\n /** The name associated with the Field Group. */\n name?: string;\n /** An array of actions to add to the header. */\n actions?: ActionsProps['items'];\n /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n}\n\ninterface FieldGroupLegendProps {\n open: boolean;\n actions?: ActionsProps['items'];\n children?: ReactNode;\n}\n\nexport const StyledFieldGroupLegend = styled.legend<{ open: boolean }>(\n ({\n open,\n theme: {\n base: {\n spacing,\n animation,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n }\n }\n }) => css`\n width: 100%;\n margin-bottom: 0;\n ${open &&\n css`\n margin-block-end: calc(1.5 * ${spacing});\n `}\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n\n button ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n\n button[aria-expanded='true'] ${StyledIcon} {\n transform: rotate(90deg);\n }\n button[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(0);\n }\n\n > ${StyledFlex} {\n min-height: ${hitAreaMouse};\n\n @media (pointer: 'coarse') {\n min-height: ${hitAreaFinger};\n }\n }\n `\n);\n\nStyledFieldGroupLegend.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroup = styled.fieldset(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale },\n components: { text }\n }\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n border: none;\n\n ${StyledFieldGroupLegend} ${StyledButton} {\n font-weight: inherit;\n }\n\n & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n }\n\n & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n }\n\n & & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n }\n\n & & & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n }\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nconst FieldGroupLegend: FunctionComponent<FieldGroupLegendProps> = ({\n children,\n open,\n actions,\n ...restProps\n}) => {\n return (\n <StyledFieldGroupLegend open={open} {...restProps}>\n <Flex container={{ alignItems: 'center', justify: 'between' }}>\n {children}\n {actions && <Actions items={actions} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nconst FieldGroup: FunctionComponent<FieldGroupProps & ForwardProps> = forwardRef(\n (\n {\n children,\n description,\n name,\n actions,\n collapsible = false,\n defaultCollapsed = false,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n ) => {\n const [open, setOpen] = useState(!defaultCollapsed);\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <Flex container={{ direction: 'column', gap: 3 }}>\n {description && <HTML id={`${uid}-description`} as='p' content={description} />}\n <div>{children}</div>\n </Flex>\n );\n\n return (\n <StyledFieldGroup\n aria-label={name}\n aria-describedby={description ? `${uid}-description` : undefined}\n {...restProps}\n ref={ref}\n >\n {name && (\n <FieldGroupLegend open={open} actions={actions}>\n {collapsible ? (\n <Button\n type='button'\n variant='text'\n onClick={() => {\n setOpen(cur => !cur);\n }}\n aria-expanded={open ? 'true' : 'false'}\n aria-label={t(open ? 'collapse_noun' : 'expand_noun', [name])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n <span>{name}</span>\n </Flex>\n </Button>\n ) : (\n <span>{name}</span>\n )}\n </FieldGroupLegend>\n )}\n {collapsible ? (\n <ExpandCollapse collapsed={!open}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n );\n }\n);\n\nexport default FieldGroup;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroupList.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA+B,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,OAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI3D,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAWD,eAAO,MAAM,cAAc,qJAe1B,CAAC;AAaF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"FieldGroupList.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA+B,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,OAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI3D,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAWD,eAAO,MAAM,cAAc,qJAe1B,CAAC;AAaF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA6CzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -33,19 +33,22 @@ StyledAddButton.defaultProps = defaultThemeProp;
|
|
|
33
33
|
const FieldGroupList = forwardRef(({ items, onAdd, onDelete, ...restProps }, ref) => {
|
|
34
34
|
const t = useI18n();
|
|
35
35
|
return (_jsxs(StyledFieldGroupList, { ref: ref, ...restProps, children: [items.map(({ id, children, name, ...restItemProps }) => {
|
|
36
|
-
return (_jsx(StyledListItem, { name: name, ...restItemProps, actions:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
return (_jsx(StyledListItem, { name: name, ...restItemProps, actions: onDelete
|
|
37
|
+
? [
|
|
38
|
+
{
|
|
39
|
+
id: 'delete',
|
|
40
|
+
text: t('delete'),
|
|
41
|
+
icon: 'trash',
|
|
42
|
+
iconOnly: true,
|
|
43
|
+
onClick: onDelete
|
|
44
|
+
? () => {
|
|
45
|
+
onDelete(id);
|
|
46
|
+
}
|
|
47
|
+
: undefined
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
: undefined, children: children }, id));
|
|
51
|
+
}), onAdd && (_jsxs(StyledAddButton, { variant: 'link', onClick: onAdd, children: [_jsx(Icon, { name: 'plus' }, void 0), " ", t('add')] }, void 0))] }, void 0));
|
|
49
52
|
});
|
|
50
53
|
export default FieldGroupList;
|
|
51
54
|
//# sourceMapping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C,CAAC;4BACE;gCACE,EAAE,EAAE,QAAQ;gCACZ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC;gCACjB,IAAI,EAAE,OAAO;gCACb,QAAQ,EAAE,IAAI;gCACd,OAAO,EAAE,QAAQ;oCACf,CAAC,CAAC,GAAG,EAAE;wCACH,QAAQ,CAAC,EAAE,CAAC,CAAC;oCACf,CAAC;oCACH,CAAC,CAAC,SAAS;6BACd;yBACF;wBACH,CAAC,CAAC,SAAS,YAGd,QAAQ,IArBJ,EAAE,CAsBQ,CAClB,CAAC;YACJ,CAAC,CAAC,EACD,KAAK,IAAI,CACR,MAAC,eAAe,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,KAAK,aAC5C,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,WAAG,OAAE,CAAC,CAAC,KAAK,CAAC,YACd,CACnB,YACoB,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport { useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\n\nimport FieldGroup, { FieldGroupProps } from './FieldGroup';\n\nregisterIcon(plusIcon);\n\nexport interface FieldGroupListItemProps extends FieldGroupProps {\n /** The ID of the field group list item */\n id: string;\n}\n\nexport interface FieldGroupListProps {\n items: FieldGroupListItemProps[];\n onAdd?: () => void;\n onDelete?: (id: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledFieldGroupList = styled.div(\n ({ theme }) =>\n css`\n margin-top: ${theme.base.spacing};\n `\n);\n\nStyledFieldGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledListItem = styled(FieldGroup)(\n ({ theme }) =>\n css`\n padding: ${theme.base.spacing} 0 calc(2 * ${theme.base.spacing});\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n margin-bottom: calc(2 * ${theme.base.spacing});\n\n legend {\n margin-bottom: -${theme.base.spacing};\n }\n\n & > * {\n margin: ${theme.base.spacing} 0;\n }\n `\n);\n\nStyledListItem.defaultProps = defaultThemeProp;\n\nconst StyledAddButton = styled(Button)(\n ({ theme }) =>\n css`\n margin-top: ${theme.base.spacing};\n `\n);\n\nStyledAddButton.defaultProps = defaultThemeProp;\n\nconst FieldGroupList: FunctionComponent<FieldGroupListProps & ForwardProps> = forwardRef(\n (\n { items, onAdd, onDelete, ...restProps }: PropsWithoutRef<FieldGroupListProps>,\n ref: FieldGroupListProps['ref']\n ) => {\n const t = useI18n();\n\n return (\n <StyledFieldGroupList ref={ref} {...restProps}>\n {items.map(({ id, children, name, ...restItemProps }: FieldGroupListItemProps) => {\n return (\n <StyledListItem\n key={id}\n name={name}\n {...restItemProps}\n actions={\n onDelete\n ? [\n {\n id: 'delete',\n text: t('delete'),\n icon: 'trash',\n iconOnly: true,\n onClick: onDelete\n ? () => {\n onDelete(id);\n }\n : undefined\n }\n ]\n : undefined\n }\n >\n {children}\n </StyledListItem>\n );\n })}\n {onAdd && (\n <StyledAddButton variant='link' onClick={onAdd}>\n <Icon name='plus' /> {t('add')}\n </StyledAddButton>\n )}\n </StyledFieldGroupList>\n );\n }\n);\n\nexport default FieldGroupList;\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { ForwardProps } from '../../types';
|
|
3
|
+
import { ListToolbarProps } from './ListToolbar.types';
|
|
4
|
+
declare const ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps>;
|
|
5
|
+
export default ListToolbar;
|
|
6
|
+
//# sourceMappingURL=ListToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAe3C,OAAO,EACL,gBAAgB,EAKjB,MAAM,qBAAqB,CAAC;AA2G7B,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAqJnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import Actions from '../Actions';
|
|
4
|
+
import Text from '../Text';
|
|
5
|
+
import Button from '../Button';
|
|
6
|
+
import { useBreakpoint, useI18n } from '../../hooks';
|
|
7
|
+
import Flex from '../Flex';
|
|
8
|
+
import SearchInput from '../SearchInput';
|
|
9
|
+
import Icon, { registerIcon } from '../Icon';
|
|
10
|
+
import * as filterIcon from '../Icon/icons/filter.icon';
|
|
11
|
+
import * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';
|
|
12
|
+
import * as rowIcon from '../Icon/icons/row.icon';
|
|
13
|
+
import * as plusIcon from '../Icon/icons/plus.icon';
|
|
14
|
+
import * as moreIcon from '../Icon/icons/more.icon';
|
|
15
|
+
import { hasProp } from '../../utils';
|
|
16
|
+
import MenuButton from '../MenuButton';
|
|
17
|
+
import { Count } from '../Badges';
|
|
18
|
+
import { StyledViewSelector, StyledSearchForm, StyledListToolbar } from './ListToolbar.styles';
|
|
19
|
+
import QueryOptionPopover from './QueryOptionPopover';
|
|
20
|
+
registerIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);
|
|
21
|
+
const CountMeta = ({ count }) => {
|
|
22
|
+
const t = useI18n();
|
|
23
|
+
return (_jsxs(Text, { variant: 'secondary', children: [count.total !== undefined && t('results_count', [count.total], { count: count.total }), count.total && count.selected && ' ', count.selected !== undefined &&
|
|
24
|
+
`(${t('selected_count', [count.selected], { count: count.selected })})`] }, void 0));
|
|
25
|
+
};
|
|
26
|
+
const QueryOptionButton = ({ id, queryOptionProps, iconOnly, setCurrentQueryOption }) => {
|
|
27
|
+
const t = useI18n();
|
|
28
|
+
let i18nKey;
|
|
29
|
+
let icon;
|
|
30
|
+
if (id === 'filter') {
|
|
31
|
+
i18nKey = 'filter';
|
|
32
|
+
icon = 'filter';
|
|
33
|
+
}
|
|
34
|
+
else if (id === 'sort') {
|
|
35
|
+
i18nKey = 'sort';
|
|
36
|
+
icon = 'arrow-up-down';
|
|
37
|
+
}
|
|
38
|
+
else if (id === 'group') {
|
|
39
|
+
i18nKey = 'group';
|
|
40
|
+
icon = 'row';
|
|
41
|
+
}
|
|
42
|
+
const text = t(i18nKey);
|
|
43
|
+
const variant = iconOnly ? 'simple' : 'text';
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!queryOptionProps || !hasProp(queryOptionProps, 'renderer')) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setCurrentQueryOption(cur => {
|
|
49
|
+
if (!cur)
|
|
50
|
+
return null;
|
|
51
|
+
return {
|
|
52
|
+
...cur,
|
|
53
|
+
props: queryOptionProps
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}, [queryOptionProps, setCurrentQueryOption]);
|
|
57
|
+
if (hasProp(queryOptionProps, 'renderer')) {
|
|
58
|
+
return (_jsx("div", { children: _jsx(Button, { variant: variant, icon: iconOnly, label: iconOnly ? text : undefined, onClick: (e) => {
|
|
59
|
+
setCurrentQueryOption({
|
|
60
|
+
id,
|
|
61
|
+
props: queryOptionProps,
|
|
62
|
+
popoverTarget: e.currentTarget
|
|
63
|
+
});
|
|
64
|
+
}, children: _jsxs(Flex, { container: { inline: true, alignItems: 'center', gap: 1 }, as: 'span', children: [_jsx(Icon, { name: icon }, void 0), !iconOnly && text, !iconOnly && queryOptionProps.count && _jsx(Count, { children: queryOptionProps.count }, void 0)] }, void 0) }, void 0) }, void 0));
|
|
65
|
+
}
|
|
66
|
+
if (hasProp(queryOptionProps, 'items')) {
|
|
67
|
+
return (_jsx("div", { children: _jsx(MenuButton, { variant: variant, text: text, icon: icon, iconOnly: iconOnly, count: queryOptionProps.count, menu: {
|
|
68
|
+
mode: queryOptionProps.mode,
|
|
69
|
+
items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),
|
|
70
|
+
onItemClick: queryOptionProps.onItemClick
|
|
71
|
+
} }, void 0) }, void 0));
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
const ListToolbar = forwardRef(({ heading, onCreateNew, search, count, filter, sort, group, actions }, ref) => {
|
|
76
|
+
const t = useI18n();
|
|
77
|
+
const isSmallOrAbove = useBreakpoint('sm');
|
|
78
|
+
const isMediumOrAbove = useBreakpoint('md');
|
|
79
|
+
const actionsButtonRef = useRef(null);
|
|
80
|
+
const [queryOptionDialogState, setQueryOptionDialogState] = useState(null);
|
|
81
|
+
const createNewButton = useMemo(() => {
|
|
82
|
+
if (!onCreateNew)
|
|
83
|
+
return null;
|
|
84
|
+
const text = t('create_new');
|
|
85
|
+
return (_jsx(Button, { variant: isSmallOrAbove ? 'secondary' : 'simple', icon: !isSmallOrAbove, label: isSmallOrAbove ? undefined : text, onClick: onCreateNew, children: _jsxs(Flex, { as: 'span', container: { inline: true, alignItems: 'center', gap: 1 }, children: [_jsx(Icon, { name: 'plus' }, void 0), isSmallOrAbove && _jsx("span", { children: text }, void 0)] }, void 0) }, void 0));
|
|
86
|
+
}, [t, onCreateNew, isSmallOrAbove]);
|
|
87
|
+
const filterButton = filter && (_jsx(QueryOptionButton, { id: 'filter', queryOptionProps: filter, iconOnly: !isMediumOrAbove, setCurrentQueryOption: setQueryOptionDialogState }, void 0));
|
|
88
|
+
const sortButton = sort && (_jsx(QueryOptionButton, { id: 'sort', queryOptionProps: sort, iconOnly: !isMediumOrAbove, setCurrentQueryOption: setQueryOptionDialogState }, void 0));
|
|
89
|
+
const groupButton = group && (_jsx(QueryOptionButton, { id: 'group', queryOptionProps: group, iconOnly: !isMediumOrAbove, setCurrentQueryOption: setQueryOptionDialogState }, void 0));
|
|
90
|
+
const onQueryOptionCancel = useCallback(() => {
|
|
91
|
+
if (queryOptionDialogState?.props.onCancel() === false)
|
|
92
|
+
return;
|
|
93
|
+
setQueryOptionDialogState(null);
|
|
94
|
+
}, [queryOptionDialogState]);
|
|
95
|
+
const onQueryOptionSubmit = useCallback(() => {
|
|
96
|
+
if (queryOptionDialogState?.props.onSubmit() === false)
|
|
97
|
+
return;
|
|
98
|
+
setQueryOptionDialogState(null);
|
|
99
|
+
}, [queryOptionDialogState]);
|
|
100
|
+
return (_jsxs(Flex, { as: StyledListToolbar, container: { direction: 'column', gap: 2 }, item: { grow: 1 }, ref: ref, children: [_jsxs(Flex, { container: { alignItems: 'center', justify: 'between' }, children: [typeof heading === 'string' ? (_jsx(Text, { variant: 'h3', children: heading }, void 0)) : (_jsx(StyledViewSelector, { variant: 'text', text: heading.views.find(view => view.selected)?.text ?? heading.views[0].text, menu: {
|
|
101
|
+
mode: 'single-select',
|
|
102
|
+
items: heading.views.map(view => ({ ...view, primary: view.text })),
|
|
103
|
+
onItemClick: heading.onViewSelect
|
|
104
|
+
} }, void 0)), createNewButton] }, void 0), _jsxs(Flex, { container: { alignItems: 'start', justify: 'between', gap: 2 }, children: [_jsxs(Flex, { as: StyledSearchForm, container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, item: { grow: 1 }, children: [search && _jsx(SearchInput, { ...search }, void 0), isSmallOrAbove && count && _jsx(CountMeta, { count: count }, void 0)] }, void 0), (filterButton || sortButton || groupButton || actions) && (_jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, md: { container: { gap: 3 } }, children: [_jsxs(_Fragment, { children: [filterButton, sortButton, groupButton] }, void 0), actions && (_jsx(Actions, { items: actions.map(({ icon, ...restProps }) => ({
|
|
105
|
+
visual: icon ? _jsx(Icon, { name: icon }, void 0) : undefined,
|
|
106
|
+
...restProps
|
|
107
|
+
})), menuAt: 1, ref: actionsButtonRef }, void 0))] }, void 0))] }, void 0), !isSmallOrAbove && count && (_jsx(Flex, { container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, children: _jsx(CountMeta, { count: count }, void 0) }, void 0)), queryOptionDialogState && (_jsx(QueryOptionPopover, { target: queryOptionDialogState.popoverTarget, heading: t(`${queryOptionDialogState.id}_by`), onCancel: onQueryOptionCancel, onSubmit: onQueryOptionSubmit, children: _jsx(queryOptionDialogState.props.renderer, {}, void 0) }, void 0))] }, void 0));
|
|
108
|
+
});
|
|
109
|
+
export default ListToolbar;
|
|
110
|
+
//# sourceMappingURL=ListToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListToolbar.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAKV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,eAAe,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CA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IAAI,KAAK,IAAI,CAC3B,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,YAC7D,KAAC,SAAS,IAAC,KAAK,EAAE,KAAK,WAAI,WACtB,CACR,EAEA,sBAAsB,IAAI,CACzB,KAAC,kBAAkB,IACjB,MAAM,EAAE,sBAAsB,CAAC,aAAa,EAC5C,OAAO,EAAE,CAAC,CAAC,GAAG,sBAAsB,CAAC,EAAE,KAAK,CAAC,EAC7C,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,mBAAmB,YAE7B,KAAC,sBAAsB,CAAC,KAAK,CAAC,QAAQ,aAAG,WACtB,CACtB,YACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n Dispatch,\n forwardRef,\n FunctionComponent,\n MouseEvent,\n PropsWithoutRef,\n SetStateAction,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport Actions from '../Actions';\nimport Text from '../Text';\nimport Button from '../Button';\nimport { ForwardProps } from '../../types';\nimport { useBreakpoint, useI18n } from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp } from '../../utils';\nimport MenuButton from '../MenuButton';\nimport { Count } from '../Badges';\n\nimport { StyledViewSelector, StyledSearchForm, StyledListToolbar } from './ListToolbar.styles';\nimport {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionDialogState,\n QueryOptionId\n} from './ListToolbar.types';\nimport QueryOptionPopover from './QueryOptionPopover';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({ count }: { count: NonNullable<ListToolbarProps['count']> }) => {\n const t = useI18n();\n return (\n <Text variant='secondary'>\n {count.total !== undefined && t('results_count', [count.total], { count: count.total })}\n {count.total && count.selected && ' '}\n {count.selected !== undefined &&\n `(${t('selected_count', [count.selected], { count: count.selected })})`}\n </Text>\n );\n};\n\nconst QueryOptionButton = ({\n id,\n queryOptionProps,\n iconOnly,\n setCurrentQueryOption\n}: {\n id: QueryOptionId;\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps;\n iconOnly: boolean;\n setCurrentQueryOption: Dispatch<SetStateAction<QueryOptionDialogState>>;\n}) => {\n const t = useI18n();\n let i18nKey!: 'filter' | 'sort' | 'group';\n let icon!: 'filter' | 'arrow-up-down' | 'row';\n\n if (id === 'filter') {\n i18nKey = 'filter';\n icon = 'filter';\n } else if (id === 'sort') {\n i18nKey = 'sort';\n icon = 'arrow-up-down';\n } else if (id === 'group') {\n i18nKey = 'group';\n icon = 'row';\n }\n\n const text = t(i18nKey);\n const variant = iconOnly ? 'simple' : 'text';\n\n useEffect(() => {\n if (!queryOptionProps || !hasProp(queryOptionProps, 'renderer')) {\n return;\n }\n\n setCurrentQueryOption(cur => {\n if (!cur) return null;\n return {\n ...cur,\n props: queryOptionProps\n };\n });\n }, [queryOptionProps, setCurrentQueryOption]);\n\n if (hasProp(queryOptionProps, 'renderer')) {\n return (\n <div>\n <Button\n variant={variant}\n icon={iconOnly}\n label={iconOnly ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n setCurrentQueryOption({\n id,\n props: queryOptionProps,\n popoverTarget: e.currentTarget\n });\n }}\n >\n <Flex container={{ inline: true, alignItems: 'center', gap: 1 }} as='span'>\n <Icon name={icon} />\n {!iconOnly && text}\n {!iconOnly && queryOptionProps.count && <Count>{queryOptionProps.count}</Count>}\n </Flex>\n </Button>\n </div>\n );\n }\n\n if (hasProp(queryOptionProps, 'items')) {\n return (\n <div>\n <MenuButton\n variant={variant}\n text={text}\n icon={icon}\n iconOnly={iconOnly}\n count={queryOptionProps.count}\n menu={{\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }}\n />\n </div>\n );\n }\n\n return null;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n (\n {\n heading,\n onCreateNew,\n search,\n count,\n filter,\n sort,\n group,\n actions\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) => {\n const t = useI18n();\n const isSmallOrAbove = useBreakpoint('sm');\n const isMediumOrAbove = useBreakpoint('md');\n const actionsButtonRef = useRef<HTMLButtonElement>(null);\n\n const [queryOptionDialogState, setQueryOptionDialogState] =\n useState<QueryOptionDialogState>(null);\n\n const createNewButton = useMemo(() => {\n if (!onCreateNew) return null;\n const text = t('create_new');\n\n return (\n <Button\n variant={isSmallOrAbove ? 'secondary' : 'simple'}\n icon={!isSmallOrAbove}\n label={isSmallOrAbove ? undefined : text}\n onClick={onCreateNew}\n >\n <Flex as='span' container={{ inline: true, alignItems: 'center', gap: 1 }}>\n <Icon name='plus' />\n {isSmallOrAbove && <span>{text}</span>}\n </Flex>\n </Button>\n );\n }, [t, onCreateNew, isSmallOrAbove]);\n\n const filterButton = filter && (\n <QueryOptionButton\n id='filter'\n queryOptionProps={filter}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const sortButton = sort && (\n <QueryOptionButton\n id='sort'\n queryOptionProps={sort}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const groupButton = group && (\n <QueryOptionButton\n id='group'\n queryOptionProps={group}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const onQueryOptionCancel = useCallback(() => {\n if (queryOptionDialogState?.props.onCancel() === false) return;\n setQueryOptionDialogState(null);\n }, [queryOptionDialogState]);\n\n const onQueryOptionSubmit = useCallback(() => {\n if (queryOptionDialogState?.props.onSubmit() === false) return;\n setQueryOptionDialogState(null);\n }, [queryOptionDialogState]);\n\n return (\n <Flex\n as={StyledListToolbar}\n container={{ direction: 'column', gap: 2 }}\n item={{ grow: 1 }}\n ref={ref}\n >\n <Flex container={{ alignItems: 'center', justify: 'between' }}>\n {typeof heading === 'string' ? (\n <Text variant='h3'>{heading}</Text>\n ) : (\n <StyledViewSelector\n variant='text'\n text={heading.views.find(view => view.selected)?.text ?? heading.views[0].text}\n menu={{\n mode: 'single-select',\n items: heading.views.map(view => ({ ...view, primary: view.text })),\n onItemClick: heading.onViewSelect\n }}\n />\n )}\n {createNewButton}\n </Flex>\n <Flex container={{ alignItems: 'start', justify: 'between', gap: 2 }}>\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 2 }}\n item={{ grow: 1 }}\n >\n {search && <SearchInput {...search} />}\n {isSmallOrAbove && count && <CountMeta count={count} />}\n </Flex>\n {(filterButton || sortButton || groupButton || actions) && (\n <Flex container={{ alignItems: 'center', gap: 1 }} md={{ container: { gap: 3 } }}>\n <>\n {filterButton}\n {sortButton}\n {groupButton}\n </>\n {actions && (\n <Actions\n items={actions.map(({ icon, ...restProps }) => ({\n visual: icon ? <Icon name={icon} /> : undefined,\n ...restProps\n }))}\n menuAt={1}\n ref={actionsButtonRef}\n />\n )}\n </Flex>\n )}\n </Flex>\n {!isSmallOrAbove && count && (\n <Flex container={{ alignItems: 'center', wrap: 'wrap', gap: 2 }}>\n <CountMeta count={count} />\n </Flex>\n )}\n\n {queryOptionDialogState && (\n <QueryOptionPopover\n target={queryOptionDialogState.popoverTarget}\n heading={t(`${queryOptionDialogState.id}_by`)}\n onCancel={onQueryOptionCancel}\n onSubmit={onQueryOptionSubmit}\n >\n <queryOptionDialogState.props.renderer />\n </QueryOptionPopover>\n )}\n </Flex>\n );\n }\n);\n\nexport default ListToolbar;\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const StyledSearchForm: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const StyledViewSelector: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../..").ForwardProps & import("../MenuButton").MenuButtonProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const StyledListToolbar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
//# sourceMappingURL=ListToolbar.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListToolbar.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB,yGAK5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,6MAS7B,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAI7B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { StyledSearchInput } from '../SearchInput';
|
|
3
|
+
import MenuButton from '../MenuButton';
|
|
4
|
+
import { StyledText } from '../Text';
|
|
5
|
+
import { defaultThemeProp } from '../../theme';
|
|
6
|
+
import { calculateFontSize } from '../../styles';
|
|
7
|
+
import { StyledButton } from '../Button';
|
|
8
|
+
export const StyledSearchForm = styled.div `
|
|
9
|
+
${StyledSearchInput} {
|
|
10
|
+
flex-grow: 1;
|
|
11
|
+
max-width: min(100%, 40ch);
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
export const StyledViewSelector = styled(MenuButton)(({ theme }) => {
|
|
15
|
+
const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);
|
|
16
|
+
return css `
|
|
17
|
+
${StyledText} {
|
|
18
|
+
font-size: ${fontSizes[theme.components.text.h3['font-size']]};
|
|
19
|
+
font-weight: ${theme.components.text.h3['font-weight']};
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
});
|
|
23
|
+
StyledViewSelector.defaultProps = defaultThemeProp;
|
|
24
|
+
export const StyledListToolbar = styled.div `
|
|
25
|
+
${StyledButton} + ${StyledButton} {
|
|
26
|
+
margin-inline-start: 0;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
//# sourceMappingURL=ListToolbar.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListToolbar.styles.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;IACtC,iBAAiB;;;;CAIpB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACjE,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEvF,OAAO,GAAG,CAAA;MACN,UAAU;mBACG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAa,CAAC;qBAC1D,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;;GAEzD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;IACvC,YAAY,MAAM,YAAY;;;CAGjC,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { StyledSearchInput } from '../SearchInput';\nimport MenuButton from '../MenuButton';\nimport { StyledText } from '../Text';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { StyledButton } from '../Button';\n\nexport const StyledSearchForm = styled.div`\n ${StyledSearchInput} {\n flex-grow: 1;\n max-width: min(100%, 40ch);\n }\n`;\n\nexport const StyledViewSelector = styled(MenuButton)(({ theme }) => {\n const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n ${StyledText} {\n font-size: ${fontSizes[theme.components.text.h3['font-size'] as FontSize]};\n font-weight: ${theme.components.text.h3['font-weight']};\n }\n `;\n});\n\nStyledViewSelector.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbar = styled.div`\n ${StyledButton} + ${StyledButton} {\n margin-inline-start: 0;\n }\n`;\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { MouseEvent, Ref, ComponentType } from 'react';
|
|
2
|
+
import { SearchInputProps } from '../SearchInput';
|
|
3
|
+
import { MenuProps } from '../Menu';
|
|
4
|
+
import { Action, BaseProps } from '../../types';
|
|
5
|
+
export interface ViewSelectorProps {
|
|
6
|
+
/** A list of pre-defined data views. */
|
|
7
|
+
views: {
|
|
8
|
+
id: string;
|
|
9
|
+
text: string;
|
|
10
|
+
selected: boolean;
|
|
11
|
+
}[];
|
|
12
|
+
/** Called when a view is selected. */
|
|
13
|
+
onViewSelect: MenuProps['onItemClick'];
|
|
14
|
+
}
|
|
15
|
+
export interface QueryOption {
|
|
16
|
+
/** A count representing the number of applied conditions within the query option. */
|
|
17
|
+
count?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface QueryOptionDialogProps extends QueryOption {
|
|
20
|
+
/** A component to render the content portion of the query option dialog. */
|
|
21
|
+
renderer: ComponentType;
|
|
22
|
+
/**
|
|
23
|
+
* Called when the user explicitly or implicitly cancels(closes) the query dialog.
|
|
24
|
+
* Returning false will block the dialog from closing.
|
|
25
|
+
*/
|
|
26
|
+
onCancel: () => boolean | void;
|
|
27
|
+
/**
|
|
28
|
+
* Called when the user explicitly applies the query option conditions.
|
|
29
|
+
* Returning false will block the dialog from closing.
|
|
30
|
+
*/
|
|
31
|
+
onSubmit: () => boolean | void;
|
|
32
|
+
}
|
|
33
|
+
/** Optionally provide query option presets. */
|
|
34
|
+
export interface PresetMenuProps extends QueryOption {
|
|
35
|
+
mode?: Exclude<MenuProps['mode'], 'action'>;
|
|
36
|
+
items: {
|
|
37
|
+
id: string;
|
|
38
|
+
text: string;
|
|
39
|
+
selected: boolean;
|
|
40
|
+
icon?: string;
|
|
41
|
+
}[];
|
|
42
|
+
onItemClick: MenuProps['onItemClick'];
|
|
43
|
+
}
|
|
44
|
+
export declare type QueryOptionId = 'filter' | 'sort' | 'group';
|
|
45
|
+
export declare type QueryOptionDialogState = {
|
|
46
|
+
id: 'filter' | 'sort' | 'group';
|
|
47
|
+
props: QueryOptionDialogProps;
|
|
48
|
+
popoverTarget: HTMLButtonElement | null;
|
|
49
|
+
} | null;
|
|
50
|
+
export interface ListToolbarProps extends BaseProps {
|
|
51
|
+
/** Rendering a simple heading or view selection menu.. */
|
|
52
|
+
heading: string | ViewSelectorProps;
|
|
53
|
+
/** Callback that will render a Create new button and is fired when that button is clicked. */
|
|
54
|
+
onCreateNew?: (e: MouseEvent) => void;
|
|
55
|
+
/** Props related to the Search Input. */
|
|
56
|
+
search?: SearchInputProps;
|
|
57
|
+
/** Total returned results related for a given search. Optional indication of a selected item count. */
|
|
58
|
+
count?: {
|
|
59
|
+
total?: number;
|
|
60
|
+
selected?: number;
|
|
61
|
+
};
|
|
62
|
+
/** Custom Rendering or available presets for filtering. */
|
|
63
|
+
filter?: QueryOptionDialogProps | PresetMenuProps;
|
|
64
|
+
/** Custom Rendering or available presets for sorting. */
|
|
65
|
+
sort?: QueryOptionDialogProps | PresetMenuProps;
|
|
66
|
+
/** Custom Rendering or available presets for grouping. */
|
|
67
|
+
group?: QueryOptionDialogProps | PresetMenuProps;
|
|
68
|
+
/** Top level dataset actions. */
|
|
69
|
+
actions?: Action[];
|
|
70
|
+
/** Ref for the wrapping element. */
|
|
71
|
+
ref?: Ref<HTMLDivElement>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=ListToolbar.types.d.ts.map
|
|
@@ -0,0 +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,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IACzD,sCAAsC;IACtC,YAAY,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;CACxC;AACD,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,4EAA4E;IAC5E,QAAQ,EAAE,aAAa,CAAC;IACxB;;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C1D,KAAK,CAAC,EAAE,sBAAsB,GAAG,eAAe,CAAC;IACjD,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListToolbar.types.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.types.ts"],"names":[],"mappings":"","sourcesContent":["import { MouseEvent, Ref, ComponentType } from 'react';\n\nimport { SearchInputProps } from '../SearchInput';\nimport { MenuProps } from '../Menu';\nimport { Action, BaseProps } from '../../types';\n\nexport interface ViewSelectorProps {\n /** A list of pre-defined data views. */\n views: { id: string; text: string; selected: boolean }[];\n /** Called when a view is selected. */\n onViewSelect: MenuProps['onItemClick'];\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?: Exclude<MenuProps['mode'], 'action'>;\n items: { id: string; text: string; selected: boolean; icon?: string }[];\n onItemClick: MenuProps['onItemClick'];\n}\nexport type QueryOptionId = 'filter' | 'sort' | 'group';\n\nexport type QueryOptionDialogState = {\n id: 'filter' | 'sort' | 'group';\n props: QueryOptionDialogProps;\n popoverTarget: HTMLButtonElement | null;\n} | null;\n\nexport interface ListToolbarProps extends BaseProps {\n /** Rendering a simple heading or view selection menu.. */\n heading: string | ViewSelectorProps;\n /** Callback that will render a Create new button and is fired when that button is clicked. */\n onCreateNew?: (e: MouseEvent) => void;\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 selected?: number;\n };\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 wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
import { ForwardProps, OmitStrict } from '../../types';
|
|
3
|
+
import { PopoverProps } from '../Popover';
|
|
4
|
+
import { QueryOptionDialogProps } from './ListToolbar.types';
|
|
5
|
+
interface ListToolbarPopoverProps extends OmitStrict<PopoverProps, 'target'>, Pick<QueryOptionDialogProps, 'onCancel' | 'onSubmit'> {
|
|
6
|
+
heading: string;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
target?: HTMLButtonElement | null;
|
|
9
|
+
}
|
|
10
|
+
declare const QueryOptionPopover: FunctionComponent<ListToolbarPopoverProps & ForwardProps>;
|
|
11
|
+
export default QueryOptionPopover;
|
|
12
|
+
//# sourceMappingURL=QueryOptionPopover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryOptionPopover.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/QueryOptionPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,SAAS,EAGV,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIvD,OAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,UAAU,uBACR,SAAQ,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,EACxC,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,UAAU,CAAC;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACnC;AAMD,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,GAAG,YAAY,CAiGjF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useCallback } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { useConsolidatedRef, useI18n, useOuterEvent, useUID } from '../../hooks';
|
|
5
|
+
import { getFocusables } from '../../utils';
|
|
6
|
+
import Button from '../Button';
|
|
7
|
+
import Flex from '../Flex';
|
|
8
|
+
import Popover from '../Popover';
|
|
9
|
+
import Text from '../Text';
|
|
10
|
+
const StyledQueryListPopover = styled(Popover) `
|
|
11
|
+
min-width: 40ch;
|
|
12
|
+
`;
|
|
13
|
+
const QueryOptionPopover = forwardRef(({ target, heading, children, onCancel, onSubmit }, ref) => {
|
|
14
|
+
const t = useI18n();
|
|
15
|
+
const headingId = useUID();
|
|
16
|
+
const popoverRef = useConsolidatedRef(ref);
|
|
17
|
+
const onKeydown = useCallback((e) => {
|
|
18
|
+
if (e.repeat)
|
|
19
|
+
return;
|
|
20
|
+
if (e.key === 'Escape') {
|
|
21
|
+
onCancel();
|
|
22
|
+
target?.focus();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (e.key === 'Tab') {
|
|
26
|
+
const focusables = getFocusables(popoverRef);
|
|
27
|
+
if (!focusables || focusables.length < 2)
|
|
28
|
+
return;
|
|
29
|
+
const firstFocusable = focusables[0];
|
|
30
|
+
const lastFocusable = focusables[focusables.length - 1];
|
|
31
|
+
if (!e.shiftKey &&
|
|
32
|
+
(document.activeElement === popoverRef.current ||
|
|
33
|
+
document.activeElement === lastFocusable)) {
|
|
34
|
+
firstFocusable?.focus();
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
}
|
|
37
|
+
else if (e.shiftKey &&
|
|
38
|
+
(document.activeElement === popoverRef.current ||
|
|
39
|
+
document.activeElement === firstFocusable)) {
|
|
40
|
+
lastFocusable?.focus();
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, [onCancel, popoverRef, target]);
|
|
45
|
+
useOuterEvent('mousedown', [popoverRef], () => {
|
|
46
|
+
onCancel();
|
|
47
|
+
});
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
document.addEventListener('keydown', onKeydown);
|
|
50
|
+
return () => {
|
|
51
|
+
document.removeEventListener('keydown', onKeydown);
|
|
52
|
+
};
|
|
53
|
+
}, [onKeydown]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
getFocusables(popoverRef)[0]?.focus();
|
|
56
|
+
}, [popoverRef]);
|
|
57
|
+
return (_jsx(StyledQueryListPopover, { target: target, ref: popoverRef, role: 'dialog', "aria-labelledby": headingId, arrow: true, onKeyDown: onKeydown, children: _jsxs(Flex, { container: { direction: 'column', gap: 2, pad: 2 }, children: [_jsx(Text, { variant: 'h3', id: headingId, children: heading }, void 0), children, _jsxs(Flex, { container: { justify: 'between' }, children: [_jsx(Button, { onClick: () => {
|
|
58
|
+
onCancel();
|
|
59
|
+
target?.focus();
|
|
60
|
+
}, children: t('cancel') }, void 0), _jsx(Button, { variant: 'primary', onClick: () => {
|
|
61
|
+
onSubmit();
|
|
62
|
+
target?.focus();
|
|
63
|
+
}, children: t('submit') }, void 0)] }, void 0)] }, void 0) }, void 0));
|
|
64
|
+
});
|
|
65
|
+
export default QueryOptionPopover;
|
|
66
|
+
//# sourceMappingURL=QueryOptionPopover.js.map
|
|
@@ -0,0 +1 @@
|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MAAM,EAAE,MAAM,EACd,GAAG,EAAE,UAAU,EACf,IAAI,EAAC,QAAQ,qBACI,SAAS,EAC1B,KAAK,QACL,SAAS,EAAE,SAAS,YAEpB,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,aACtD,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAE,SAAS,YAC7B,OAAO,WACH,EACN,QAAQ,EACT,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,aACrC,KAAC,MAAM,IACL,OAAO,EAAE,GAAG,EAAE;gCACZ,QAAQ,EAAE,CAAC;gCACX,MAAM,EAAE,KAAK,EAAE,CAAC;4BAClB,CAAC,YAEA,CAAC,CAAC,QAAQ,CAAC,WACL,EACT,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,GAAG,EAAE;gCACZ,QAAQ,EAAE,CAAC;gCACX,MAAM,EAAE,KAAK,EAAE,CAAC;4BAClB,CAAC,YAEA,CAAC,CAAC,QAAQ,CAAC,WACL,YACJ,YACF,WACgB,CAC1B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import {\n FunctionComponent,\n PropsWithoutRef,\n forwardRef,\n ReactNode,\n useEffect,\n useCallback\n} from 'react';\nimport styled from 'styled-components';\n\nimport { useConsolidatedRef, useI18n, useOuterEvent, useUID } from '../../hooks';\nimport { ForwardProps, OmitStrict } from '../../types';\nimport { getFocusables } from '../../utils';\nimport Button from '../Button';\nimport Flex from '../Flex';\nimport Popover, { PopoverProps } from '../Popover';\nimport Text from '../Text';\n\nimport { QueryOptionDialogProps } from './ListToolbar.types';\n\ninterface ListToolbarPopoverProps\n extends OmitStrict<PopoverProps, 'target'>,\n Pick<QueryOptionDialogProps, 'onCancel' | 'onSubmit'> {\n heading: string;\n children: ReactNode;\n target?: HTMLButtonElement | null;\n}\n\nconst StyledQueryListPopover = styled(Popover)`\n min-width: 40ch;\n`;\n\nconst QueryOptionPopover: FunctionComponent<ListToolbarPopoverProps & ForwardProps> = forwardRef(\n (\n { target, heading, children, onCancel, onSubmit }: PropsWithoutRef<ListToolbarPopoverProps>,\n ref: ListToolbarPopoverProps['ref']\n ) => {\n const t = useI18n();\n const headingId = useUID();\n const popoverRef = useConsolidatedRef(ref);\n\n const onKeydown = useCallback(\n (e: KeyboardEvent) => {\n if (e.repeat) return;\n\n if (e.key === 'Escape') {\n onCancel();\n target?.focus();\n return;\n }\n\n if (e.key === 'Tab') {\n const focusables = getFocusables(popoverRef);\n if (!focusables || focusables.length < 2) return;\n const firstFocusable = focusables[0];\n const lastFocusable = focusables[focusables.length - 1];\n\n if (\n !e.shiftKey &&\n (document.activeElement === popoverRef.current ||\n document.activeElement === lastFocusable)\n ) {\n firstFocusable?.focus();\n e.preventDefault();\n } else if (\n e.shiftKey &&\n (document.activeElement === popoverRef.current ||\n document.activeElement === firstFocusable)\n ) {\n lastFocusable?.focus();\n e.preventDefault();\n }\n }\n },\n [onCancel, popoverRef, target]\n );\n\n useOuterEvent('mousedown', [popoverRef], () => {\n onCancel();\n });\n\n useEffect(() => {\n document.addEventListener('keydown', onKeydown);\n return () => {\n document.removeEventListener('keydown', onKeydown);\n };\n }, [onKeydown]);\n\n useEffect(() => {\n getFocusables(popoverRef)[0]?.focus();\n }, [popoverRef]);\n\n return (\n <StyledQueryListPopover\n target={target}\n ref={popoverRef}\n role='dialog'\n aria-labelledby={headingId}\n arrow\n onKeyDown={onKeydown}\n >\n <Flex container={{ direction: 'column', gap: 2, pad: 2 }}>\n <Text variant='h3' id={headingId}>\n {heading}\n </Text>\n {children}\n <Flex container={{ justify: 'between' }}>\n <Button\n onClick={() => {\n onCancel();\n target?.focus();\n }}\n >\n {t('cancel')}\n </Button>\n <Button\n variant='primary'\n onClick={() => {\n onSubmit();\n target?.focus();\n }}\n >\n {t('submit')}\n </Button>\n </Flex>\n </Flex>\n </StyledQueryListPopover>\n );\n }\n);\n\nexport default QueryOptionPopover;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { default } from './ListToolbar';\nexport { ListToolbarProps } from './ListToolbar.types';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuButton.d.ts","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,iBAAiB,EAKjB,oBAAoB,EACrB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlF,OAAe,EAAE,WAAW,EAAgB,MAAM,WAAW,CAAC;AAC9D,OAAgB,EAAE,YAAY,EAAiB,MAAM,YAAY,CAAC;AAQlE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,eAAgB,SAAQ,SAAS,EAAE,cAAc;IAChE,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC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