@coveord/plasma-mantine 47.5.0 → 47.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,12 +30,11 @@ var defaultProps = {
30
30
  required: false
31
31
  };
32
32
  var Collection = function(props) {
33
- var _ref = (0, _core.useComponentDefaultProps)("Collection", defaultProps, props), value = _ref.value, defaultValue = _ref.defaultValue, onChange = _ref.onChange, onFocus = _ref.onFocus, disabled = _ref.disabled, draggable = _ref.draggable, children = _ref.children, spacing = _ref.spacing, required = _ref.required, newItem = _ref.newItem, addLabel = _ref.addLabel, addDisabledTooltip = _ref.addDisabledTooltip, // Style props
33
+ var _ref = (0, _core.useComponentDefaultProps)("Collection", defaultProps, props), value = _ref.value, defaultValue = _ref.defaultValue, onChange = _ref.onChange, disabled = _ref.disabled, draggable = _ref.draggable, children = _ref.children, spacing = _ref.spacing, required = _ref.required, newItem = _ref.newItem, addLabel = _ref.addLabel, addDisabledTooltip = _ref.addDisabledTooltip, allowAdd = _ref.allowAdd, // Style props
34
34
  classNames = _ref.classNames, className = _ref.className, styles = _ref.styles, unstyled = _ref.unstyled, others = _objectWithoutProperties(_ref, [
35
35
  "value",
36
36
  "defaultValue",
37
37
  "onChange",
38
- "onFocus",
39
38
  "disabled",
40
39
  "draggable",
41
40
  "children",
@@ -44,6 +43,7 @@ var Collection = function(props) {
44
43
  "newItem",
45
44
  "addLabel",
46
45
  "addDisabledTooltip",
46
+ "allowAdd",
47
47
  "classNames",
48
48
  "className",
49
49
  "styles",
@@ -75,13 +75,12 @@ var Collection = function(props) {
75
75
  children: children(item, index)
76
76
  }, index);
77
77
  });
78
- var hasEmptyItem = values.some(function(item) {
79
- return JSON.stringify(item) === JSON.stringify(newItem);
80
- });
78
+ var ref3;
79
+ var addAllowed = (ref3 = allowAdd === null || allowAdd === void 0 ? void 0 : allowAdd(values)) !== null && ref3 !== void 0 ? ref3 : true;
81
80
  var _addButton = disabled ? null : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Group, {
82
81
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Tooltip, {
83
82
  label: addDisabledTooltip,
84
- disabled: !hasEmptyItem,
83
+ disabled: addAllowed,
85
84
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Box, {
86
85
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Button, {
87
86
  variant: "subtle",
@@ -91,7 +90,7 @@ var Collection = function(props) {
91
90
  onClick: function() {
92
91
  return append(newItem);
93
92
  },
94
- disabled: hasEmptyItem,
93
+ disabled: !addAllowed,
95
94
  children: addLabel
96
95
  })
97
96
  })
@@ -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 draggable?: boolean;\n disabled?: 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 onFocus,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\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 items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={() => remove(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item, index)}\n </CollectionItem>\n ));\n\n const hasEmptyItem = values.some((item) => JSON.stringify(item) === JSON.stringify(newItem));\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={!hasEmptyItem}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => append(newItem)}\n disabled={hasEmptyItem}\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","onFocus","children","newItem","classNames","className","styles","unstyled","others","useStyles","name","classes","cx","collectionID","useId","useControlledList","values","append","remove","reorder","hasOnlyOneItem","length","items","map","item","index","CollectionItem","onRemove","removable","hasEmptyItem","some","JSON","stringify","_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;;;;+BA4CaA,YAAU;;;eAAVA,UAAU;;;;;;;;;gCA5CG,6BAA6B;oBAWhD,eAAe;qBACF,gBAAgB;iCAEK,qBAAqB;sBAE9B,aAAa;8BAChB,kBAAkB;sEACzB,sBAAsB;AAiB5C,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,IAqBIC,IAAiF,GAAjFA,IAAAA,KAAwB,yBAAA,EAAC,YAAY,EAAER,YAAY,EAAwBO,KAAK,CAAC,EApBjFE,KAAK,GAoBLD,IAAiF,CApBjFC,KAAK,EACLC,YAAY,GAmBZF,IAAiF,CAnBjFE,YAAY,EACZC,QAAQ,GAkBRH,IAAiF,CAlBjFG,QAAQ,EACRC,OAAO,GAiBPJ,IAAiF,CAjBjFI,OAAO,EACPR,QAAQ,GAgBRI,IAAiF,CAhBjFJ,QAAQ,EACRH,SAAS,GAeTO,IAAiF,CAfjFP,SAAS,EACTY,QAAQ,GAcRL,IAAiF,CAdjFK,QAAQ,EACRR,OAAO,GAaPG,IAAiF,CAbjFH,OAAO,EACPC,QAAQ,GAYRE,IAAiF,CAZjFF,QAAQ,EACRQ,OAAO,GAWPN,IAAiF,CAXjFM,OAAO,EACPZ,QAAQ,GAURM,IAAiF,CAVjFN,QAAQ,EACRC,kBAAkB,GASlBK,IAAiF,CATjFL,kBAAkB,EAElB,cAAc;IACdY,UAAU,GAMVP,IAAiF,CANjFO,UAAU,EACVC,SAAS,GAKTR,IAAiF,CALjFQ,SAAS,EACTC,MAAM,GAINT,IAAiF,CAJjFS,MAAM,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WAAW,EAAEvC,YAAY;sBACpD,SAACwC,QAAQ;qCACN,qBAAChB,KAAG,IAAA,wEACIgB,QAAQ,CAACC,cAAc;oBAC3BC,GAAG,EAAEF,QAAQ,CAACG,QAAQ;oBACtBnD,SAAS,EAAEO,EAAE,CAACD,OAAO,CAAC8C,IAAI,EAAEpD,SAAS,CAAC;oBAClCG,MAAM;8BAEV,cAAA,sBAACkD,KAAK,MAAA;wBAAChE,OAAO,EAAEA,OAAO;;4BAClB4B,KAAK;4BACL+B,QAAQ,CAACM,WAAW;4BACpB1B,UAAU;;sBACP;mBACN;aACT;UACO;MACE,CACpB;AACN,CAAC,AAAC"}
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 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 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 items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={() => remove(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","children","newItem","allowAdd","classNames","className","styles","unstyled","others","useStyles","name","classes","cx","collectionID","useId","useControlledList","values","append","remove","reorder","hasOnlyOneItem","length","items","map","item","index","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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W,EAAEpC,YAAY;sBACpD,SAACqC,QAAQ;qCACN,qBAAChB,KAAG,IAAA,wEACIgB,QAAQ,CAACC,cAAc;oBAC3BC,GAAG,EAAEF,QAAQ,CAACG,QAAQ;oBACtBhD,SAAS,EAAEO,EAAE,CAACD,OAAO,CAAC2C,IAAI,EAAEjD,SAAS,CAAC;oBAClCG,MAAM;8BAEV,cAAA,sBAAC+C,KAAK,MAAA;wBAAC7D,OAAO,EAAEA,OAAO;;4BAClB4B,KAAK;4BACL4B,QAAQ,CAACM,WAAW;4BACpB1B,UAAU;;sBACP;mBACN;aACT;UACO;MACE,CACpB;AACN,CAAC,AAAC"}
package/dist/cjs/index.js CHANGED
@@ -20,10 +20,11 @@ _export(exports, {
20
20
  }
21
21
  });
22
22
  var _exportStar = require("@swc/helpers/lib/_export_star.js").default;
23
- var _tableCore = require("@tanstack/table-core");
23
+ _exportStar(require("@mantine/carousel"), exports);
24
24
  _exportStar(require("@mantine/core"), exports);
25
25
  _exportStar(require("@mantine/form"), exports);
26
26
  _exportStar(require("@mantine/hooks"), exports);
27
+ var _tableCore = require("@tanstack/table-core");
27
28
  var _components = _exportStar(require("./components"), exports);
28
29
  _exportStar(require("./theme"), exports);
29
30
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import {Tuple} from '@mantine/core';\n\nimport {PlasmaColors} from './theme/PlasmaColors';\n\nexport {type ColumnDef, createColumnHelper} from '@tanstack/table-core';\n\nexport * from '@mantine/core';\nexport * from '@mantine/form';\nexport type {FormValidateInput} from '@mantine/form/lib/types';\nexport * from '@mantine/hooks';\n\nexport * from './components';\nexport * from './theme';\n\n// explicitly overriding mantine components\nexport {Header, Table} from './components';\n\ndeclare module '@mantine/core' {\n export interface MantineThemeColorsOverride {\n // eslint-disable-next-line @typescript-eslint/ban-types\n colors: Record<keyof typeof PlasmaColors | (string & {}), Tuple<string, 10>>;\n }\n}\n"],"names":["createColumnHelper","Header","Table"],"mappings":"AAAA;;;;;;;;;;;IAIwBA,kBAAkB;eAAlBA,UAAkB,mBAAA;;IAWlCC,MAAM;eAANA,WAAM,OAAA;;IAAEC,KAAK;eAALA,WAAK,MAAA;;;;yBAX4B,sBAAsB;oBAEzD,eAAe;oBACf,eAAe;oBAEf,gBAAgB;sCAEhB,cAAc;oBACd,SAAS"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import {Tuple} from '@mantine/core';\n\nimport {PlasmaColors} from './theme/PlasmaColors';\n\nexport * from '@mantine/carousel';\nexport * from '@mantine/core';\nexport * from '@mantine/form';\nexport type {FormValidateInput} from '@mantine/form/lib/types';\nexport * from '@mantine/hooks';\nexport {createColumnHelper, type ColumnDef} from '@tanstack/table-core';\nexport * from './components';\n// explicitly overriding mantine components\nexport {Header, Table} from './components';\nexport * from './theme';\n\ndeclare module '@mantine/core' {\n export interface MantineThemeColorsOverride {\n // eslint-disable-next-line @typescript-eslint/ban-types\n colors: Record<keyof typeof PlasmaColors | (string & {}), Tuple<string, 10>>;\n }\n}\n"],"names":["createColumnHelper","Header","Table"],"mappings":"AAAA;;;;;;;;;;;IASQA,kBAAkB;eAAlBA,UAAkB,mBAAA;;IAGlBC,MAAM;eAANA,WAAM,OAAA;;IAAEC,KAAK;eAALA,WAAK,MAAA;;;;oBARP,mBAAmB;oBACnB,eAAe;oBACf,eAAe;oBAEf,gBAAgB;yBACmB,sBAAsB;sCACzD,cAAc;oBAGd,SAAS"}
@@ -10,6 +10,7 @@ interface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {
10
10
  onChange?: (value: T[]) => void;
11
11
  draggable?: boolean;
12
12
  disabled?: boolean;
13
+ allowAdd?: (values: T[]) => boolean;
13
14
  addLabel?: string;
14
15
  addDisabledTooltip?: string;
15
16
  spacing?: MantineNumberSize;
@@ -1 +1 @@
1
- {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../../src/components/collection/Collection.tsx"],"names":[],"mappings":"AACA,OAAO,EAGH,YAAY,EAE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,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAWD,eAAO,MAAM,UAAU,+CAmFtB,CAAC"}
@@ -1,13 +1,14 @@
1
1
  import { Tuple } from '@mantine/core';
2
2
  import { PlasmaColors } from './theme/PlasmaColors';
3
- export { type ColumnDef, createColumnHelper } from '@tanstack/table-core';
3
+ export * from '@mantine/carousel';
4
4
  export * from '@mantine/core';
5
5
  export * from '@mantine/form';
6
6
  export type { FormValidateInput } from '@mantine/form/lib/types';
7
7
  export * from '@mantine/hooks';
8
+ export { createColumnHelper, type ColumnDef } from '@tanstack/table-core';
8
9
  export * from './components';
9
- export * from './theme';
10
10
  export { Header, Table } from './components';
11
+ export * from './theme';
11
12
  declare module '@mantine/core' {
12
13
  interface MantineThemeColorsOverride {
13
14
  colors: Record<keyof typeof PlasmaColors | (string & {}), Tuple<string, 10>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,OAAO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19,12 +19,11 @@ var defaultProps = {
19
19
  required: false
20
20
  };
21
21
  export var Collection = function(props) {
22
- var _ref = useComponentDefaultProps("Collection", defaultProps, props), value = _ref.value, defaultValue = _ref.defaultValue, onChange = _ref.onChange, onFocus = _ref.onFocus, disabled = _ref.disabled, draggable = _ref.draggable, children = _ref.children, spacing = _ref.spacing, required = _ref.required, newItem = _ref.newItem, addLabel = _ref.addLabel, addDisabledTooltip = _ref.addDisabledTooltip, // Style props
22
+ var _ref = useComponentDefaultProps("Collection", defaultProps, props), value = _ref.value, defaultValue = _ref.defaultValue, onChange = _ref.onChange, disabled = _ref.disabled, draggable = _ref.draggable, children = _ref.children, spacing = _ref.spacing, required = _ref.required, newItem = _ref.newItem, addLabel = _ref.addLabel, addDisabledTooltip = _ref.addDisabledTooltip, allowAdd = _ref.allowAdd, // Style props
23
23
  classNames = _ref.classNames, className = _ref.className, styles = _ref.styles, unstyled = _ref.unstyled, others = _object_without_properties(_ref, [
24
24
  "value",
25
25
  "defaultValue",
26
26
  "onChange",
27
- "onFocus",
28
27
  "disabled",
29
28
  "draggable",
30
29
  "children",
@@ -33,6 +32,7 @@ export var Collection = function(props) {
33
32
  "newItem",
34
33
  "addLabel",
35
34
  "addDisabledTooltip",
35
+ "allowAdd",
36
36
  "classNames",
37
37
  "className",
38
38
  "styles",
@@ -64,13 +64,12 @@ export var Collection = function(props) {
64
64
  children: children(item, index)
65
65
  }, index);
66
66
  });
67
- var hasEmptyItem = values.some(function(item) {
68
- return JSON.stringify(item) === JSON.stringify(newItem);
69
- });
67
+ var ref3;
68
+ var addAllowed = (ref3 = allowAdd === null || allowAdd === void 0 ? void 0 : allowAdd(values)) !== null && ref3 !== void 0 ? ref3 : true;
70
69
  var _addButton = disabled ? null : /*#__PURE__*/ _jsx(Group, {
71
70
  children: /*#__PURE__*/ _jsx(Tooltip, {
72
71
  label: addDisabledTooltip,
73
- disabled: !hasEmptyItem,
72
+ disabled: addAllowed,
74
73
  children: /*#__PURE__*/ _jsx(Box, {
75
74
  children: /*#__PURE__*/ _jsx(Button, {
76
75
  variant: "subtle",
@@ -80,7 +79,7 @@ export var Collection = function(props) {
80
79
  onClick: function() {
81
80
  return append(newItem);
82
81
  },
83
- disabled: hasEmptyItem,
82
+ disabled: !addAllowed,
84
83
  children: addLabel
85
84
  })
86
85
  })
@@ -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 draggable?: boolean;\n disabled?: 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 onFocus,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\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 items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={() => remove(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item, index)}\n </CollectionItem>\n ));\n\n const hasEmptyItem = values.some((item) => JSON.stringify(item) === JSON.stringify(newItem));\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={!hasEmptyItem}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => append(newItem)}\n disabled={hasEmptyItem}\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","onFocus","children","newItem","classNames","className","styles","unstyled","others","name","classes","cx","collectionID","values","append","remove","reorder","hasOnlyOneItem","length","items","map","item","index","onRemove","removable","hasEmptyItem","some","JSON","stringify","_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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,CAACC,cAAc;oBAC3BC,GAAG,EAAEF,QAAQ,CAACG,QAAQ;oBACtBxC,SAAS,EAAEM,EAAE,CAACD,OAAO,CAACoC,IAAI,EAAEzC,SAAS,CAAC;oBAClCG,MAAM;8BAEV,cAAA,MAAC5B,KAAK;wBAACc,OAAO,EAAEA,OAAO;;4BAClByB,KAAK;4BACLuB,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 newItem: T;\n children: (item: T, index: number) => ReactNode;\n defaultValue?: T[];\n value?: T[];\n onFocus?: () => void;\n onChange?: (value: T[]) => 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 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 items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={() => remove(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","children","newItem","allowAdd","classNames","className","styles","unstyled","others","name","classes","cx","collectionID","values","append","remove","reorder","hasOnlyOneItem","length","items","map","item","index","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;A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C,SAAS;YAACoD,SAAS,EAAC,UAAU;YAACC,WAAW,EAAE1B,YAAY;sBACpD,SAAC2B,QAAQ;qCACN,KAAC9D,GAAG,8EACI8D,QAAQ,CAACC,cAAc;oBAC3BC,GAAG,EAAEF,QAAQ,CAACG,QAAQ;oBACtBrC,SAAS,EAAEM,EAAE,CAACD,OAAO,CAACiC,IAAI,EAAEtC,SAAS,CAAC;oBAClCG,MAAM;8BAEV,cAAA,MAAC5B,KAAK;wBAACc,OAAO,EAAEA,OAAO;;4BAClByB,KAAK;4BACLoB,QAAQ,CAACK,WAAW;4BACpBlB,UAAU;;sBACP;mBACN;aACT;UACO;MACE,CACpB;AACN,CAAC,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,10 +1,11 @@
1
- export { createColumnHelper } from "@tanstack/table-core";
1
+ export * from "@mantine/carousel";
2
2
  export * from "@mantine/core";
3
3
  export * from "@mantine/form";
4
4
  export * from "@mantine/hooks";
5
+ export { createColumnHelper } from "@tanstack/table-core";
5
6
  export * from "./components";
6
- export * from "./theme";
7
7
  // explicitly overriding mantine components
8
8
  export { Header, Table } from "./components";
9
+ export * from "./theme";
9
10
 
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import {Tuple} from '@mantine/core';\n\nimport {PlasmaColors} from './theme/PlasmaColors';\n\nexport {type ColumnDef, createColumnHelper} from '@tanstack/table-core';\n\nexport * from '@mantine/core';\nexport * from '@mantine/form';\nexport type {FormValidateInput} from '@mantine/form/lib/types';\nexport * from '@mantine/hooks';\n\nexport * from './components';\nexport * from './theme';\n\n// explicitly overriding mantine components\nexport {Header, Table} from './components';\n\ndeclare module '@mantine/core' {\n export interface MantineThemeColorsOverride {\n // eslint-disable-next-line @typescript-eslint/ban-types\n colors: Record<keyof typeof PlasmaColors | (string & {}), Tuple<string, 10>>;\n }\n}\n"],"names":["createColumnHelper","Header","Table"],"mappings":"AAIA,SAAwBA,kBAAkB,QAAO,sBAAsB,CAAC;AAExE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,2CAA2C;AAC3C,SAAQC,MAAM,EAAEC,KAAK,QAAO,cAAc,CAAC"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import {Tuple} from '@mantine/core';\n\nimport {PlasmaColors} from './theme/PlasmaColors';\n\nexport * from '@mantine/carousel';\nexport * from '@mantine/core';\nexport * from '@mantine/form';\nexport type {FormValidateInput} from '@mantine/form/lib/types';\nexport * from '@mantine/hooks';\nexport {createColumnHelper, type ColumnDef} from '@tanstack/table-core';\nexport * from './components';\n// explicitly overriding mantine components\nexport {Header, Table} from './components';\nexport * from './theme';\n\ndeclare module '@mantine/core' {\n export interface MantineThemeColorsOverride {\n // eslint-disable-next-line @typescript-eslint/ban-types\n colors: Record<keyof typeof PlasmaColors | (string & {}), Tuple<string, 10>>;\n }\n}\n"],"names":["createColumnHelper","Header","Table"],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,gBAAgB,CAAC;AAC/B,SAAQA,kBAAkB,QAAuB,sBAAsB,CAAC;AACxE,cAAc,cAAc,CAAC;AAC7B,2CAA2C;AAC3C,SAAQC,MAAM,EAAEC,KAAK,QAAO,cAAc,CAAC;AAC3C,cAAc,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coveord/plasma-mantine",
3
- "version": "47.5.0",
3
+ "version": "47.7.0",
4
4
  "description": "A Plasma flavoured Mantine theme",
5
5
  "keywords": [
6
6
  "plasma",
@@ -23,11 +23,13 @@
23
23
  "dependencies": {
24
24
  "@coveord/plasma-react-icons": "47.3.7",
25
25
  "@coveord/plasma-tokens": "47.3.7",
26
+ "@mantine/carousel": "5.6.4",
26
27
  "@monaco-editor/react": "4.4.5",
27
28
  "@swc/helpers": "0.4.11",
28
29
  "@tanstack/react-table": "8.5.11",
29
30
  "@tanstack/table-core": "8.5.11",
30
31
  "dayjs": "1.11.3",
32
+ "embla-carousel-react": "7.0.4",
31
33
  "lodash.defaultsdeep": "4.6.1",
32
34
  "monaco-editor": "0.34.0",
33
35
  "react-beautiful-dnd": "13.1.0"
@@ -27,6 +27,7 @@ interface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {
27
27
  onChange?: (value: T[]) => void;
28
28
  draggable?: boolean;
29
29
  disabled?: boolean;
30
+ allowAdd?: (values: T[]) => boolean;
30
31
  addLabel?: string;
31
32
  addDisabledTooltip?: string;
32
33
  spacing?: MantineNumberSize;
@@ -47,7 +48,6 @@ export const Collection = <T,>(props: CollectionProps<T>) => {
47
48
  value,
48
49
  defaultValue,
49
50
  onChange,
50
- onFocus,
51
51
  disabled,
52
52
  draggable,
53
53
  children,
@@ -56,6 +56,7 @@ export const Collection = <T,>(props: CollectionProps<T>) => {
56
56
  newItem,
57
57
  addLabel,
58
58
  addDisabledTooltip,
59
+ allowAdd,
59
60
 
60
61
  // Style props
61
62
  classNames,
@@ -84,17 +85,17 @@ export const Collection = <T,>(props: CollectionProps<T>) => {
84
85
  </CollectionItem>
85
86
  ));
86
87
 
87
- const hasEmptyItem = values.some((item) => JSON.stringify(item) === JSON.stringify(newItem));
88
+ const addAllowed = allowAdd?.(values) ?? true;
88
89
 
89
90
  const _addButton = disabled ? null : (
90
91
  <Group>
91
- <Tooltip label={addDisabledTooltip} disabled={!hasEmptyItem}>
92
+ <Tooltip label={addDisabledTooltip} disabled={addAllowed}>
92
93
  <Box>
93
94
  <Button
94
95
  variant="subtle"
95
96
  leftIcon={<AddSize16Px height={16} />}
96
97
  onClick={() => append(newItem)}
97
- disabled={hasEmptyItem}
98
+ disabled={!addAllowed}
98
99
  >
99
100
  {addLabel}
100
101
  </Button>
@@ -96,12 +96,13 @@ describe('Collection', () => {
96
96
  expect(screen.getByTestId('form-state')).toHaveTextContent('{"fruits":["banana","orange","new"]}');
97
97
  });
98
98
 
99
- it('disallows from adding more than one new item at once', () => {
99
+ it('disables the add button whenever allowAdd callback returns false', () => {
100
+ const allowAdd = jest.fn().mockImplementation(() => false);
100
101
  const Fixture = () => {
101
102
  const form = useForm({initialValues: {fruits: ['banana', 'orange']}});
102
103
  return (
103
104
  <>
104
- <Collection newItem="new" {...form.getInputProps('fruits')}>
105
+ <Collection newItem="new" {...form.getInputProps('fruits')} allowAdd={allowAdd}>
105
106
  {(name) => <span data-testid="item">{name}</span>}
106
107
  </Collection>
107
108
  <div data-testid="form-state">{JSON.stringify(form.values)}</div>
@@ -109,10 +110,13 @@ describe('Collection', () => {
109
110
  );
110
111
  };
111
112
 
112
- render(<Fixture />);
113
- const addItem = screen.getByRole('button', {name: /add/i});
114
- userEvent.click(addItem);
115
- expect(addItem).toBeDisabled();
113
+ const {rerender} = render(<Fixture />);
114
+ expect(screen.getByRole('button', {name: /add/i})).toBeDisabled();
115
+ expect(allowAdd).toHaveBeenCalledWith(['banana', 'orange']);
116
+
117
+ allowAdd.mockImplementation(() => true);
118
+ rerender(<Fixture />);
119
+ expect(screen.getByRole('button', {name: /add/i})).toBeEnabled();
116
120
  });
117
121
 
118
122
  describe('when required is true', () => {
package/src/index.ts CHANGED
@@ -2,18 +2,16 @@ import {Tuple} from '@mantine/core';
2
2
 
3
3
  import {PlasmaColors} from './theme/PlasmaColors';
4
4
 
5
- export {type ColumnDef, createColumnHelper} from '@tanstack/table-core';
6
-
5
+ export * from '@mantine/carousel';
7
6
  export * from '@mantine/core';
8
7
  export * from '@mantine/form';
9
8
  export type {FormValidateInput} from '@mantine/form/lib/types';
10
9
  export * from '@mantine/hooks';
11
-
10
+ export {createColumnHelper, type ColumnDef} from '@tanstack/table-core';
12
11
  export * from './components';
13
- export * from './theme';
14
-
15
12
  // explicitly overriding mantine components
16
13
  export {Header, Table} from './components';
14
+ export * from './theme';
17
15
 
18
16
  declare module '@mantine/core' {
19
17
  export interface MantineThemeColorsOverride {