@leav/ui 1.9.0-caa4797b → 1.9.0-e09e8fd5

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.
Files changed (23) hide show
  1. package/dist/_gqlTypes/index.d.ts +100 -9
  2. package/dist/_gqlTypes/index.js +43 -8
  3. package/dist/_gqlTypes/index.js.map +1 -1
  4. package/dist/components/Explorer/Explorer.js +21 -11
  5. package/dist/components/Explorer/Explorer.js.map +1 -1
  6. package/dist/components/Explorer/_queries/useExplorerCountData.d.ts +16 -0
  7. package/dist/components/Explorer/_queries/useExplorerCountData.js +26 -0
  8. package/dist/components/Explorer/_queries/useExplorerCountData.js.map +1 -0
  9. package/dist/components/Explorer/actions-mass/ResultsCount.d.ts +10 -0
  10. package/dist/components/Explorer/actions-mass/ResultsCount.js +8 -0
  11. package/dist/components/Explorer/actions-mass/ResultsCount.js.map +1 -0
  12. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +9 -2
  13. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +18 -4
  14. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +1 -1
  15. package/dist/components/Explorer/actions-mass/useMassActions.d.ts +5 -3
  16. package/dist/components/Explorer/actions-mass/useMassActions.js +19 -13
  17. package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
  18. package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.d.ts +3 -1
  19. package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js +5 -1
  20. package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js.map +1 -1
  21. package/dist/locales/en/shared.json +2 -2
  22. package/dist/locales/fr/shared.json +2 -2
  23. package/package.json +3 -3
@@ -28,8 +28,9 @@ import { faPlus } from '@fortawesome/free-solid-svg-icons';
28
28
  * @param totalCount - used for display purpose only
29
29
  * @param onCreate - callback to let outside world known about creating item (and linking)
30
30
  * @param refetch - method to call to refresh the list. A new item will be visible if it matches filters and sorts
31
+ * @param refetchCount - method to call to refresh the count of the library. A new item will be visible if it matches filters and sorts
31
32
  */
