@coveord/plasma-mantine 48.9.1 → 48.9.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/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-test.log +7 -7
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/collection/Collection.js.map +1 -1
- package/dist/cjs/components/header/Header.js.map +1 -1
- package/dist/definitions/components/collection/Collection.d.ts +67 -1
- package/dist/definitions/components/collection/Collection.d.ts.map +1 -1
- package/dist/definitions/components/header/Header.d.ts +23 -2
- package/dist/definitions/components/header/Header.d.ts.map +1 -1
- package/dist/esm/components/collection/Collection.js.map +1 -1
- package/dist/esm/components/header/Header.js.map +1 -1
- package/package.json +1 -1
- package/src/components/collection/Collection.tsx +67 -1
- package/src/components/header/Header.tsx +23 -2
- package/dist/cjs/components/code-editor/CodeEditor.example.js +0 -41
- package/dist/cjs/components/code-editor/CodeEditor.example.js.map +0 -1
- package/dist/definitions/components/code-editor/CodeEditor.example.d.ts +0 -4
- package/dist/definitions/components/code-editor/CodeEditor.example.d.ts.map +0 -1
- package/dist/esm/components/code-editor/CodeEditor.example.js +0 -31
- package/dist/esm/components/code-editor/CodeEditor.example.js.map +0 -1
- package/src/components/code-editor/CodeEditor.example.tsx +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/collection/Collection.tsx"],"sourcesContent":["import {AddSize16Px} from '@coveord/plasma-react-icons';\nimport {\n Box,\n Button,\n DefaultProps,\n Group,\n MantineNumberSize,\n Selectors,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useId} from '@mantine/hooks';\nimport {ReactNode} from 'react';\nimport {DragDropContext, Droppable} from 'react-beautiful-dnd';\n\nimport {useControlledList} from '../../hooks';\nimport {CollectionItem} from './CollectionItem';\nimport useStyles from './Colllection.styles';\n\ninterface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {\n newItem: T;\n children: (item: T, index: number) => ReactNode;\n defaultValue?: T[];\n value?: T[];\n onFocus?: () => void;\n onChange?: (value: T[]) => void;\n onRemoveItem?: (itemIndex: number) => void;\n draggable?: boolean;\n disabled?: boolean;\n allowAdd?: (values: T[]) => boolean;\n addLabel?: string;\n addDisabledTooltip?: string;\n spacing?: MantineNumberSize;\n required?: boolean;\n}\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n spacing: 'xs',\n required: false,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T>) => {\n const {\n value,\n defaultValue,\n onChange,\n onRemoveItem,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n\n // Style props\n classNames,\n className,\n styles,\n unstyled,\n\n ...others\n } = useComponentDefaultProps('Collection', defaultProps as CollectionProps<T>, props);\n const {classes, cx} = useStyles(null, {classNames, name: 'Collection', styles, unstyled});\n const collectionID = useId('dnd-droppable');\n\n const [values, {append, remove, reorder}] = useControlledList({value, onChange, defaultValue});\n const hasOnlyOneItem = values.length === 1;\n const removeItem = (index: number) => () => {\n remove(index);\n onRemoveItem?.(index);\n };\n\n const items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={removeItem(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item, index)}\n </CollectionItem>\n ));\n\n const addAllowed = allowAdd?.(values) ?? true;\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={addAllowed}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => append(newItem)}\n disabled={!addAllowed}\n >\n {addLabel}\n </Button>\n </Box>\n </Tooltip>\n </Group>\n );\n\n return (\n <DragDropContext\n onDragEnd={({destination, source}) => reorder({from: source.index, to: destination?.index || 0})}\n >\n <Droppable direction=\"vertical\" droppableId={collectionID}>\n {(provided) => (\n <Box\n {...provided.droppableProps}\n ref={provided.innerRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <Stack spacing={spacing}>\n {items}\n {provided.placeholder}\n {_addButton}\n </Stack>\n </Box>\n )}\n </Droppable>\n </DragDropContext>\n );\n};\n"],"names":["Collection","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","props","useComponentDefaultProps","value","defaultValue","onChange","onRemoveItem","children","newItem","allowAdd","classNames","className","styles","unstyled","others","useStyles","name","classes","cx","collectionID","useId","useControlledList","values","append","remove","reorder","hasOnlyOneItem","length","removeItem","index","items","map","item","CollectionItem","onRemove","removable","addAllowed","_addButton","Group","Tooltip","label","Box","Button","variant","leftIcon","AddSize16Px","height","onClick","DragDropContext","onDragEnd","destination","source","from","to","Droppable","direction","droppableId","provided","droppableProps","ref","innerRef","root","Stack","placeholder"],"mappings":"AAAA;;;;+BA8CaA,YAAU;;;eAAVA,UAAU;;;;;;;;;gCA9CG,6BAA6B;oBAWhD,eAAe;qBACF,gBAAgB;iCAEK,qBAAqB;sBAE9B,aAAa;8BAChB,kBAAkB;sEACzB,sBAAsB;AAmB5C,IAAMC,YAAY,GAAsC;IACpDC,SAAS,EAAE,KAAK;IAChBC,QAAQ,EAAE,UAAU;IACpBC,kBAAkB,EAAE,gCAAgC;IACpDC,QAAQ,EAAE,KAAK;IACfC,OAAO,EAAE,IAAI;IACbC,QAAQ,EAAE,KAAK;CAClB,AAAC;AAEK,IAAMP,UAAU,GAAG,SAAKQ,KAAyB,EAAK;IACzD,IAsBIC,IAAiF,GAAjFA,IAAAA,KAAwB,yBAAA,EAAC,YAAY,EAAER,YAAY,EAAwBO,KAAK,CAAC,EArBjFE,KAAK,GAqBLD,IAAiF,CArBjFC,KAAK,EACLC,YAAY,GAoBZF,IAAiF,CApBjFE,YAAY,EACZC,QAAQ,GAmBRH,IAAiF,CAnBjFG,QAAQ,EACRC,YAAY,GAkBZJ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../../src/components/collection/Collection.tsx"],"sourcesContent":["import {AddSize16Px} from '@coveord/plasma-react-icons';\nimport {\n Box,\n Button,\n DefaultProps,\n Group,\n MantineNumberSize,\n Selectors,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useId} from '@mantine/hooks';\nimport {ReactNode} from 'react';\nimport {DragDropContext, Droppable} from 'react-beautiful-dnd';\n\nimport {useControlledList} from '../../hooks';\nimport {CollectionItem} from './CollectionItem';\nimport useStyles from './Colllection.styles';\n\ninterface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The default value each new item should have\n */\n newItem: T;\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * The initial items of the collection (for uncontrolled usage only)\n */\n defaultValue?: T[];\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: (values: T[]) => boolean;\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: string;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The spacing between the colleciton items\n *\n * @default 'xs'\n */\n spacing?: MantineNumberSize;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n spacing: 'xs',\n required: false,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T>) => {\n const {\n value,\n defaultValue,\n onChange,\n onRemoveItem,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n\n // Style props\n classNames,\n className,\n styles,\n unstyled,\n\n ...others\n } = useComponentDefaultProps('Collection', defaultProps as CollectionProps<T>, props);\n const {classes, cx} = useStyles(null, {classNames, name: 'Collection', styles, unstyled});\n const collectionID = useId('dnd-droppable');\n\n const [values, {append, remove, reorder}] = useControlledList({value, onChange, defaultValue});\n const hasOnlyOneItem = values.length === 1;\n const removeItem = (index: number) => () => {\n remove(index);\n onRemoveItem?.(index);\n };\n\n const items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={removeItem(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item, index)}\n </CollectionItem>\n ));\n\n const addAllowed = allowAdd?.(values) ?? true;\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={addAllowed}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => append(newItem)}\n disabled={!addAllowed}\n >\n {addLabel}\n </Button>\n </Box>\n </Tooltip>\n </Group>\n );\n\n return (\n <DragDropContext\n onDragEnd={({destination, source}) => reorder({from: source.index, to: destination?.index || 0})}\n >\n <Droppable direction=\"vertical\" droppableId={collectionID}>\n {(provided) => (\n <Box\n {...provided.droppableProps}\n ref={provided.innerRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <Stack spacing={spacing}>\n {items}\n {provided.placeholder}\n {_addButton}\n </Stack>\n </Box>\n )}\n </Droppable>\n </DragDropContext>\n );\n};\n"],"names":["Collection","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","props","useComponentDefaultProps","value","defaultValue","onChange","onRemoveItem","children","newItem","allowAdd","classNames","className","styles","unstyled","others","useStyles","name","classes","cx","collectionID","useId","useControlledList","values","append","remove","reorder","hasOnlyOneItem","length","removeItem","index","items","map","item","CollectionItem","onRemove","removable","addAllowed","_addButton","Group","Tooltip","label","Box","Button","variant","leftIcon","AddSize16Px","height","onClick","DragDropContext","onDragEnd","destination","source","from","to","Droppable","direction","droppableId","provided","droppableProps","ref","innerRef","root","Stack","placeholder"],"mappings":"AAAA;;;;+BAgHaA,YAAU;;;eAAVA,UAAU;;;;;;;;;gCAhHG,6BAA6B;oBAWhD,eAAe;qBACF,gBAAgB;iCAEK,qBAAqB;sBAE9B,aAAa;8BAChB,kBAAkB;sEACzB,sBAAsB;AAqF5C,IAAMC,YAAY,GAAsC;IACpDC,SAAS,EAAE,KAAK;IAChBC,QAAQ,EAAE,UAAU;IACpBC,kBAAkB,EAAE,gCAAgC;IACpDC,QAAQ,EAAE,KAAK;IACfC,OAAO,EAAE,IAAI;IACbC,QAAQ,EAAE,KAAK;CAClB,AAAC;AAEK,IAAMP,UAAU,GAAG,SAAKQ,KAAyB,EAAK;IACzD,IAsBIC,IAAiF,GAAjFA,IAAAA,KAAwB,yBAAA,EAAC,YAAY,EAAER,YAAY,EAAwBO,KAAK,CAAC,EArBjFE,KAAK,GAqBLD,IAAiF,CArBjFC,KAAK,EACLC,YAAY,GAoBZF,IAAiF,CApBjFE,YAAY,EACZC,QAAQ,GAmBRH,IAAiF,CAnBjFG,QAAQ,EACRC,YAAY,GAkBZJ,IAAiF,CAlBjFI,YAAY,EACZR,QAAQ,GAiBRI,IAAiF,CAjBjFJ,QAAQ,EACRH,SAAS,GAgBTO,IAAiF,CAhBjFP,SAAS,EACTY,QAAQ,GAeRL,IAAiF,CAfjFK,QAAQ,EACRR,OAAO,GAcPG,IAAiF,CAdjFH,OAAO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AAQ,gBAAE,qBAACC,iBAAW,YAAA;wBAACC,MAAM,EAAE,EAAE;sBAAI;oBACrCC,OAAO,EAAE;+BAAMxB,MAAM,CAACf,OAAO,CAAC;qBAAA;oBAC9BV,QAAQ,EAAE,CAACsC,UAAU;8BAEpBxC,QAAQ;kBACJ;cACP;UACA;MACN,AACX,AAAC;IAEF,qBACI,qBAACoD,kBAAe,gBAAA;QACZC,SAAS,EAAE;gBAAEC,WAAW,SAAXA,WAAW,EAAEC,MAAM,SAANA,MAAM;YAAM1B,OAAAA,OAAO,CAAC;gBAAC2B,IAAI,EAAED,MAAM,CAACtB,KAAK;gBAAEwB,EAAE,EAAEH,CAAAA,WAAW,aAAXA,WAAW,WAAO,GAAlBA,KAAAA,CAAkB,GAAlBA,WAAW,CAAErB,KAAK,CAAA,IAAI,CAAC;aAAC,CAAC,CAAA;SAAA;kBAEhG,cAAA,qBAACyB,kBAAS,UAAA;YAACC,SAAS,EAAC,UAAU;YAACC,WAAW,EAAErC,YAAY;sBACpD,SAACsC,QAAQ;qCACN,qBAAChB,KAAG,IAAA,wEACIgB,QAAQ,CAACC,cAAc;oBAC3BC,GAAG,EAAEF,QAAQ,CAACG,QAAQ;oBACtBjD,SAAS,EAAEO,EAAE,CAACD,OAAO,CAAC4C,IAAI,EAAElD,SAAS,CAAC;oBAClCG,MAAM;8BAEV,cAAA,sBAACgD,KAAK,MAAA;wBAAC/D,OAAO,EAAEA,OAAO;;4BAClB+B,KAAK;4BACL2B,QAAQ,CAACM,WAAW;4BACpB1B,UAAU;;sBACP;mBACN;aACT;UACO;MACE,CACpB;AACN,CAAC,AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/header/Header.tsx"],"sourcesContent":["import {QuestionSize24Px} from '@coveord/plasma-react-icons';\nimport {Anchor, Breadcrumbs, DefaultProps, Divider, Group, Stack, Text, Title, Tooltip} from '@mantine/core';\nimport {FunctionComponent,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/header/Header.tsx"],"sourcesContent":["import {QuestionSize24Px} from '@coveord/plasma-react-icons';\nimport {Anchor, Breadcrumbs, DefaultProps, Divider, Group, Stack, Text, Title, Tooltip} from '@mantine/core';\nimport {FunctionComponent, ReactNode} from 'react';\n\ninterface HeaderProps extends DefaultProps {\n /**\n * The description text displayed inside the header underneath the title\n */\n description?: ReactNode;\n /**\n * Action buttons that can be displayed on the right of the header\n */\n actions?: ReactNode;\n /**\n * Whether the header should have a border on the bottom\n */\n borderBottom?: boolean;\n /**\n * A href pointing to documentation related to the current panel.\n * When provided, an info icon is rendered next to the title as link to this documentation\n */\n docLink?: string;\n /**\n * The tooltip text shown when hovering over the doc link icon\n */\n docLinkTooltipLabel?: string;\n /**\n * The title of the header.\n * If more than one children are provided, each of them act as parts of a breadcrumb\n */\n children: ReactNode;\n}\n\nexport const Header: FunctionComponent<HeaderProps> = ({\n description,\n actions,\n borderBottom,\n docLink,\n docLinkTooltipLabel,\n children,\n ...others\n}) => (\n <>\n <Group position=\"apart\" py=\"md\" px=\"xl\" {...others}>\n <Stack spacing=\"xs\">\n <Title order={4}>\n <Group spacing={0}>\n <Breadcrumbs>{children}</Breadcrumbs>\n {docLink ? (\n <Tooltip label={docLinkTooltipLabel} position=\"bottom\">\n <Anchor href={docLink} target=\"_blank\" ml=\"xs\">\n <QuestionSize24Px height={24} />\n </Anchor>\n </Tooltip>\n ) : null}\n </Group>\n </Title>\n <Text size=\"sm\">{description}</Text>\n </Stack>\n <Group spacing=\"xs\">{actions}</Group>\n </Group>\n {borderBottom ? <Divider size=\"xs\" /> : null}\n </>\n);\n"],"names":["Header","description","actions","borderBottom","docLink","docLinkTooltipLabel","children","others","Group","position","py","px","Stack","spacing","Title","order","Breadcrumbs","Tooltip","label","Anchor","href","target","ml","QuestionSize24Px","height","Text","size","Divider"],"mappings":"AAAA;;;;+BAiCaA,QAAM;;;eAANA,MAAM;;;;;;;gCAjCY,6BAA6B;oBACiC,eAAe;AAgCrG,IAAMA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efaultProps, MantineNumberSize, Selectors } from '@mantine/core';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import useStyles from './Colllection.styles';
|
|
4
4
|
interface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {
|
|
5
|
+
/**
|
|
6
|
+
* The default value each new item should have
|
|
7
|
+
*/
|
|
5
8
|
newItem: T;
|
|
9
|
+
/**
|
|
10
|
+
* A render function called for each item passed in the `value` prop.
|
|
11
|
+
*
|
|
12
|
+
* @param item The current item's value
|
|
13
|
+
* @param index The current item's index
|
|
14
|
+
*/
|
|
6
15
|
children: (item: T, index: number) => ReactNode;
|
|
7
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The list of items to display inside the collection
|
|
18
|
+
*
|
|
19
|
+
* @default []
|
|
20
|
+
*/
|
|
8
21
|
value?: T[];
|
|
22
|
+
/**
|
|
23
|
+
* The initial items of the collection (for uncontrolled usage only)
|
|
24
|
+
*/
|
|
25
|
+
defaultValue?: T[];
|
|
26
|
+
/**
|
|
27
|
+
* Unused, has no effect
|
|
28
|
+
*/
|
|
9
29
|
onFocus?: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Function called whenever the value needs to be updated
|
|
32
|
+
*
|
|
33
|
+
* @param value The whole list of items after the change
|
|
34
|
+
*/
|
|
10
35
|
onChange?: (value: T[]) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Function called after an item is removed from the collection using the remove button
|
|
38
|
+
*
|
|
39
|
+
* @param itemIndex The index of the item that was removed
|
|
40
|
+
*/
|
|
11
41
|
onRemoveItem?: (itemIndex: number) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the collection should have drag and drop behavior enabled
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
12
47
|
draggable?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the collection is disabled, or in other words in read only mode
|
|
50
|
+
*
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
13
53
|
disabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Function that determines if the add item button should be enabled given the current items of the collection.
|
|
56
|
+
* The button is always enabled if this props remains undefined
|
|
57
|
+
*
|
|
58
|
+
* @param values The current items of the collection
|
|
59
|
+
*/
|
|
14
60
|
allowAdd?: (values: T[]) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The label of the add item button
|
|
63
|
+
*
|
|
64
|
+
* @default "Add item"
|
|
65
|
+
*/
|
|
15
66
|
addLabel?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The tooltip text displayed when hovering over the disabled add item button
|
|
69
|
+
*
|
|
70
|
+
* @default 'There is already an empty item'
|
|
71
|
+
*/
|
|
16
72
|
addDisabledTooltip?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The spacing between the colleciton items
|
|
75
|
+
*
|
|
76
|
+
* @default 'xs'
|
|
77
|
+
*/
|
|
17
78
|
spacing?: MantineNumberSize;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item
|
|
81
|
+
*
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
18
84
|
required?: boolean;
|
|
19
85
|
}
|
|
20
86
|
export declare const Collection: <T>(props: CollectionProps<T>) => JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../../src/components/collection/Collection.tsx"],"names":[],"mappings":"AACA,OAAO,EAGH,YAAY,EAEZ,iBAAiB,EACjB,SAAS,EAIZ,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAKhC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAE7C,UAAU,eAAe,CAAC,CAAC,CAAE,SAAQ,YAAY,CAAC,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC;IAC1E,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,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,CAAC,EAAE,OAAO,CAAC;CACtB;AAWD,eAAO,MAAM,UAAU,+CAyFtB,CAAC"}
|
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import { DefaultProps } from '@mantine/core';
|
|
2
|
-
import { FunctionComponent,
|
|
2
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
3
3
|
interface HeaderProps extends DefaultProps {
|
|
4
|
+
/**
|
|
5
|
+
* The description text displayed inside the header underneath the title
|
|
6
|
+
*/
|
|
4
7
|
description?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Action buttons that can be displayed on the right of the header
|
|
10
|
+
*/
|
|
5
11
|
actions?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the header should have a border on the bottom
|
|
14
|
+
*/
|
|
6
15
|
borderBottom?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* A href pointing to documentation related to the current panel.
|
|
18
|
+
* When provided, an info icon is rendered next to the title as link to this documentation
|
|
19
|
+
*/
|
|
7
20
|
docLink?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The tooltip text shown when hovering over the doc link icon
|
|
23
|
+
*/
|
|
8
24
|
docLinkTooltipLabel?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The title of the header.
|
|
27
|
+
* If more than one children are provided, each of them act as parts of a breadcrumb
|
|
28
|
+
*/
|
|
29
|
+
children: ReactNode;
|
|
9
30
|
}
|
|
10
|
-
export declare const Header: FunctionComponent<
|
|
31
|
+
export declare const Header: FunctionComponent<HeaderProps>;
|
|
11
32
|
export {};
|
|
12
33
|
//# sourceMappingURL=Header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../src/components/header/Header.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,YAAY,EAA8C,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAC,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../src/components/header/Header.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,YAAY,EAA8C,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAC,iBAAiB,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAEnD,UAAU,WAAY,SAAQ,YAAY;IACtC;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,CA8BjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/collection/Collection.tsx"],"sourcesContent":["import {AddSize16Px} from '@coveord/plasma-react-icons';\nimport {\n Box,\n Button,\n DefaultProps,\n Group,\n MantineNumberSize,\n Selectors,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useId} from '@mantine/hooks';\nimport {ReactNode} from 'react';\nimport {DragDropContext, Droppable} from 'react-beautiful-dnd';\n\nimport {useControlledList} from '../../hooks';\nimport {CollectionItem} from './CollectionItem';\nimport useStyles from './Colllection.styles';\n\ninterface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {\n newItem: T;\n children: (item: T, index: number) => ReactNode;\n defaultValue?: T[];\n value?: T[];\n onFocus?: () => void;\n onChange?: (value: T[]) => void;\n onRemoveItem?: (itemIndex: number) => void;\n draggable?: boolean;\n disabled?: boolean;\n allowAdd?: (values: T[]) => boolean;\n addLabel?: string;\n addDisabledTooltip?: string;\n spacing?: MantineNumberSize;\n required?: boolean;\n}\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n spacing: 'xs',\n required: false,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T>) => {\n const {\n value,\n defaultValue,\n onChange,\n onRemoveItem,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n\n // Style props\n classNames,\n className,\n styles,\n unstyled,\n\n ...others\n } = useComponentDefaultProps('Collection', defaultProps as CollectionProps<T>, props);\n const {classes, cx} = useStyles(null, {classNames, name: 'Collection', styles, unstyled});\n const collectionID = useId('dnd-droppable');\n\n const [values, {append, remove, reorder}] = useControlledList({value, onChange, defaultValue});\n const hasOnlyOneItem = values.length === 1;\n const removeItem = (index: number) => () => {\n remove(index);\n onRemoveItem?.(index);\n };\n\n const items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={removeItem(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item, index)}\n </CollectionItem>\n ));\n\n const addAllowed = allowAdd?.(values) ?? true;\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={addAllowed}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => append(newItem)}\n disabled={!addAllowed}\n >\n {addLabel}\n </Button>\n </Box>\n </Tooltip>\n </Group>\n );\n\n return (\n <DragDropContext\n onDragEnd={({destination, source}) => reorder({from: source.index, to: destination?.index || 0})}\n >\n <Droppable direction=\"vertical\" droppableId={collectionID}>\n {(provided) => (\n <Box\n {...provided.droppableProps}\n ref={provided.innerRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <Stack spacing={spacing}>\n {items}\n {provided.placeholder}\n {_addButton}\n </Stack>\n </Box>\n )}\n </Droppable>\n </DragDropContext>\n );\n};\n"],"names":["AddSize16Px","Box","Button","Group","Stack","Tooltip","useComponentDefaultProps","useId","DragDropContext","Droppable","useControlledList","CollectionItem","useStyles","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","Collection","props","value","defaultValue","onChange","onRemoveItem","children","newItem","allowAdd","classNames","className","styles","unstyled","others","name","classes","cx","collectionID","values","append","remove","reorder","hasOnlyOneItem","length","removeItem","index","items","map","item","onRemove","removable","addAllowed","_addButton","label","variant","leftIcon","height","onClick","onDragEnd","destination","source","from","to","direction","droppableId","provided","droppableProps","ref","innerRef","root","placeholder"],"mappings":"AAAA;;;;;AAAA,SAAQA,WAAW,QAAO,6BAA6B,CAAC;AACxD,SACIC,GAAG,EACHC,MAAM,EAENC,KAAK,EAGLC,KAAK,EACLC,OAAO,EACPC,wBAAwB,QACrB,eAAe,CAAC;AACvB,SAAQC,KAAK,QAAO,gBAAgB,CAAC;AAErC,SAAQC,eAAe,EAAEC,SAAS,QAAO,qBAAqB,CAAC;AAE/D,SAAQC,iBAAiB,QAAO,aAAa,CAAC;AAC9C,SAAQC,cAAc,QAAO,kBAAkB,CAAC;AAChD,OAAOC,SAAS,MAAM,sBAAsB,CAAC;AAmB7C,IAAMC,YAAY,GAAsC;IACpDC,SAAS,EAAE,KAAK;IAChBC,QAAQ,EAAE,UAAU;IACpBC,kBAAkB,EAAE,gCAAgC;IACpDC,QAAQ,EAAE,KAAK;IACfC,OAAO,EAAE,IAAI;IACbC,QAAQ,EAAE,KAAK;CAClB,AAAC;AAEF,OAAO,IAAMC,UAAU,GAAG,SAAKC,KAAyB,EAAK;IACzD,IAsBIf,IAAiF,GAAjFA,wBAAwB,CAAC,YAAY,EAAEO,YAAY,EAAwBQ,KAAK,CAAC,EArBjFC,KAAK,GAqBLhB,IAAiF,CArBjFgB,KAAK,EACLC,YAAY,GAoBZjB,IAAiF,CApBjFiB,YAAY,EACZC,QAAQ,GAmBRlB,IAAiF,CAnBjFkB,QAAQ,EACRC,YAAY,GAkBZnB,IAAiF,CAlBjFmB,YAAY,EACZR,QAAQ,GAiBRX,IAAiF,CAjBjF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BACpD,cAAA,KAAClD,GAAG;0BACA,cAAA,KAACC,MAAM;oBACHoD,OAAO,EAAC,QAAQ;oBAChBC,QAAQ,gBAAE,KAACvD,WAAW;wBAACwD,MAAM,EAAE,EAAE;sBAAI;oBACrCC,OAAO,EAAE;+BAAMlB,MAAM,CAACZ,OAAO,CAAC;qBAAA;oBAC9BV,QAAQ,EAAE,CAACkC,UAAU;8BAEpBpC,QAAQ;kBACJ;cACP;UACA;MACN,AACX,AAAC;IAEF,qBACI,KAACP,eAAe;QACZkD,SAAS,EAAE;gBAAEC,WAAW,SAAXA,WAAW,EAAEC,MAAM,SAANA,MAAM;YAAMnB,OAAAA,OAAO,CAAC;gBAACoB,IAAI,EAAED,MAAM,CAACf,KAAK;gBAAEiB,EAAE,EAAEH,CAAAA,WAAW,aAAXA,WAAW,WAAO,GAAlBA,KAAAA,CAAkB,GAAlBA,WAAW,CAAEd,KAAK,CAAA,IAAI,CAAC;aAAC,CAAC,CAAA;SAAA;kBAEhG,cAAA,KAACpC,SAAS;YAACsD,SAAS,EAAC,UAAU;YAACC,WAAW,EAAE3B,YAAY;sBACpD,SAAC4B,QAAQ;qCACN,KAAChE,GAAG,8EACIgE,QAAQ,CAACC,cAAc;oBAC3BC,GAAG,EAAEF,QAAQ,CAACG,QAAQ;oBACtBtC,SAAS,EAAEM,EAAE,CAACD,OAAO,CAACkC,IAAI,EAAEvC,SAAS,CAAC;oBAClCG,MAAM;8BAEV,cAAA,MAAC7B,KAAK;wBAACc,OAAO,EAAEA,OAAO;;4BAClB4B,KAAK;4BACLmB,QAAQ,CAACK,WAAW;4BACpBlB,UAAU;;sBACP;mBACN;aACT;UACO;MACE,CACpB;AACN,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/collection/Collection.tsx"],"sourcesContent":["import {AddSize16Px} from '@coveord/plasma-react-icons';\nimport {\n Box,\n Button,\n DefaultProps,\n Group,\n MantineNumberSize,\n Selectors,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useId} from '@mantine/hooks';\nimport {ReactNode} from 'react';\nimport {DragDropContext, Droppable} from 'react-beautiful-dnd';\n\nimport {useControlledList} from '../../hooks';\nimport {CollectionItem} from './CollectionItem';\nimport useStyles from './Colllection.styles';\n\ninterface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The default value each new item should have\n */\n newItem: T;\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * The initial items of the collection (for uncontrolled usage only)\n */\n defaultValue?: T[];\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: (values: T[]) => boolean;\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: string;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The spacing between the colleciton items\n *\n * @default 'xs'\n */\n spacing?: MantineNumberSize;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n spacing: 'xs',\n required: false,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T>) => {\n const {\n value,\n defaultValue,\n onChange,\n onRemoveItem,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n\n // Style props\n classNames,\n className,\n styles,\n unstyled,\n\n ...others\n } = useComponentDefaultProps('Collection', defaultProps as CollectionProps<T>, props);\n const {classes, cx} = useStyles(null, {classNames, name: 'Collection', styles, unstyled});\n const collectionID = useId('dnd-droppable');\n\n const [values, {append, remove, reorder}] = useControlledList({value, onChange, defaultValue});\n const hasOnlyOneItem = values.length === 1;\n const removeItem = (index: number) => () => {\n remove(index);\n onRemoveItem?.(index);\n };\n\n const items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={removeItem(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item, index)}\n </CollectionItem>\n ));\n\n const addAllowed = allowAdd?.(values) ?? true;\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={addAllowed}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => append(newItem)}\n disabled={!addAllowed}\n >\n {addLabel}\n </Button>\n </Box>\n </Tooltip>\n </Group>\n );\n\n return (\n <DragDropContext\n onDragEnd={({destination, source}) => reorder({from: source.index, to: destination?.index || 0})}\n >\n <Droppable direction=\"vertical\" droppableId={collectionID}>\n {(provided) => (\n <Box\n {...provided.droppableProps}\n ref={provided.innerRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <Stack spacing={spacing}>\n {items}\n {provided.placeholder}\n {_addButton}\n </Stack>\n </Box>\n )}\n </Droppable>\n </DragDropContext>\n );\n};\n"],"names":["AddSize16Px","Box","Button","Group","Stack","Tooltip","useComponentDefaultProps","useId","DragDropContext","Droppable","useControlledList","CollectionItem","useStyles","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","Collection","props","value","defaultValue","onChange","onRemoveItem","children","newItem","allowAdd","classNames","className","styles","unstyled","others","name","classes","cx","collectionID","values","append","remove","reorder","hasOnlyOneItem","length","removeItem","index","items","map","item","onRemove","removable","addAllowed","_addButton","label","variant","leftIcon","height","onClick","onDragEnd","destination","source","from","to","direction","droppableId","provided","droppableProps","ref","innerRef","root","placeholder"],"mappings":"AAAA;;;;;AAAA,SAAQA,WAAW,QAAO,6BAA6B,CAAC;AACxD,SACIC,GAAG,EACHC,MAAM,EAENC,KAAK,EAGLC,KAAK,EACLC,OAAO,EACPC,wBAAwB,QACrB,eAAe,CAAC;AACvB,SAAQC,KAAK,QAAO,gBAAgB,CAAC;AAErC,SAAQC,eAAe,EAAEC,SAAS,QAAO,qBAAqB,CAAC;AAE/D,SAAQC,iBAAiB,QAAO,aAAa,CAAC;AAC9C,SAAQC,cAAc,QAAO,kBAAkB,CAAC;AAChD,OAAOC,SAAS,MAAM,sBAAsB,CAAC;AAqF7C,IAAMC,YAAY,GAAsC;IACpDC,SAAS,EAAE,KAAK;IAChBC,QAAQ,EAAE,UAAU;IACpBC,kBAAkB,EAAE,gCAAgC;IACpDC,QAAQ,EAAE,KAAK;IACfC,OAAO,EAAE,IAAI;IACbC,QAAQ,EAAE,KAAK;CAClB,AAAC;AAEF,OAAO,IAAMC,UAAU,GAAG,SAAKC,KAAyB,EAAK;IACzD,IAsBIf,IAAiF,GAAjFA,wBAAwB,CAAC,YAAY,EAAEO,YAAY,EAAwBQ,KAAK,CAAC,EArBjFC,KAAK,GAqBLhB,IAAiF,CArBjFgB,KAAK,EACLC,YAAY,GAoBZjB,IAAiF,CApBjFiB,YAAY,EACZC,QAAQ,GAmBRlB,IAAiF,CAnBjFkB,QAAQ,EACRC,YAAY,GAkBZnB,IAAiF,CAlBjFmB,YAAY,EACZR,QAAQ,GAiBRX,IAAiF,CAjBjFW,QAAQ,EACRH,SAAS,GAgBTR,IAAiF,CAhBjFQ,SAAS,EACTY,QAAQ,GAeRpB,I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oBAChBC,QAAQ,gBAAE,KAACvD,WAAW;wBAACwD,MAAM,EAAE,EAAE;sBAAI;oBACrCC,OAAO,EAAE;+BAAMlB,MAAM,CAACZ,OAAO,CAAC;qBAAA;oBAC9BV,QAAQ,EAAE,CAACkC,UAAU;8BAEpBpC,QAAQ;kBACJ;cACP;UACA;MACN,AACX,AAAC;IAEF,qBACI,KAACP,eAAe;QACZkD,SAAS,EAAE;gBAAEC,WAAW,SAAXA,WAAW,EAAEC,MAAM,SAANA,MAAM;YAAMnB,OAAAA,OAAO,CAAC;gBAACoB,IAAI,EAAED,MAAM,CAACf,KAAK;gBAAEiB,EAAE,EAAEH,CAAAA,WAAW,aAAXA,WAAW,WAAO,GAAlBA,KAAAA,CAAkB,GAAlBA,WAAW,CAAEd,KAAK,CAAA,IAAI,CAAC;aAAC,CAAC,CAAA;SAAA;kBAEhG,cAAA,KAACpC,SAAS;YAACsD,SAAS,EAAC,UAAU;YAACC,WAAW,EAAE3B,YAAY;sBACpD,SAAC4B,QAAQ;qCACN,KAAChE,GAAG,8EACIgE,QAAQ,CAACC,cAAc;oBAC3BC,GAAG,EAAEF,QAAQ,CAACG,QAAQ;oBACtBtC,SAAS,EAAEM,EAAE,CAACD,OAAO,CAACkC,IAAI,EAAEvC,SAAS,CAAC;oBAClCG,MAAM;8BAEV,cAAA,MAAC7B,KAAK;wBAACc,OAAO,EAAEA,OAAO;;4BAClB4B,KAAK;4BACLmB,QAAQ,CAACK,WAAW;4BACpBlB,UAAU;;sBACP;mBACN;aACT;UACO;MACE,CACpB;AACN,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/header/Header.tsx"],"sourcesContent":["import {QuestionSize24Px} from '@coveord/plasma-react-icons';\nimport {Anchor, Breadcrumbs, DefaultProps, Divider, Group, Stack, Text, Title, Tooltip} from '@mantine/core';\nimport {FunctionComponent,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/header/Header.tsx"],"sourcesContent":["import {QuestionSize24Px} from '@coveord/plasma-react-icons';\nimport {Anchor, Breadcrumbs, DefaultProps, Divider, Group, Stack, Text, Title, Tooltip} from '@mantine/core';\nimport {FunctionComponent, ReactNode} from 'react';\n\ninterface HeaderProps extends DefaultProps {\n /**\n * The description text displayed inside the header underneath the title\n */\n description?: ReactNode;\n /**\n * Action buttons that can be displayed on the right of the header\n */\n actions?: ReactNode;\n /**\n * Whether the header should have a border on the bottom\n */\n borderBottom?: boolean;\n /**\n * A href pointing to documentation related to the current panel.\n * When provided, an info icon is rendered next to the title as link to this documentation\n */\n docLink?: string;\n /**\n * The tooltip text shown when hovering over the doc link icon\n */\n docLinkTooltipLabel?: string;\n /**\n * The title of the header.\n * If more than one children are provided, each of them act as parts of a breadcrumb\n */\n children: ReactNode;\n}\n\nexport const Header: FunctionComponent<HeaderProps> = ({\n description,\n actions,\n borderBottom,\n docLink,\n docLinkTooltipLabel,\n children,\n ...others\n}) => (\n <>\n <Group position=\"apart\" py=\"md\" px=\"xl\" {...others}>\n <Stack spacing=\"xs\">\n <Title order={4}>\n <Group spacing={0}>\n <Breadcrumbs>{children}</Breadcrumbs>\n {docLink ? (\n <Tooltip label={docLinkTooltipLabel} position=\"bottom\">\n <Anchor href={docLink} target=\"_blank\" ml=\"xs\">\n <QuestionSize24Px height={24} />\n </Anchor>\n </Tooltip>\n ) : null}\n </Group>\n </Title>\n <Text size=\"sm\">{description}</Text>\n </Stack>\n <Group spacing=\"xs\">{actions}</Group>\n </Group>\n {borderBottom ? <Divider size=\"xs\" /> : null}\n </>\n);\n"],"names":["QuestionSize24Px","Anchor","Breadcrumbs","Divider","Group","Stack","Text","Title","Tooltip","Header","description","actions","borderBottom","docLink","docLinkTooltipLabel","children","others","position","py","px","spacing","order","label","href","target","ml","height","size"],"mappings":"AAAA;;;;AAAA,SAAQA,gBAAgB,QAAO,6BAA6B,CAAC;AAC7D,SAAQC,MAAM,EAAEC,WAAW,EAAgBC,OAAO,EAAEC,KAAK,EAAEC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
|
@@ -19,19 +19,85 @@ import {CollectionItem} from './CollectionItem';
|
|
|
19
19
|
import useStyles from './Colllection.styles';
|
|
20
20
|
|
|
21
21
|
interface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {
|
|
22
|
+
/**
|
|
23
|
+
* The default value each new item should have
|
|
24
|
+
*/
|
|
22
25
|
newItem: T;
|
|
26
|
+
/**
|
|
27
|
+
* A render function called for each item passed in the `value` prop.
|
|
28
|
+
*
|
|
29
|
+
* @param item The current item's value
|
|
30
|
+
* @param index The current item's index
|
|
31
|
+
*/
|
|
23
32
|
children: (item: T, index: number) => ReactNode;
|
|
24
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The list of items to display inside the collection
|
|
35
|
+
*
|
|
36
|
+
* @default []
|
|
37
|
+
*/
|
|
25
38
|
value?: T[];
|
|
39
|
+
/**
|
|
40
|
+
* The initial items of the collection (for uncontrolled usage only)
|
|
41
|
+
*/
|
|
42
|
+
defaultValue?: T[];
|
|
43
|
+
/**
|
|
44
|
+
* Unused, has no effect
|
|
45
|
+
*/
|
|
26
46
|
onFocus?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Function called whenever the value needs to be updated
|
|
49
|
+
*
|
|
50
|
+
* @param value The whole list of items after the change
|
|
51
|
+
*/
|
|
27
52
|
onChange?: (value: T[]) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Function called after an item is removed from the collection using the remove button
|
|
55
|
+
*
|
|
56
|
+
* @param itemIndex The index of the item that was removed
|
|
57
|
+
*/
|
|
28
58
|
onRemoveItem?: (itemIndex: number) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the collection should have drag and drop behavior enabled
|
|
61
|
+
*
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
29
64
|
draggable?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the collection is disabled, or in other words in read only mode
|
|
67
|
+
*
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
30
70
|
disabled?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Function that determines if the add item button should be enabled given the current items of the collection.
|
|
73
|
+
* The button is always enabled if this props remains undefined
|
|
74
|
+
*
|
|
75
|
+
* @param values The current items of the collection
|
|
76
|
+
*/
|
|
31
77
|
allowAdd?: (values: T[]) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The label of the add item button
|
|
80
|
+
*
|
|
81
|
+
* @default "Add item"
|
|
82
|
+
*/
|
|
32
83
|
addLabel?: string;
|
|
84
|
+
/**
|
|
85
|
+
* The tooltip text displayed when hovering over the disabled add item button
|
|
86
|
+
*
|
|
87
|
+
* @default 'There is already an empty item'
|
|
88
|
+
*/
|
|
33
89
|
addDisabledTooltip?: string;
|
|
90
|
+
/**
|
|
91
|
+
* The spacing between the colleciton items
|
|
92
|
+
*
|
|
93
|
+
* @default 'xs'
|
|
94
|
+
*/
|
|
34
95
|
spacing?: MantineNumberSize;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item
|
|
98
|
+
*
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
35
101
|
required?: boolean;
|
|
36
102
|
}
|
|
37
103
|
|
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
import {QuestionSize24Px} from '@coveord/plasma-react-icons';
|
|
2
2
|
import {Anchor, Breadcrumbs, DefaultProps, Divider, Group, Stack, Text, Title, Tooltip} from '@mantine/core';
|
|
3
|
-
import {FunctionComponent,
|
|
3
|
+
import {FunctionComponent, ReactNode} from 'react';
|
|
4
4
|
|
|
5
5
|
interface HeaderProps extends DefaultProps {
|
|
6
|
+
/**
|
|
7
|
+
* The description text displayed inside the header underneath the title
|
|
8
|
+
*/
|
|
6
9
|
description?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Action buttons that can be displayed on the right of the header
|
|
12
|
+
*/
|
|
7
13
|
actions?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the header should have a border on the bottom
|
|
16
|
+
*/
|
|
8
17
|
borderBottom?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* A href pointing to documentation related to the current panel.
|
|
20
|
+
* When provided, an info icon is rendered next to the title as link to this documentation
|
|
21
|
+
*/
|
|
9
22
|
docLink?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The tooltip text shown when hovering over the doc link icon
|
|
25
|
+
*/
|
|
10
26
|
docLinkTooltipLabel?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The title of the header.
|
|
29
|
+
* If more than one children are provided, each of them act as parts of a breadcrumb
|
|
30
|
+
*/
|
|
31
|
+
children: ReactNode;
|
|
11
32
|
}
|
|
12
33
|
|
|
13
|
-
export const Header: FunctionComponent<
|
|
34
|
+
export const Header: FunctionComponent<HeaderProps> = ({
|
|
14
35
|
description,
|
|
15
36
|
actions,
|
|
16
37
|
borderBottom,
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _default;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _objectSpread = require("@swc/helpers/lib/_object_spread.js").default;
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
var _form = require("@mantine/form");
|
|
14
|
-
var _codeEditor = require("./CodeEditor");
|
|
15
|
-
var _default = function() {
|
|
16
|
-
var form = (0, _form.useForm)({
|
|
17
|
-
initialValues: {
|
|
18
|
-
config: '{"key":"value"}'
|
|
19
|
-
},
|
|
20
|
-
validate: {
|
|
21
|
-
config: function(jsonValue) {
|
|
22
|
-
try {
|
|
23
|
-
var config = JSON.parse(jsonValue);
|
|
24
|
-
if (!config.key) {
|
|
25
|
-
return "The key must have a value";
|
|
26
|
-
}
|
|
27
|
-
} catch (e) {
|
|
28
|
-
return "Invalid JSON";
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_codeEditor.CodeEditor, _objectSpread({
|
|
35
|
-
language: "json",
|
|
36
|
-
label: "Configuration",
|
|
37
|
-
description: "This JSON configuration is very important"
|
|
38
|
-
}, form.getInputProps("config")));
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=CodeEditor.example.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.example.tsx"],"sourcesContent":["import {useForm} from '@mantine/form';\nimport {CodeEditor} from './CodeEditor';\n\nexport default () => {\n const form = useForm({\n initialValues: {\n config: '{\"key\":\"value\"}',\n },\n validate: {\n config: (jsonValue) => {\n try {\n const config = JSON.parse(jsonValue);\n if (!config.key) {\n return 'The key must have a value';\n }\n } catch {\n return 'Invalid JSON';\n }\n return null;\n },\n },\n });\n\n return (\n <CodeEditor\n language=\"json\"\n label=\"Configuration\"\n description=\"This JSON configuration is very important\"\n {...form.getInputProps('config')}\n />\n );\n};\n"],"names":["form","useForm","initialValues","config","validate","jsonValue","JSON","parse","key","CodeEditor","language","label","description","getInputProps"],"mappings":"AAAA;;;;+BAGA,SA4BE;;;eA5BF,QA4BE;;;;;oBA/BoB,eAAe;0BACZ,cAAc;IAEvC,QA4BE,GA5Ba,WAAM;IACjB,IAAMA,IAAI,GAAGC,IAAAA,KAAO,QAAA,EAAC;QACjBC,aAAa,EAAE;YACXC,MAAM,EAAE,iBAAiB;SAC5B;QACDC,QAAQ,EAAE;YACND,MAAM,EAAE,SAACE,SAAS,EAAK;gBACnB,IAAI;oBACA,IAAMF,MAAM,GAAGG,IAAI,CAACC,KAAK,CAACF,SAAS,CAAC,AAAC;oBACrC,IAAI,CAACF,MAAM,CAACK,GAAG,EAAE;wBACb,OAAO,2BAA2B,CAAC;oBACvC,CAAC;gBACL,EAAE,UAAM;oBACJ,OAAO,cAAc,CAAC;gBAC1B,CAAC;gBACD,OAAO,IAAI,CAAC;YAChB,CAAC;SACJ;KACJ,CAAC,AAAC;IAEH,qBACI,qBAACC,WAAU,WAAA;QACPC,QAAQ,EAAC,MAAM;QACfC,KAAK,EAAC,eAAe;QACrBC,WAAW,EAAC,2CAA2C;OACnDZ,IAAI,CAACa,aAAa,CAAC,QAAQ,CAAC,EAClC,CACJ;AACN,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.example.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/CodeEditor.example.tsx"],"names":[],"mappings":";;AAGA,wBA4BE"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import _object_spread from "@swc/helpers/src/_object_spread.mjs";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useForm } from "@mantine/form";
|
|
4
|
-
import { CodeEditor } from "./CodeEditor";
|
|
5
|
-
export default function() {
|
|
6
|
-
var form = useForm({
|
|
7
|
-
initialValues: {
|
|
8
|
-
config: '{"key":"value"}'
|
|
9
|
-
},
|
|
10
|
-
validate: {
|
|
11
|
-
config: function(jsonValue) {
|
|
12
|
-
try {
|
|
13
|
-
var config = JSON.parse(jsonValue);
|
|
14
|
-
if (!config.key) {
|
|
15
|
-
return "The key must have a value";
|
|
16
|
-
}
|
|
17
|
-
} catch (e) {
|
|
18
|
-
return "Invalid JSON";
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return /*#__PURE__*/ _jsx(CodeEditor, _object_spread({
|
|
25
|
-
language: "json",
|
|
26
|
-
label: "Configuration",
|
|
27
|
-
description: "This JSON configuration is very important"
|
|
28
|
-
}, form.getInputProps("config")));
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=CodeEditor.example.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.example.tsx"],"sourcesContent":["import {useForm} from '@mantine/form';\nimport {CodeEditor} from './CodeEditor';\n\nexport default () => {\n const form = useForm({\n initialValues: {\n config: '{\"key\":\"value\"}',\n },\n validate: {\n config: (jsonValue) => {\n try {\n const config = JSON.parse(jsonValue);\n if (!config.key) {\n return 'The key must have a value';\n }\n } catch {\n return 'Invalid JSON';\n }\n return null;\n },\n },\n });\n\n return (\n <CodeEditor\n language=\"json\"\n label=\"Configuration\"\n description=\"This JSON configuration is very important\"\n {...form.getInputProps('config')}\n />\n );\n};\n"],"names":["useForm","CodeEditor","form","initialValues","config","validate","jsonValue","JSON","parse","key","language","label","description","getInputProps"],"mappings":"AAAA;;AAAA,SAAQA,OAAO,QAAO,eAAe,CAAC;AACtC,SAAQC,UAAU,QAAO,cAAc,CAAC;AAExC,eAAe,WAAM;IACjB,IAAMC,IAAI,GAAGF,OAAO,CAAC;QACjBG,aAAa,EAAE;YACXC,MAAM,EAAE,iBAAiB;SAC5B;QACDC,QAAQ,EAAE;YACND,MAAM,EAAE,SAACE,SAAS,EAAK;gBACnB,IAAI;oBACA,IAAMF,MAAM,GAAGG,IAAI,CAACC,KAAK,CAACF,SAAS,CAAC,AAAC;oBACrC,IAAI,CAACF,MAAM,CAACK,GAAG,EAAE;wBACb,OAAO,2BAA2B,CAAC;oBACvC,CAAC;gBACL,EAAE,UAAM;oBACJ,OAAO,cAAc,CAAC;gBAC1B,CAAC;gBACD,OAAO,IAAI,CAAC;YAChB,CAAC;SACJ;KACJ,CAAC,AAAC;IAEH,qBACI,KAACR,UAAU;QACPS,QAAQ,EAAC,MAAM;QACfC,KAAK,EAAC,eAAe;QACrBC,WAAW,EAAC,2CAA2C;OACnDV,IAAI,CAACW,aAAa,CAAC,QAAQ,CAAC,EAClC,CACJ;AACN,CAAC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {useForm} from '@mantine/form';
|
|
2
|
-
import {CodeEditor} from './CodeEditor';
|
|
3
|
-
|
|
4
|
-
export default () => {
|
|
5
|
-
const form = useForm({
|
|
6
|
-
initialValues: {
|
|
7
|
-
config: '{"key":"value"}',
|
|
8
|
-
},
|
|
9
|
-
validate: {
|
|
10
|
-
config: (jsonValue) => {
|
|
11
|
-
try {
|
|
12
|
-
const config = JSON.parse(jsonValue);
|
|
13
|
-
if (!config.key) {
|
|
14
|
-
return 'The key must have a value';
|
|
15
|
-
}
|
|
16
|
-
} catch {
|
|
17
|
-
return 'Invalid JSON';
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<CodeEditor
|
|
26
|
-
language="json"
|
|
27
|
-
label="Configuration"
|
|
28
|
-
description="This JSON configuration is very important"
|
|
29
|
-
{...form.getInputProps('config')}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
};
|