32
- export const useCreatePrimaryAction = ({ isEnabled, isVisible, libraryId, entrypoint, totalCount, canCreateAndLinkValue, isMultivalue, onCreate, formId, joinLibraryContext, refetch, }) => {
33
+ export const useCreatePrimaryAction = ({ isEnabled, isVisible, libraryId, entrypoint, totalCount, canCreateAndLinkValue, isMultivalue, onCreate, formId, joinLibraryContext, refetch, refetchCount, }) => {
33
34
  const { t } = useSharedTranslation();
34
35
  const { lang } = useLang();
35
36
  const [isModalCreationVisible, setIsModalCreationVisible] = useState(false);
@@ -85,6 +86,7 @@ export const useCreatePrimaryAction = ({ isEnabled, isVisible, libraryId, entryp
85
86
  case LibraryBehavior.files:
86
87
  _createModal = (_jsx(UploadFiles, { libraryId: _getLibraryId(), multiple: true, onClose: () => setIsModalCreationVisible(false), onCompleted: () => {
87
88
  refetch();
89
+ refetchCount();
88
90
  _notifyNewCreation(t('upload.file'));
89
91
  setIsModalCreationVisible(false);
90
92
  } }));
@@ -92,6 +94,7 @@ export const useCreatePrimaryAction = ({ isEnabled, isVisible, libraryId, entryp
92
94
  case LibraryBehavior.directories:
93
95
  _createModal = (_jsx(CreateDirectory, { libraryId: _getLibraryId(), onClose: () => setIsModalCreationVisible(false), onCompleted: () => {
94
96
  refetch();
97
+ refetchCount();
95
98
  _notifyNewCreation(t('upload.folder'));
96
99
  setIsModalCreationVisible(false);
97
100
  } }));
@@ -124,6 +127,7 @@ export const useCreatePrimaryAction = ({ isEnabled, isVisible, libraryId, entryp
124
127
  await Promise.resolve(onCreate?.({ recordIdCreated: newRecord.id }));
125
128
  }
126
129
  refetch();
130
+ refetchCount();
127
131
  }, submitButtons: ['create'] }));
128
132
  break;
129
133
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useCreatePrimaryAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-primary/useCreatePrimaryAction.tsx"],"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AAQ,EAAE,CAAC,EAAC,eAAe,EAAE,SAAS,CAAC,EAAE,EAAC,CAAC,CAAC,CAAC;oBACvE,CAAC;oBACD,OAAO,EAAE,CAAC;gBACd,CAAC,EACD,aAAa,EAAE,CAAC,QAAQ,CAAC,GAC3B,CACL,CAAC;YACF,MAAM;IACd,CAAC;IAED,OAAO;QACH,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI;QAC5D,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI;KAC5D,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ReactElement, useState} from 'react';\nimport {KitAlert} from 'aristid-ds';\nimport {CreateDirectory, EditRecordModal, UploadFiles} from '_ui/components';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport useSaveValueBatchMutation from '_ui/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {\n AttributeType,\n type JoinLibraryContextFragment,\n LibraryBehavior,\n useExplorerLibraryDetailsQuery,\n} from '_ui/_gqlTypes';\nimport {type FeatureHook, type Entrypoint, type IPrimaryAction} from '../_types';\nimport {CREATE_RECORD_MODAL_CLASSNAME} from '../_constants';\nimport {SUCCESS_ALERT_DURATION} from '_ui/constants';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faPlus} from '@fortawesome/free-solid-svg-icons';\n\n/**\n * Hook used to get the action for the `<DataView />` component.\n *\n * When the creation is done, we refresh all data even if the new record is not visible due to some filters.\n *\n * It returns also two parts: one for the call action button - one for displaying the modal required by the action.\n *\n * @param isEnabled - whether the action is present\n * @param isVisible - whether the button should be visible or not\n * @param libraryId - the library's id to add new item\n * @param entrypoint - represent the current entrypoint\n * @param totalCount - used for display purpose only\n * @param onCreate - callback to let outside world known about creating item (and linking)\n * @param refetch - method to call to refresh the list. A new item will be visible if it matches filters and sorts\n */\nexport const useCreatePrimaryAction = ({\n isEnabled,\n isVisible,\n libraryId,\n entrypoint,\n totalCount,\n canCreateAndLinkValue,\n isMultivalue,\n onCreate,\n formId,\n joinLibraryContext,\n refetch,\n}: FeatureHook<{\n libraryId: string;\n entrypoint: Entrypoint;\n totalCount: number;\n canCreateAndLinkValue: boolean;\n isMultivalue: boolean;\n onCreate?: ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => void;\n joinLibraryContext?: JoinLibraryContextFragment;\n formId?: string;\n refetch: () => void;\n}>) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n\n const [isModalCreationVisible, setIsModalCreationVisible] = useState(false);\n const {saveValues} = useSaveValueBatchMutation();\n\n const _getLibraryId = () =>\n (joinLibraryContext?.mandatoryAttribute &&\n 'linked_library' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_library?.id) ||\n libraryId;\n\n const {data, loading, error} = useExplorerLibraryDetailsQuery({\n variables: {libraryId: _getLibraryId()},\n skip: !isEnabled,\n });\n\n const hasCreateRecordPermission = data?.libraries?.list[0]?.permissions?.create_record ?? false;\n\n if (error || loading || !isVisible || !hasCreateRecordPermission) {\n return {createPrimaryAction: null, createModal: null};\n }\n\n let canCreateRecord;\n if (joinLibraryContext?.mandatoryAttribute?.type === AttributeType.tree) {\n canCreateRecord = false;\n } else if (entrypoint.type === 'library') {\n canCreateRecord = true;\n } else {\n canCreateRecord = canCreateAndLinkValue && (isMultivalue || totalCount === 0);\n }\n\n const _createPrimaryAction: IPrimaryAction = {\n callback: () => {\n setIsModalCreationVisible(true);\n },\n icon: <FontAwesomeIcon icon={faPlus} />,\n disabled: !canCreateRecord,\n label: t('explorer.create-one'),\n };\n\n const _notifyNewCreation = (label?: string | null) => {\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_ALERT_DURATION,\n message: t('items_list.created_in_success.message', {\n libName:\n localizedTranslation(data?.libraries?.list[0]?.label, lang) ||\n t('items_list.created_in_success.item'),\n }),\n description: t('items_list.created_in_success.description', {\n libName:\n localizedTranslation(data?.libraries?.list[0]?.label, lang) ||\n t('items_list.created_in_success.item'),\n itemName: label || t('items_list.created_in_success.item'),\n }),\n closable: true,\n });\n };\n\n let _createModal: ReactElement | null = null;\n switch (data?.libraries?.list[0]?.behavior) {\n case LibraryBehavior.files:\n _createModal = (\n <UploadFiles\n libraryId={_getLibraryId()}\n multiple\n onClose={() => setIsModalCreationVisible(false)}\n onCompleted={() => {\n refetch();\n _notifyNewCreation(t('upload.file'));\n setIsModalCreationVisible(false);\n }}\n />\n );\n break;\n case LibraryBehavior.directories:\n _createModal = (\n <CreateDirectory\n libraryId={_getLibraryId()}\n onClose={() => setIsModalCreationVisible(false)}\n onCompleted={() => {\n refetch();\n _notifyNewCreation(t('upload.folder'));\n setIsModalCreationVisible(false);\n }}\n />\n );\n break;\n case LibraryBehavior.standard:\n case LibraryBehavior.join:\n _createModal = (\n <EditRecordModal\n className={CREATE_RECORD_MODAL_CLASSNAME}\n open\n record={null}\n library={_getLibraryId()}\n creationFormId={formId}\n onClose={() => {\n setIsModalCreationVisible(false);\n }}\n onCreate={async newRecord => {\n _notifyNewCreation(newRecord.label);\n setIsModalCreationVisible(false);\n if (entrypoint.type === 'link') {\n await saveValues(\n {\n id: entrypoint.parentRecordId,\n library: {\n id: entrypoint.parentLibraryId,\n },\n },\n [\n {\n attribute: entrypoint.linkAttributeId,\n idValue: null,\n value: newRecord.id,\n },\n ],\n ).then(async saveValuesResult =>\n onCreate?.({\n recordIdCreated: newRecord.id,\n saveValuesResultOnLink: saveValuesResult,\n }),\n );\n } else {\n await Promise.resolve(onCreate?.({recordIdCreated: newRecord.id}));\n }\n refetch();\n }}\n submitButtons={['create']}\n />\n );\n break;\n }\n\n return {\n createPrimaryAction: isEnabled ? _createPrimaryAction : null,\n createModal: isModalCreationVisible ? _createModal : null,\n };\n};\n"]}
1
+ {"version":3,"file":"useCreatePrimaryAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-primary/useCreatePrimaryAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAoB,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,eAAe,EAAE,eAAe,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,yBAAyB,MAAM,uFAAuF,CAAC;AAE9H,OAAO,EACH,aAAa,EAEb,eAAe,EACf,8BAA8B,GACjC,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,6BAA6B,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACnC,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,OAAO,EACP,YAAY,GAkBd,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC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,CAAC,eAAe;gCACrC,OAAO,EAAE,IAAI;gCACb,KAAK,EAAE,SAAS,CAAC,EAAE;6BACtB;yBACJ,CACJ,CAAC,IAAI,CAAC,KAAK,EAAC,gBAAgB,EAAC,EAAE,CAC5B,QAAQ,EAAE,CAAC;4BACP,eAAe,EAAE,SAAS,CAAC,EAAE;4BAC7B,sBAAsB,EAAE,gBAAgB;yBAC3C,CAAC,CACL,CAAC;oBACN,CAAC;yBAAM,CAAC;wBACJ,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAC,eAAe,EAAE,SAAS,CAAC,EAAE,EAAC,CAAC,CAAC,CAAC;oBACvE,CAAC;oBACD,OAAO,EAAE,CAAC;oBACV,YAAY,EAAE,CAAC;gBACnB,CAAC,EACD,aAAa,EAAE,CAAC,QAAQ,CAAC,GAC3B,CACL,CAAC;YACF,MAAM;IACd,CAAC;IAED,OAAO;QACH,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI;QAC5D,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI;KAC5D,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ReactElement, useState} from 'react';\nimport {KitAlert} from 'aristid-ds';\nimport {CreateDirectory, EditRecordModal, UploadFiles} from '_ui/components';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport useSaveValueBatchMutation from '_ui/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {\n AttributeType,\n type JoinLibraryContextFragment,\n LibraryBehavior,\n useExplorerLibraryDetailsQuery,\n} from '_ui/_gqlTypes';\nimport {type FeatureHook, type Entrypoint, type IPrimaryAction} from '../_types';\nimport {CREATE_RECORD_MODAL_CLASSNAME} from '../_constants';\nimport {SUCCESS_ALERT_DURATION} from '_ui/constants';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faPlus} from '@fortawesome/free-solid-svg-icons';\n\n/**\n * Hook used to get the action for the `<DataView />` component.\n *\n * When the creation is done, we refresh all data even if the new record is not visible due to some filters.\n *\n * It returns also two parts: one for the call action button - one for displaying the modal required by the action.\n *\n * @param isEnabled - whether the action is present\n * @param isVisible - whether the button should be visible or not\n * @param libraryId - the library's id to add new item\n * @param entrypoint - represent the current entrypoint\n * @param totalCount - used for display purpose only\n * @param onCreate - callback to let outside world known about creating item (and linking)\n * @param refetch - method to call to refresh the list. A new item will be visible if it matches filters and sorts\n * @param refetchCount - method to call to refresh the count of the library. A new item will be visible if it matches filters and sorts\n */\nexport const useCreatePrimaryAction = ({\n isEnabled,\n isVisible,\n libraryId,\n entrypoint,\n totalCount,\n canCreateAndLinkValue,\n isMultivalue,\n onCreate,\n formId,\n joinLibraryContext,\n refetch,\n refetchCount,\n}: FeatureHook<{\n libraryId: string;\n entrypoint: Entrypoint;\n totalCount: number;\n canCreateAndLinkValue: boolean;\n isMultivalue: boolean;\n onCreate?: ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => void;\n joinLibraryContext?: JoinLibraryContextFragment;\n formId?: string;\n refetch: () => void;\n refetchCount: () => void;\n}>) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n\n const [isModalCreationVisible, setIsModalCreationVisible] = useState(false);\n const {saveValues} = useSaveValueBatchMutation();\n\n const _getLibraryId = () =>\n (joinLibraryContext?.mandatoryAttribute &&\n 'linked_library' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_library?.id) ||\n libraryId;\n\n const {data, loading, error} = useExplorerLibraryDetailsQuery({\n variables: {libraryId: _getLibraryId()},\n skip: !isEnabled,\n });\n\n const hasCreateRecordPermission = data?.libraries?.list[0]?.permissions?.create_record ?? false;\n\n if (error || loading || !isVisible || !hasCreateRecordPermission) {\n return {createPrimaryAction: null, createModal: null};\n }\n\n let canCreateRecord;\n if (joinLibraryContext?.mandatoryAttribute?.type === AttributeType.tree) {\n canCreateRecord = false;\n } else if (entrypoint.type === 'library') {\n canCreateRecord = true;\n } else {\n canCreateRecord = canCreateAndLinkValue && (isMultivalue || totalCount === 0);\n }\n\n const _createPrimaryAction: IPrimaryAction = {\n callback: () => {\n setIsModalCreationVisible(true);\n },\n icon: <FontAwesomeIcon icon={faPlus} />,\n disabled: !canCreateRecord,\n label: t('explorer.create-one'),\n };\n\n const _notifyNewCreation = (label?: string | null) => {\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_ALERT_DURATION,\n message: t('items_list.created_in_success.message', {\n libName:\n localizedTranslation(data?.libraries?.list[0]?.label, lang) ||\n t('items_list.created_in_success.item'),\n }),\n description: t('items_list.created_in_success.description', {\n libName:\n localizedTranslation(data?.libraries?.list[0]?.label, lang) ||\n t('items_list.created_in_success.item'),\n itemName: label || t('items_list.created_in_success.item'),\n }),\n closable: true,\n });\n };\n\n let _createModal: ReactElement | null = null;\n switch (data?.libraries?.list[0]?.behavior) {\n case LibraryBehavior.files:\n _createModal = (\n <UploadFiles\n libraryId={_getLibraryId()}\n multiple\n onClose={() => setIsModalCreationVisible(false)}\n onCompleted={() => {\n refetch();\n refetchCount();\n _notifyNewCreation(t('upload.file'));\n setIsModalCreationVisible(false);\n }}\n />\n );\n break;\n case LibraryBehavior.directories:\n _createModal = (\n <CreateDirectory\n libraryId={_getLibraryId()}\n onClose={() => setIsModalCreationVisible(false)}\n onCompleted={() => {\n refetch();\n refetchCount();\n _notifyNewCreation(t('upload.folder'));\n setIsModalCreationVisible(false);\n }}\n />\n );\n break;\n case LibraryBehavior.standard:\n case LibraryBehavior.join:\n _createModal = (\n <EditRecordModal\n className={CREATE_RECORD_MODAL_CLASSNAME}\n open\n record={null}\n library={_getLibraryId()}\n creationFormId={formId}\n onClose={() => {\n setIsModalCreationVisible(false);\n }}\n onCreate={async newRecord => {\n _notifyNewCreation(newRecord.label);\n setIsModalCreationVisible(false);\n if (entrypoint.type === 'link') {\n await saveValues(\n {\n id: entrypoint.parentRecordId,\n library: {\n id: entrypoint.parentLibraryId,\n },\n },\n [\n {\n attribute: entrypoint.linkAttributeId,\n idValue: null,\n value: newRecord.id,\n },\n ],\n ).then(async saveValuesResult =>\n onCreate?.({\n recordIdCreated: newRecord.id,\n saveValuesResultOnLink: saveValuesResult,\n }),\n );\n } else {\n await Promise.resolve(onCreate?.({recordIdCreated: newRecord.id}));\n }\n refetch();\n refetchCount();\n }}\n submitButtons={['create']}\n />\n );\n break;\n }\n\n return {\n createPrimaryAction: isEnabled ? _createPrimaryAction : null,\n createModal: isModalCreationVisible ? _createModal : null,\n };\n};\n"]}
@@ -746,8 +746,8 @@
746
746
  "copied": "Copied"
747
747
  },
748
748
  "massAction": {
749
- "itemsTotal_one": "{{count, number}} item",
750
- "itemsTotal_other": "{{count, number}} items",
749
+ "results_one": "result",
750
+ "results_other": "results",
751
751
  "selectedItems_one": "{{count, number}} selected",
752
752
  "selectedItems_other": "{{count, number}} selected",
753
753
  "deactivate": "Deactivate",
@@ -746,8 +746,8 @@
746
746
  "copied": "Copié"
747
747
  },
748
748
  "massAction": {
749
- "itemsTotal_one": "{{count, number}} élément",
750
- "itemsTotal_other": "{{count, number}} éléments",
749
+ "results_one": "résultat",
750
+ "results_other": "résultats",
751
751
  "selectedItems_one": "{{count, number}} sélectionné",
752
752
  "selectedItems_other": "{{count, number}} sélectionnés",
753
753
  "deactivate": "Supprimer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leav/ui",
3
- "version": "1.9.0-caa4797b",
3
+ "version": "1.9.0-e09e8fd5",
4
4
  "description": "Shared React components and hooks",
5
5
  "scripts": {
6
6
  "prepublishOnly": "yarn build",
@@ -44,7 +44,7 @@
44
44
  "@types/react": "18.2.14",
45
45
  "@types/react-dom": "18.2.6",
46
46
  "@types/react-table": "7.7.20",
47
- "aristid-ds": "15.0.0-06322cf",
47
+ "aristid-ds": "15.0.0-6a7cc18",
48
48
  "babel-jest": "29.7.0",
49
49
  "graphql": "16.12.0",
50
50
  "i18next": "22.5.1",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@apollo/client": ">=3.8.1",
65
- "aristid-ds": "15.0.0-06322cf",
65
+ "aristid-ds": "15.0.0-6a7cc18",
66
66
  "i18next": ">=22.5.1",
67
67
  "react": "^18.2.0",
68
68
  "react-dom": "^18.2.0",