@leaflink/stash 50.11.0 → 50.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/Accordion.js +30 -31
  2. package/dist/Accordion.js.map +1 -1
  3. package/dist/Accordion.vue.d.ts +6 -1
  4. package/dist/ActionsDropdown.js +2 -2
  5. package/dist/AddressSelect.js +2 -2
  6. package/dist/Alert.js +6 -6
  7. package/dist/AppNavigationItem.js +8 -8
  8. package/dist/AppNavigationItem.vue.d.ts +5 -0
  9. package/dist/AppSidebar.js +9 -9
  10. package/dist/AppSidebar.js.map +1 -1
  11. package/dist/AppTopbar.js +3 -3
  12. package/dist/Avatar.js +3 -3
  13. package/dist/Backdrop.js +2 -2
  14. package/dist/Badge.js +2 -2
  15. package/dist/Box.js +1 -1
  16. package/dist/{Box.vue_vue_type_script_setup_true_lang-DgJHq-09.js → Box.vue_vue_type_script_setup_true_lang-rFnvwLVY.js} +3 -3
  17. package/dist/{Box.vue_vue_type_script_setup_true_lang-DgJHq-09.js.map → Box.vue_vue_type_script_setup_true_lang-rFnvwLVY.js.map} +1 -1
  18. package/dist/Button.js +3 -3
  19. package/dist/ButtonGroup.js +4 -4
  20. package/dist/Card.js +7 -7
  21. package/dist/CardContent.js +2 -2
  22. package/dist/CardFooter.js +2 -2
  23. package/dist/CardHeader.js +4 -4
  24. package/dist/CardMedia.js +6 -6
  25. package/dist/Carousel.js +33 -33
  26. package/dist/Carousel.js.map +1 -1
  27. package/dist/Checkbox.js +7 -7
  28. package/dist/ChevronToggle.js +1 -1
  29. package/dist/{ChevronToggle.vue_vue_type_script_setup_true_lang-DuvluoTi.js → ChevronToggle.vue_vue_type_script_setup_true_lang-Ce_qOXfR.js} +3 -3
  30. package/dist/{ChevronToggle.vue_vue_type_script_setup_true_lang-DuvluoTi.js.map → ChevronToggle.vue_vue_type_script_setup_true_lang-Ce_qOXfR.js.map} +1 -1
  31. package/dist/Chip.js +7 -7
  32. package/dist/ConfirmationCodeInput.js +6 -6
  33. package/dist/ContextSwitcher.js +1 -1
  34. package/dist/Copy.js +1 -1
  35. package/dist/CurrencyInput.js +115 -111
  36. package/dist/CurrencyInput.js.map +1 -1
  37. package/dist/DataView.js +102 -98
  38. package/dist/DataView.js.map +1 -1
  39. package/dist/{DataView.keys-C7eaZg2G.js → DataView.keys-aSOnA4AD.js} +2 -1
  40. package/dist/DataView.keys-aSOnA4AD.js.map +1 -0
  41. package/dist/DataView.vue.d.ts +11 -0
  42. package/dist/DataViewFilters.js +4 -4
  43. package/dist/DataViewSortButton.js +11 -11
  44. package/dist/DataViewToolbar.js +61 -60
  45. package/dist/DataViewToolbar.js.map +1 -1
  46. package/dist/DatePicker.js +1080 -1037
  47. package/dist/DatePicker.js.map +1 -1
  48. package/dist/DescriptionList.js +2 -2
  49. package/dist/DescriptionListDetail.js +2 -2
  50. package/dist/DescriptionListGroup.js +2 -2
  51. package/dist/DescriptionListTerm.js +3 -3
  52. package/dist/Dialog.js +1 -1
  53. package/dist/Divider.js +2 -2
  54. package/dist/Dropdown.js +19 -19
  55. package/dist/Dropdown.js.map +1 -1
  56. package/dist/EmptyState.js +2 -2
  57. package/dist/Expand.js +1 -1
  58. package/dist/{Expand.vue_vue_type_script_setup_true_lang-D0fSAtHr.js → Expand.vue_vue_type_script_setup_true_lang-CiONJfAp.js} +5 -5
  59. package/dist/{Expand.vue_vue_type_script_setup_true_lang-D0fSAtHr.js.map → Expand.vue_vue_type_script_setup_true_lang-CiONJfAp.js.map} +1 -1
  60. package/dist/Field.js +1 -1
  61. package/dist/{Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js → Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js} +6 -6
  62. package/dist/Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js.map +1 -0
  63. package/dist/FileUpload.js +7 -7
  64. package/dist/FilterChip.js +1 -1
  65. package/dist/FilterDrawerItem.js +9 -9
  66. package/dist/FilterDropdown.js +2 -2
  67. package/dist/FilterSelect.js +4 -4
  68. package/dist/Filters.js +18 -18
  69. package/dist/Filters.js.map +1 -1
  70. package/dist/HttpError.js +9 -9
  71. package/dist/Icon.js +2 -2
  72. package/dist/Icon.js.map +1 -1
  73. package/dist/Icon.vue.d.ts +5 -0
  74. package/dist/IconLabel.js +2 -2
  75. package/dist/IconLabel.vue.d.ts +5 -0
  76. package/dist/Illustration.js +2 -2
  77. package/dist/{Illustration.vue_vue_type_script_setup_true_lang-CYddAFtS.js → Illustration.vue_vue_type_script_setup_true_lang-BBqgoJO8.js} +3 -3
  78. package/dist/{Illustration.vue_vue_type_script_setup_true_lang-CYddAFtS.js.map → Illustration.vue_vue_type_script_setup_true_lang-BBqgoJO8.js.map} +1 -1
  79. package/dist/Image.js +2 -2
  80. package/dist/{Image.vue_vue_type_script_setup_true_lang-YUNunj71.js → Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js} +3 -3
  81. package/dist/{Image.vue_vue_type_script_setup_true_lang-YUNunj71.js.map → Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js.map} +1 -1
  82. package/dist/InlineEdit.js +5 -5
  83. package/dist/InlineEdit.js.map +1 -1
  84. package/dist/Input.js +2 -2
  85. package/dist/InputOptions.js +2 -2
  86. package/dist/InputOptions.js.map +1 -1
  87. package/dist/IntegrationIcon.js +2 -2
  88. package/dist/Label.js +1 -1
  89. package/dist/{Label.vue_vue_type_script_setup_true_lang-C4JKdqvC.js → Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.js} +3 -3
  90. package/dist/{Label.vue_vue_type_script_setup_true_lang-C4JKdqvC.js.map → Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.js.map} +1 -1
  91. package/dist/LicenseChip.js +2 -2
  92. package/dist/ListItem.js +1 -1
  93. package/dist/ListItemCell.js +2 -2
  94. package/dist/ListView.js +11 -11
  95. package/dist/ListView.js.map +1 -1
  96. package/dist/ListView.vue.d.ts +38 -13
  97. package/dist/Loading.js +2 -2
  98. package/dist/Logo.js +1 -1
  99. package/dist/{Logo.vue_vue_type_script_setup_true_lang-BfUU9J9O.js → Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js} +4 -4
  100. package/dist/{Logo.vue_vue_type_script_setup_true_lang-BfUU9J9O.js.map → Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js.map} +1 -1
  101. package/dist/Menu.js +2 -2
  102. package/dist/MenuItem.js +2 -2
  103. package/dist/Metric.js +5 -5
  104. package/dist/Modal.js +20 -20
  105. package/dist/Modals.js +12 -12
  106. package/dist/Modals.js.map +1 -1
  107. package/dist/Module.js +3 -3
  108. package/dist/ModuleContent.js +3 -3
  109. package/dist/ModuleFooter.js +2 -2
  110. package/dist/ModuleHeader.js +2 -2
  111. package/dist/ModuleHeader.js.map +1 -1
  112. package/dist/ObfuscateText.js +7 -7
  113. package/dist/PageContent.js +3 -3
  114. package/dist/PageHeader.js +6 -6
  115. package/dist/PageNavigation.js +1 -1
  116. package/dist/Paginate.js +73 -55
  117. package/dist/Paginate.js.map +1 -1
  118. package/dist/Paginate.vue.d.ts +12 -1
  119. package/dist/PlaidLink.js +2 -2
  120. package/dist/QuickAction.js +2 -2
  121. package/dist/QuickAction.vue.d.ts +5 -0
  122. package/dist/Radio.js +2 -2
  123. package/dist/RadioGroup.js +2 -2
  124. package/dist/RadioNew.js +1 -1
  125. package/dist/RangeInput.js +2 -2
  126. package/dist/SearchBar.js +4 -4
  127. package/dist/SearchBar.js.map +1 -1
  128. package/dist/Select.js +7 -7
  129. package/dist/Select.js.map +1 -1
  130. package/dist/SelectStatus.js +19 -19
  131. package/dist/SelectStatus.js.map +1 -1
  132. package/dist/SelectStatus.vue.d.ts +5 -0
  133. package/dist/Skeleton.js +4 -4
  134. package/dist/Step.js +19 -19
  135. package/dist/Step.js.map +1 -1
  136. package/dist/Stepper.js +9 -9
  137. package/dist/Switch.js +7 -7
  138. package/dist/Tab.js +4 -4
  139. package/dist/TabPanel.js +2 -2
  140. package/dist/Table.js +6 -6
  141. package/dist/Table.js.map +1 -1
  142. package/dist/TableCell.js +7 -7
  143. package/dist/TableHeaderCell.js +4 -4
  144. package/dist/TableHeaderRow.js +5 -5
  145. package/dist/TableRow.js +5 -5
  146. package/dist/TableRow.js.map +1 -1
  147. package/dist/TableRow.vue.d.ts +12 -8
  148. package/dist/Tabs.js +2 -2
  149. package/dist/{Tabs.vue_vue_type_script_setup_true_lang-NZm1OrRT.js → Tabs.vue_vue_type_script_setup_true_lang-CmnBP4i1.js} +4 -4
  150. package/dist/{Tabs.vue_vue_type_script_setup_true_lang-NZm1OrRT.js.map → Tabs.vue_vue_type_script_setup_true_lang-CmnBP4i1.js.map} +1 -1
  151. package/dist/TextEditor.js +3314 -3291
  152. package/dist/TextEditor.js.map +1 -1
  153. package/dist/TextEditor.vue.d.ts +5 -0
  154. package/dist/Textarea.js +3 -3
  155. package/dist/Textarea.js.map +1 -1
  156. package/dist/Thumbnail.js +7 -7
  157. package/dist/Thumbnail.js.map +1 -1
  158. package/dist/ThumbnailEmpty.js +3 -3
  159. package/dist/ThumbnailGroup.js +6 -6
  160. package/dist/ThumbnailGroup.js.map +1 -1
  161. package/dist/{ThumbnailGroup.keys-D6WL5xQ5.js → ThumbnailGroup.keys-EJ4qFNhx.js} +2 -2
  162. package/dist/{ThumbnailGroup.keys-D6WL5xQ5.js.map → ThumbnailGroup.keys-EJ4qFNhx.js.map} +1 -1
  163. package/dist/Timeline.js +2 -2
  164. package/dist/TimelineItem.js +3 -3
  165. package/dist/Toast.js +277 -280
  166. package/dist/Toast.js.map +1 -1
  167. package/dist/Toasts.js +1 -1
  168. package/dist/Tooltip.js +1 -1
  169. package/dist/components.css +1 -1
  170. package/dist/directives/autofocus.js +2 -2
  171. package/dist/directives/autofocus.js.map +1 -1
  172. package/dist/directives/sticky.js.map +1 -1
  173. package/dist/{formatDateTime-C8CYECpd.js → formatDateTime-Dz8bXV0R.js} +98 -12
  174. package/dist/{formatDateTime-C8CYECpd.js.map → formatDateTime-Dz8bXV0R.js.map} +1 -1
  175. package/dist/index.js +2 -2
  176. package/dist/index.js.map +1 -1
  177. package/dist/locale.js +3 -2
  178. package/dist/locale.js.map +1 -1
  179. package/dist/searchFuzzy-DRasJ33G.js +409 -0
  180. package/dist/{searchFuzzy-DKooyZM8.js.map → searchFuzzy-DRasJ33G.js.map} +1 -1
  181. package/dist/storage.js +3 -3
  182. package/dist/tailwind-base.js +0 -2
  183. package/dist/tailwind-base.js.map +1 -1
  184. package/dist/{toTimeZone-CVE1ZmsS.js → toTimeZone-Coq1oPTt.js} +7 -9
  185. package/dist/{toTimeZone-CVE1ZmsS.js.map → toTimeZone-Coq1oPTt.js.map} +1 -1
  186. package/dist/useModals.js.map +1 -1
  187. package/dist/usePaginationStats-d_q39naC.js +12 -0
  188. package/dist/usePaginationStats-d_q39naC.js.map +1 -0
  189. package/dist/useSearch.js +1 -1
  190. package/dist/useSelection.js +4 -1
  191. package/dist/useSelection.js.map +1 -1
  192. package/dist/useValidation.js +39 -36
  193. package/dist/useValidation.js.map +1 -1
  194. package/dist/utils/formatDateTime.js +2 -2
  195. package/dist/utils/helpers.js +29 -29
  196. package/dist/utils/helpers.js.map +1 -1
  197. package/dist/utils/searchFuzzy.js +1 -1
  198. package/dist/utils/toTimeZone.js +1 -1
  199. package/package.json +42 -20
  200. package/tailwind-base.ts +0 -2
  201. package/types/jsonApi.ts +8 -8
  202. package/dist/DataView.keys-C7eaZg2G.js.map +0 -1
  203. package/dist/Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js.map +0 -1
  204. package/dist/searchFuzzy-DKooyZM8.js +0 -407
@@ -1 +1 @@
1
- {"version":3,"file":"DataView.js","sources":["../src/components/DataView/DataView.utils.ts","../src/components/DataView/DataView.types.ts","../src/components/DataView/DataView.vue"],"sourcesContent":["import { SortId, SortOrder, SortValue, SortValueDeserialized } from './DataView.types';\n\n/**\n * Receives a SortValue (ex: `'-product_name'`) and returns an object with a `id` and an `order`.\n */\nexport function deserializeSortValue(sort: SortValue): SortValueDeserialized {\n const order = sort[0] === '-' ? 'desc' : 'asc';\n const id = order === 'asc' ? sort : sort.slice(1);\n\n return { id, order };\n}\n\n/**\n * Receives an object with a `id` and an `order` and returns a SortValue (ex: `'-product_name'`).\n */\nexport function serializeSortValue({ id, order }: SortValueDeserialized): SortValue {\n return `${order === 'desc' ? '-' : ''}${id}`;\n}\n\ninterface GetNextSortArgs {\n newId: SortId | undefined;\n newOrder?: SortOrder;\n oldId?: SortId;\n oldOrder?: SortOrder;\n}\n\n/**\n * Given new and old sorting data, it returns the next sorting value using the following sorting cycle:\n *\n * \"unsorted --> ascending --> descending --> unsorted\"\n */\nexport function getNextSort({ newId, newOrder, oldId, oldOrder }: GetNextSortArgs): SortValue | undefined {\n if (!newId) {\n return undefined;\n }\n\n if (newId !== oldId) {\n // if sorting by a new field, sort ascending\n return serializeSortValue({ id: newId, order: newOrder || 'asc' });\n }\n\n /**\n * `newOrder` and `oldOrder` can each have 3 different values: undefined, 'asc', or 'desc'.\n * Therefore, there are 9 possible combinations (3 times 3). See below:\n */\n\n // #region newOrder: undefined\n if (!newOrder && !oldOrder) {\n return newId; // ascending\n }\n\n if (!newOrder && oldOrder === 'desc') {\n return undefined; // unsorted\n }\n\n if (!newOrder && oldOrder === 'asc') {\n return `-${newId}`; // descending\n }\n // #endregion\n\n // #region newOrder: asc\n if (newOrder === 'asc' && !oldOrder) {\n return newId;\n }\n\n if (newOrder === 'asc' && oldOrder === 'asc') {\n return undefined;\n }\n\n if (newOrder === 'asc' && oldOrder === 'desc') {\n return newId;\n }\n // #endregion\n\n // #region newOrder: desc\n if (newOrder === 'desc' && !oldOrder) {\n return `-${newId}`;\n }\n\n if (newOrder === 'desc' && oldOrder === 'desc') {\n return undefined;\n }\n\n if (newOrder === 'desc' && oldOrder === 'asc') {\n return `-${newId}`;\n }\n // #endregion\n}\n","import { ComputedRef, Ref } from 'vue';\n\nimport { SpacingDensities } from '../../../types/misc';\n\nexport enum DataViewVariant {\n Table = 'table',\n}\n\nexport type DataViewVariants = `${DataViewVariant}`;\n\n/**\n * A unique id for a sorting strategy. If the order is descending, it must begin with \"-\" (a hyphen/dash).\n *\n * Ex: `'product_name'` if ascending or `'-product_name'` if descending\n */\nexport type SortValue = string;\n\n/**\n * The SortValue with its leading hyphen/dash removed\n */\nexport type SortId = string;\n\n/**\n * Determined by whether or not there is a leading hyphen/dash in the SortValue\n */\nexport type SortOrder = 'asc' | 'desc';\n\n/**\n * A deserialized instance of a `SortValue`.\n */\nexport type SortValueDeserialized = {\n id: SortId;\n order: SortOrder;\n};\n\n/** Updates the DataView internal state with the given sortId */\nexport type UpdateCurrentSort = (\n sortId: SortId | undefined,\n options?: {\n sortOrder?: SortOrder;\n /** If true, emits the `update:currentSort` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the given page */\nexport type SetPage = (\n page: number,\n options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the previous page */\nexport type GoPrevPage = (options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n}) => void;\n\n/** Updates the DataView internal state with the next page */\nexport type GoNextPage = (options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n}) => void;\n\n/** Updates the DataView internal state with the given searchTerm */\nexport type UpdateCurrentSearch = (\n searchTerm?: string,\n options?: {\n /** If true, emits the `update:currentSearch` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the given filter values */\nexport type UpdateCurrentFilters<FilterValues = object> = (\n newFilters: FilterValues,\n options?: {\n /** If true, emits the `update:currentSearch` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\nexport interface UpdateEvent<FilterValues = object> {\n page?: number;\n pageSize?: number;\n ordering?: string;\n search?: string;\n filters?: FilterValues;\n}\n\nexport interface DataViewInjection {\n currentPage: ComputedRef<number>;\n\n isPaginationEnabled: ComputedRef<boolean>;\n\n pageCount: ComputedRef<number>;\n\n pageSize: ComputedRef<number>;\n\n totalDataCount: ComputedRef<number>;\n\n /** Updates the DataView internal state with the given page */\n setPage: SetPage;\n\n /** Updates the DataView internal state with the previous page */\n goPrevPage: GoPrevPage;\n\n /** Updates the DataView internal state with the next page */\n goNextPage: GoNextPage;\n\n currentSortId: ComputedRef<SortId | undefined>;\n\n currentSortOrder: ComputedRef<SortOrder | undefined>;\n\n /** Updates the DataView internal state with the given sortId */\n updateCurrentSort: UpdateCurrentSort;\n\n currentSearch: ComputedRef<string>;\n\n /** Updates the DataView internal state with the given searchTerm */\n updateCurrentSearch: UpdateCurrentSearch;\n\n /**\n * The DataView's padding; the default value is \"comfortable\". On small screens, the density will always be \"compact\".\n */\n density: ComputedRef<SpacingDensities | undefined>;\n\n /**\n * Defines if a DataView has a Toolbar rendered. This prop is updated when DataViewToolbar exists and is mounted.\n */\n hasToolbar?: Ref<boolean>;\n\n /**\n * Enables certain loading indicators to be displayed within the DataView.\n */\n isLoading?: ComputedRef<boolean>;\n\n /**\n * Enables certain empty states to be displayed within the DataView.\n */\n isEmpty?: ComputedRef<boolean>;\n\n /**\n * Allows Table to control whether or not a DataViewToolbar should show a checkmark\n */\n isSelectable?: Ref<boolean>;\n\n /**\n * Whether or not the DataView is rendered within a Module; the value is inferred based on being\n * able to inject details from Module.\n *\n * Note: This is sent to DataView child components so they only need to worry about interfacing\n * with the DataViewInjection API.\n */\n isWithinModule: ComputedRef<boolean>;\n\n /**\n * The DataView's variant; the default value is undefined.\n */\n variant: ComputedRef<DataViewVariants | undefined>;\n}\n","<script lang=\"ts\">\n export * from './DataView.constants';\n export * from './DataView.keys';\n export * from './DataView.types';\n export * from './DataView.utils';\n</script>\n\n<script setup lang=\"ts\">\n import cloneDeep from 'lodash-es/cloneDeep';\n import { computed, inject, provide, ref, useCssModule, watch } from 'vue';\n\n import { SpacingDensities } from '../../../types/misc';\n import { MODULE_INJECTION } from '../Module/Module.keys';\n import Paginate from '../Paginate/Paginate.vue';\n import { DEFAULT_PAGE_SIZE } from './DataView.constants';\n import { DATA_VIEW_INJECTION } from './DataView.keys';\n import {\n DataViewVariants,\n GoNextPage,\n GoPrevPage,\n SetPage,\n SortId,\n SortOrder,\n SortValue,\n UpdateCurrentFilters,\n UpdateCurrentSearch,\n UpdateCurrentSort,\n UpdateEvent,\n } from './DataView.types';\n import { deserializeSortValue, getNextSort } from './DataView.utils';\n\n export interface DataViewProps {\n /**\n * Can be used to provide the initial page.\n * Also, it can be used to control the active page with `v-model:current-page=\"myPage\"`.\n */\n currentPage?: number;\n\n /**\n * Can be used to set the initial search term.\n * Also, it can be used to control the active search term with `v-model:current-search=\"mySearchTerm\"`.\n */\n currentSearch?: string;\n\n /**\n * Can be used to provide the initial sort order.\n * Also, it can be used to control the active sort order with `v-model:current-sort=\"mySortOrder\"`.\n */\n currentSort?: SortValue;\n\n /**\n * A list of records. If pagination is enabled, `data` must be only the current page of records.\n */\n data?: object[];\n\n /**\n * Controls the DataView's padding; the default value is \"comfortable\". On small screens, \"compact\" density is applied regardless of this prop's value.\n */\n density?: SpacingDensities;\n\n pageSize?: number;\n\n /**\n * Opt-out of displaying pagination. Hides the pagination buttons and page stats.\n */\n disablePagination?: boolean;\n\n /**\n * Hides the bottom pagination without disabling the pagination from the toolbar\n */\n hideBottomPagination?: boolean;\n\n /**\n * The total number of records available.\n * Used to auto-enable pagination when results exist.\n * DataView does not paginate data for you; instead, `props.data` should always show\n * the current page of results.\n */\n totalDataCount?: number;\n\n /**\n * DataView variant. The default value is `undefined`. Will default to `table` when used within\n * a `<Module variant=\"table\">`.\n */\n variant?: DataViewVariants;\n\n isLoading?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewProps>(), {\n currentPage: 1,\n currentSearch: undefined,\n currentSort: undefined,\n data: () => [],\n density: 'comfortable',\n pageSize: DEFAULT_PAGE_SIZE,\n disablePagination: false,\n totalDataCount: 0,\n hideBottomPagination: false,\n variant: undefined,\n });\n\n const emit = defineEmits<{\n (e: 'update', state: UpdateEvent): void;\n (e: 'update:currentFilters', newFilters: object): void;\n (e: 'update:currentPage', page: number, pageSize: number): void;\n (e: 'update:currentSearch', searchTerm?: string): void;\n (e: 'update:currentSort', payload?: SortValue): void;\n }>();\n\n const classes = useCssModule();\n const rootRef = ref<HTMLElement | null>(null);\n const moduleInjection = inject(MODULE_INJECTION.key, MODULE_INJECTION.defaults);\n const computedVariant = computed<DataViewVariants | undefined>(() => {\n if (props.variant) {\n return props.variant;\n }\n\n if (moduleInjection.variant?.value === 'table') {\n return 'table';\n }\n\n return undefined;\n });\n const isWithinModule = computed(() => moduleInjection.variant !== undefined);\n\n // #region pagination\n const internalPage = ref(1);\n const isPaginationEnabled = computed(() => !props.disablePagination && props.totalDataCount > 0);\n const pageCount = computed(() => Math.ceil(props.totalDataCount / props.pageSize));\n\n const setPage: SetPage = function (page: number, { shouldEmit } = {}) {\n internalPage.value = page;\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentPage', page, props.pageSize);\n }\n\n if (Number(rootRef.value?.getBoundingClientRect().top) < 0) {\n rootRef.value?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n }\n };\n\n const goPrevPage: GoPrevPage = function ({ shouldEmit } = {}) {\n const page = Math.max(internalPage.value - 1, 1);\n\n setPage(page, { shouldEmit });\n };\n\n /** Updates the DataView internal state with the previous page */\n const goNextPage: GoNextPage = function ({ shouldEmit } = {}) {\n const page = Math.min(internalPage.value + 1, pageCount.value);\n\n setPage(page, { shouldEmit });\n };\n\n watch(\n () => props.currentPage,\n () => {\n setPage(props.currentPage);\n },\n { immediate: true },\n );\n // #endregion pagination\n\n // #region sorting\n const internalSort = ref<SortValue | undefined>(undefined);\n\n const internalSortId = computed<SortId | undefined>(() =>\n internalSort.value ? deserializeSortValue(internalSort.value).id : undefined,\n );\n const internalSortOrder = computed<SortOrder | undefined>(() =>\n internalSort.value ? deserializeSortValue(internalSort.value).order : undefined,\n );\n\n const updateCurrentSort: UpdateCurrentSort = function (sortId, { sortOrder, shouldEmit } = {}) {\n const { id: oldId, order: oldOrder } = deserializeSortValue(internalSort.value || '');\n const nextSort = getNextSort({ newId: sortId, newOrder: sortOrder, oldId, oldOrder });\n\n internalSort.value = nextSort;\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentSort', nextSort);\n }\n };\n\n watch(\n () => props.currentSort,\n () => {\n updateCurrentSort(props.currentSort);\n },\n { immediate: true },\n );\n // #endregion sorting\n\n // #region search\n const internalSearch = ref('');\n\n const hasToolbar = ref(false);\n const isSelectable = ref(false);\n\n const updateCurrentSearch: UpdateCurrentSearch = function (searchTerm, { shouldEmit } = {}) {\n internalSearch.value = searchTerm || '';\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentSearch', searchTerm);\n }\n };\n\n watch(\n () => props.currentSearch,\n () => {\n updateCurrentSearch(props.currentSearch);\n },\n { immediate: true },\n );\n // #endregion search\n\n // #region filters\n const internalFilters = ref<object>({});\n\n const updateCurrentFilters: UpdateCurrentFilters = function (newFilters: object, { shouldEmit } = {}) {\n internalFilters.value = newFilters;\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentFilters', newFilters);\n }\n };\n // #endregion filters\n\n function emitUpdate() {\n emit('update', {\n page: internalPage.value,\n pageSize: props.pageSize,\n ordering: internalSort.value,\n search: internalSearch.value,\n filters: cloneDeep(internalFilters.value),\n });\n }\n\n provide(\n DATA_VIEW_INJECTION.key,\n Object.freeze({\n // Pagination\n currentPage: computed(() => internalPage.value),\n isPaginationEnabled,\n pageCount,\n pageSize: computed(() => props.pageSize),\n totalDataCount: computed(() => props.totalDataCount),\n setPage,\n goPrevPage,\n goNextPage,\n\n // Sorting\n currentSortId: internalSortId,\n currentSortOrder: internalSortOrder,\n updateCurrentSort,\n\n // Search\n currentSearch: computed(() => internalSearch.value),\n updateCurrentSearch,\n\n // Miscellaneous\n density: computed(() => props.density),\n hasToolbar,\n isEmpty: computed(() => props.data.length === 0),\n isSelectable,\n isLoading: computed(() => props.isLoading),\n isWithinModule,\n variant: computedVariant,\n }),\n );\n\n defineExpose({\n page: computed(() => internalPage.value),\n pageSize: computed(() => props.pageSize),\n setPage,\n goPrevPage,\n goNextPage,\n ordering: computed(() => internalSort.value),\n updateCurrentSort,\n search: computed(() => internalSearch.value),\n updateCurrentSearch,\n filters: computed(() => internalFilters.value),\n updateCurrentFilters,\n });\n</script>\n\n<template>\n <div ref=\"rootRef\" class=\"stash-data-view tw-relative\" data-test=\"stash-data-view\">\n <!-- @slot default -->\n <slot\n :current-page=\"internalPage\"\n :current-sort-id=\"internalSortId\"\n :current-sort-order=\"internalSortOrder\"\n :data=\"data\"\n :go-prev-page=\"goPrevPage\"\n :go-next-page=\"goNextPage\"\n :page-count=\"pageCount\"\n :set-page=\"setPage\"\n :total-data-count=\"props.totalDataCount\"\n :update-current-sort=\"updateCurrentSort\"\n :update-current-search=\"updateCurrentSearch\"\n ></slot>\n\n <Paginate\n v-if=\"isPaginationEnabled && !isWithinModule && pageCount > 1 && !props.hideBottomPagination\"\n class=\"tw-mt-6\"\n :class=\"classes.paginate\"\n :current-page=\"internalPage\"\n :list-length=\"props.totalDataCount\"\n :page-size=\"props.pageSize\"\n @set-page=\"(page: number) => setPage(page, { shouldEmit: true })\"\n />\n </div>\n</template>\n\n<style module>\n .paginate ul {\n margin: 0;\n }\n</style>\n"],"names":["deserializeSortValue","sort","order","serializeSortValue","id","getNextSort","newId","newOrder","oldId","oldOrder","DataViewVariant","props","__props","emit","__emit","classes","useCssModule","rootRef","ref","moduleInjection","inject","MODULE_INJECTION","computedVariant","computed","_a","isWithinModule","internalPage","isPaginationEnabled","pageCount","setPage","page","shouldEmit","emitUpdate","_b","goPrevPage","goNextPage","watch","internalSort","internalSortId","internalSortOrder","updateCurrentSort","sortId","sortOrder","nextSort","internalSearch","hasToolbar","isSelectable","updateCurrentSearch","searchTerm","internalFilters","updateCur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,MACA,QAAQjB,EAAS,MAAMqB,EAAe,KAAK;AAAA,MAC3C,qBAAAG;AAAA,MACA,SAASxB,EAAS,MAAM0B,EAAgB,KAAK;AAAA,MAC7C,sBAAAC;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"DataView.js","sources":["../src/components/DataView/DataView.utils.ts","../src/components/DataView/DataView.types.ts","../src/components/DataView/DataView.vue"],"sourcesContent":["import { SortId, SortOrder, SortValue, SortValueDeserialized } from './DataView.types';\n\n/**\n * Receives a SortValue (ex: `'-product_name'`) and returns an object with a `id` and an `order`.\n */\nexport function deserializeSortValue(sort: SortValue): SortValueDeserialized {\n const order = sort[0] === '-' ? 'desc' : 'asc';\n const id = order === 'asc' ? sort : sort.slice(1);\n\n return { id, order };\n}\n\n/**\n * Receives an object with a `id` and an `order` and returns a SortValue (ex: `'-product_name'`).\n */\nexport function serializeSortValue({ id, order }: SortValueDeserialized): SortValue {\n return `${order === 'desc' ? '-' : ''}${id}`;\n}\n\ninterface GetNextSortArgs {\n newId: SortId | undefined;\n newOrder?: SortOrder;\n oldId?: SortId;\n oldOrder?: SortOrder;\n}\n\n/**\n * Given new and old sorting data, it returns the next sorting value using the following sorting cycle:\n *\n * \"unsorted --> ascending --> descending --> unsorted\"\n */\nexport function getNextSort({ newId, newOrder, oldId, oldOrder }: GetNextSortArgs): SortValue | undefined {\n if (!newId) {\n return undefined;\n }\n\n if (newId !== oldId) {\n // if sorting by a new field, sort ascending\n return serializeSortValue({ id: newId, order: newOrder || 'asc' });\n }\n\n /**\n * `newOrder` and `oldOrder` can each have 3 different values: undefined, 'asc', or 'desc'.\n * Therefore, there are 9 possible combinations (3 times 3). See below:\n */\n\n // #region newOrder: undefined\n if (!newOrder && !oldOrder) {\n return newId; // ascending\n }\n\n if (!newOrder && oldOrder === 'desc') {\n return undefined; // unsorted\n }\n\n if (!newOrder && oldOrder === 'asc') {\n return `-${newId}`; // descending\n }\n // #endregion\n\n // #region newOrder: asc\n if (newOrder === 'asc' && !oldOrder) {\n return newId;\n }\n\n if (newOrder === 'asc' && oldOrder === 'asc') {\n return undefined;\n }\n\n if (newOrder === 'asc' && oldOrder === 'desc') {\n return newId;\n }\n // #endregion\n\n // #region newOrder: desc\n if (newOrder === 'desc' && !oldOrder) {\n return `-${newId}`;\n }\n\n if (newOrder === 'desc' && oldOrder === 'desc') {\n return undefined;\n }\n\n if (newOrder === 'desc' && oldOrder === 'asc') {\n return `-${newId}`;\n }\n // #endregion\n}\n","import { ComputedRef, Ref } from 'vue';\n\nimport { SpacingDensities } from '../../../types/misc';\n\nexport enum DataViewVariant {\n Table = 'table',\n}\n\nexport type DataViewVariants = `${DataViewVariant}`;\n\n/**\n * A unique id for a sorting strategy. If the order is descending, it must begin with \"-\" (a hyphen/dash).\n *\n * Ex: `'product_name'` if ascending or `'-product_name'` if descending\n */\nexport type SortValue = string;\n\n/**\n * The SortValue with its leading hyphen/dash removed\n */\nexport type SortId = string;\n\n/**\n * Determined by whether or not there is a leading hyphen/dash in the SortValue\n */\nexport type SortOrder = 'asc' | 'desc';\n\n/**\n * A deserialized instance of a `SortValue`.\n */\nexport type SortValueDeserialized = {\n id: SortId;\n order: SortOrder;\n};\n\n/** Updates the DataView internal state with the given sortId */\nexport type UpdateCurrentSort = (\n sortId: SortId | undefined,\n options?: {\n sortOrder?: SortOrder;\n /** If true, emits the `update:currentSort` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the given page */\nexport type SetPage = (\n page: number,\n options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the previous page */\nexport type GoPrevPage = (options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n}) => void;\n\n/** Updates the DataView internal state with the next page */\nexport type GoNextPage = (options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n}) => void;\n\n/** Updates the DataView internal state with the given searchTerm */\nexport type UpdateCurrentSearch = (\n searchTerm?: string,\n options?: {\n /** If true, emits the `update:currentSearch` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the given filter values */\nexport type UpdateCurrentFilters<FilterValues = object> = (\n newFilters: FilterValues,\n options?: {\n /** If true, emits the `update:currentSearch` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\nexport interface UpdateEvent<FilterValues = object> {\n page?: number;\n pageSize?: number;\n ordering?: string;\n search?: string;\n filters?: FilterValues;\n}\n\nexport interface DataViewInjection {\n currentPage: ComputedRef<number>;\n\n /** Optional override for the next button disabled state */\n isPaginateNextDisabled: ComputedRef<boolean>;\n\n isPaginationEnabled: ComputedRef<boolean>;\n\n pageCount: ComputedRef<number>;\n\n pageSize: ComputedRef<number>;\n\n totalDataCount: ComputedRef<number>;\n\n /** Updates the DataView internal state with the given page */\n setPage: SetPage;\n\n /** Updates the DataView internal state with the previous page */\n goPrevPage: GoPrevPage;\n\n /** Updates the DataView internal state with the next page */\n goNextPage: GoNextPage;\n\n currentSortId: ComputedRef<SortId | undefined>;\n\n currentSortOrder: ComputedRef<SortOrder | undefined>;\n\n /** Updates the DataView internal state with the given sortId */\n updateCurrentSort: UpdateCurrentSort;\n\n currentSearch: ComputedRef<string>;\n\n /** Updates the DataView internal state with the given searchTerm */\n updateCurrentSearch: UpdateCurrentSearch;\n\n /**\n * The DataView's padding; the default value is \"comfortable\". On small screens, the density will always be \"compact\".\n */\n density: ComputedRef<SpacingDensities | undefined>;\n\n /**\n * Defines if a DataView has a Toolbar rendered. This prop is updated when DataViewToolbar exists and is mounted.\n */\n hasToolbar?: Ref<boolean>;\n\n /**\n * Enables certain loading indicators to be displayed within the DataView.\n */\n isLoading?: ComputedRef<boolean>;\n\n /**\n * Enables certain empty states to be displayed within the DataView.\n */\n isEmpty?: ComputedRef<boolean>;\n\n /**\n * Allows Table to control whether or not a DataViewToolbar should show a checkmark\n */\n isSelectable?: Ref<boolean>;\n\n /**\n * Whether or not the DataView is rendered within a Module; the value is inferred based on being\n * able to inject details from Module.\n *\n * Note: This is sent to DataView child components so they only need to worry about interfacing\n * with the DataViewInjection API.\n */\n isWithinModule: ComputedRef<boolean>;\n\n /**\n * The DataView's variant; the default value is undefined.\n */\n variant: ComputedRef<DataViewVariants | undefined>;\n}\n","<script lang=\"ts\">\n export * from './DataView.constants';\n export * from './DataView.keys';\n export * from './DataView.types';\n export * from './DataView.utils';\n</script>\n\n<script setup lang=\"ts\">\n import cloneDeep from 'lodash-es/cloneDeep';\n import { computed, inject, provide, ref, useCssModule, watch } from 'vue';\n\n import { SpacingDensities } from '../../../types/misc';\n import { MODULE_INJECTION } from '../Module/Module.keys';\n import Paginate from '../Paginate/Paginate.vue';\n import { DEFAULT_PAGE_SIZE } from './DataView.constants';\n import { DATA_VIEW_INJECTION } from './DataView.keys';\n import {\n DataViewVariants,\n GoNextPage,\n GoPrevPage,\n SetPage,\n SortId,\n SortOrder,\n SortValue,\n UpdateCurrentFilters,\n UpdateCurrentSearch,\n UpdateCurrentSort,\n UpdateEvent,\n } from './DataView.types';\n import { deserializeSortValue, getNextSort } from './DataView.utils';\n\n export interface DataViewProps {\n /**\n * Can be used to provide the initial page.\n * Also, it can be used to control the active page with `v-model:current-page=\"myPage\"`.\n */\n currentPage?: number;\n\n /**\n * Can be used to set the initial search term.\n * Also, it can be used to control the active search term with `v-model:current-search=\"mySearchTerm\"`.\n */\n currentSearch?: string;\n\n /**\n * Can be used to provide the initial sort order.\n * Also, it can be used to control the active sort order with `v-model:current-sort=\"mySortOrder\"`.\n */\n currentSort?: SortValue;\n\n /**\n * A list of records. If pagination is enabled, `data` must be only the current page of records.\n */\n data?: object[];\n\n /**\n * Controls the DataView's padding; the default value is \"comfortable\". On small screens, \"compact\" density is applied regardless of this prop's value.\n */\n density?: SpacingDensities;\n\n pageSize?: number;\n\n /**\n * Opt-out of displaying pagination. Hides the pagination buttons and page stats.\n */\n disablePagination?: boolean;\n\n /**\n * Hides the bottom pagination without disabling the pagination from the toolbar\n */\n hideBottomPagination?: boolean;\n\n /**\n * The total number of records available.\n * Used to auto-enable pagination when results exist.\n * Use `Infinity` for activating 'n of many' pagination\n * DataView does not paginate data for you; instead, `props.data` should always show\n * the current page of results.\n */\n totalDataCount?: number;\n\n /**\n * Whether there is a next page of data or not as informed by the server.\n * This only applies when`totalDataCount=\"Infinity\"` to determine if the \"Next\" pagination button should be disabled.\n */\n hasNextPage?: boolean;\n\n /**\n * DataView variant. The default value is `undefined`. Will default to `table` when used within\n * a `<Module variant=\"table\">`.\n */\n variant?: DataViewVariants;\n\n isLoading?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewProps>(), {\n currentPage: 1,\n currentSearch: undefined,\n currentSort: undefined,\n data: () => [],\n density: 'comfortable',\n pageSize: DEFAULT_PAGE_SIZE,\n disablePagination: false,\n totalDataCount: 0,\n hasNextPage: undefined,\n hideBottomPagination: false,\n variant: undefined,\n });\n\n const emit = defineEmits<{\n (e: 'update', state: UpdateEvent): void;\n (e: 'update:currentFilters', newFilters: object): void;\n (e: 'update:currentPage', page: number, pageSize: number): void;\n (e: 'update:currentSearch', searchTerm?: string): void;\n (e: 'update:currentSort', payload?: SortValue): void;\n }>();\n\n const classes = useCssModule();\n const rootRef = ref<HTMLElement | null>(null);\n const moduleInjection = inject(MODULE_INJECTION.key, MODULE_INJECTION.defaults);\n const computedVariant = computed<DataViewVariants | undefined>(() => {\n if (props.variant) {\n return props.variant;\n }\n\n if (moduleInjection.variant?.value === 'table') {\n return 'table';\n }\n\n return undefined;\n });\n const isWithinModule = computed(() => moduleInjection.variant !== undefined);\n\n // #region pagination\n const internalPage = ref(1);\n const isPaginationEnabled = computed(() => !props.disablePagination && props.totalDataCount > 0);\n const isPaginateNextDisabled = computed(() => props.totalDataCount === Infinity && !props.hasNextPage);\n const pageCount = computed(() => Math.ceil(props.totalDataCount / props.pageSize));\n\n const setPage: SetPage = function (page: number, { shouldEmit } = {}) {\n internalPage.value = page;\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentPage', page, props.pageSize);\n }\n\n if (Number(rootRef.value?.getBoundingClientRect().top) < 0) {\n rootRef.value?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n }\n };\n\n const goPrevPage: GoPrevPage = function ({ shouldEmit } = {}) {\n const page = Math.max(internalPage.value - 1, 1);\n\n setPage(page, { shouldEmit });\n };\n\n /** Updates the DataView internal state with the previous page */\n const goNextPage: GoNextPage = function ({ shouldEmit } = {}) {\n const page = Math.min(internalPage.value + 1, pageCount.value);\n\n setPage(page, { shouldEmit });\n };\n\n watch(\n () => props.currentPage,\n () => {\n setPage(props.currentPage);\n },\n { immediate: true },\n );\n // #endregion pagination\n\n // #region sorting\n const internalSort = ref<SortValue | undefined>(undefined);\n\n const internalSortId = computed<SortId | undefined>(() =>\n internalSort.value ? deserializeSortValue(internalSort.value).id : undefined,\n );\n const internalSortOrder = computed<SortOrder | undefined>(() =>\n internalSort.value ? deserializeSortValue(internalSort.value).order : undefined,\n );\n\n const updateCurrentSort: UpdateCurrentSort = function (sortId, { sortOrder, shouldEmit } = {}) {\n const { id: oldId, order: oldOrder } = deserializeSortValue(internalSort.value || '');\n const nextSort = getNextSort({ newId: sortId, newOrder: sortOrder, oldId, oldOrder });\n\n internalSort.value = nextSort;\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentSort', nextSort);\n }\n };\n\n watch(\n () => props.currentSort,\n () => {\n updateCurrentSort(props.currentSort);\n },\n { immediate: true },\n );\n // #endregion sorting\n\n // #region search\n const internalSearch = ref('');\n\n const hasToolbar = ref(false);\n const isSelectable = ref(false);\n\n const updateCurrentSearch: UpdateCurrentSearch = function (searchTerm, { shouldEmit } = {}) {\n internalSearch.value = searchTerm || '';\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentSearch', searchTerm);\n }\n };\n\n watch(\n () => props.currentSearch,\n () => {\n updateCurrentSearch(props.currentSearch);\n },\n { immediate: true },\n );\n // #endregion search\n\n // #region filters\n const internalFilters = ref<object>({});\n\n const updateCurrentFilters: UpdateCurrentFilters = function (newFilters: object, { shouldEmit } = {}) {\n internalFilters.value = newFilters;\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentFilters', newFilters);\n }\n };\n // #endregion filters\n\n function emitUpdate() {\n emit('update', {\n page: internalPage.value,\n pageSize: props.pageSize,\n ordering: internalSort.value,\n search: internalSearch.value,\n filters: cloneDeep(internalFilters.value),\n });\n }\n\n provide(\n DATA_VIEW_INJECTION.key,\n Object.freeze({\n // Pagination\n currentPage: computed(() => internalPage.value),\n isPaginationEnabled,\n isPaginateNextDisabled,\n pageCount,\n pageSize: computed(() => props.pageSize),\n totalDataCount: computed(() => props.totalDataCount),\n setPage,\n goPrevPage,\n goNextPage,\n\n // Sorting\n currentSortId: internalSortId,\n currentSortOrder: internalSortOrder,\n updateCurrentSort,\n\n // Search\n currentSearch: computed(() => internalSearch.value),\n updateCurrentSearch,\n\n // Miscellaneous\n density: computed(() => props.density),\n hasToolbar,\n isEmpty: computed(() => props.data.length === 0),\n isSelectable,\n isLoading: computed(() => props.isLoading),\n isWithinModule,\n variant: computedVariant,\n }),\n );\n\n defineExpose({\n page: computed(() => internalPage.value),\n pageSize: computed(() => props.pageSize),\n setPage,\n goPrevPage,\n goNextPage,\n ordering: computed(() => internalSort.value),\n updateCurrentSort,\n search: computed(() => internalSearch.value),\n updateCurrentSearch,\n filters: computed(() => internalFilters.value),\n updateCurrentFilters,\n });\n</script>\n\n<template>\n <div ref=\"rootRef\" class=\"stash-data-view tw-relative\" data-test=\"stash-data-view\">\n <!-- @slot default -->\n <slot\n :current-page=\"internalPage\"\n :current-sort-id=\"internalSortId\"\n :current-sort-order=\"internalSortOrder\"\n :data=\"data\"\n :go-prev-page=\"goPrevPage\"\n :go-next-page=\"goNextPage\"\n :page-count=\"pageCount\"\n :set-page=\"setPage\"\n :total-data-count=\"props.totalDataCount\"\n :update-current-sort=\"updateCurrentSort\"\n :update-current-search=\"updateCurrentSearch\"\n ></slot>\n\n <Paginate\n v-if=\"isPaginationEnabled && !isWithinModule && pageCount > 1 && !props.hideBottomPagination\"\n class=\"tw-mt-6\"\n :class=\"classes.paginate\"\n :current-page=\"internalPage\"\n :is-next-disabled=\"isLoading || isPaginateNextDisabled\"\n :list-length=\"props.totalDataCount\"\n :page-size=\"props.pageSize\"\n :variant=\"props.totalDataCount === Infinity ? 'stats' : 'standard'\"\n @set-page=\"(page: number) => setPage(page, { shouldEmit: true })\"\n />\n </div>\n</template>\n\n<style module>\n .paginate ul {\n margin: 0;\n }\n</style>\n"],"names":["deserializeSortValue","sort","order","serializeSortValue","id","getNextSort","newId","newOrder","oldId","oldOrder","DataViewVariant","props","__props","emit","__emit","classes","useCssModule","rootRef","ref","moduleInjection","inject","MODULE_INJECTION","computedVariant","computed","_a","isWithinModule","internalPage","isPaginationEnabled","isPaginateNextDisabled","pageCount","setPage","page","shouldEmit","emitUpdate","_b","goPrevPage","goNextPage","watch","internalSort","internalSortId","internalSortOrder","updateCurrentSort","sortId","sortOrder","nextSort","internalSearch","hasToolbar","isSelectable","updateCurrentSearch","searchTerm","internalFilters","updateCurrentFilters","newFilters","cloneDeep","provide","DATA_VIEW_INJECTION","__expose"],"mappings":";;;;;;AAKO,SAASA,EAAqBC,GAAwC;AAC3E,QAAMC,IAAQD,EAAK,CAAC,MAAM,MAAM,SAAS;AAGlC,SAAA,EAAE,IAFEC,MAAU,QAAQD,IAAOA,EAAK,MAAM,CAAC,GAEnC,OAAAC,EAAM;AACrB;AAKO,SAASC,GAAmB,EAAE,IAAAC,GAAI,OAAAF,KAA2C;AAClF,SAAO,GAAGA,MAAU,SAAS,MAAM,EAAE,GAAGE,CAAE;AAC5C;AAcO,SAASC,GAAY,EAAE,OAAAC,GAAO,UAAAC,GAAU,OAAAC,GAAO,UAAAC,KAAoD;AACxG,MAAKH,GAIL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AAahC,EAAS,MAAMG,EAAa,KAAK;AAAA,QAC9C,qBAAAC;AAAA,QACA,wBAAAC;AAAA,QACA,WAAAC;AAAA,QACA,UAAUN,EAAS,MAAMZ,EAAM,QAAQ;AAAA,QACvC,gBAAgBY,EAAS,MAAMZ,EAAM,cAAc;AAAA,QACnD,SAAAmB;AAAA,QACA,YAAAK;AAAA,QACA,YAAAC;AAAA;AAAA,QAGA,eAAeG;AAAA,QACf,kBAAkBC;AAAA,QAClB,mBAAAC;AAAA;AAAA,QAGA,eAAelB,EAAS,MAAMsB,EAAe,KAAK;AAAA,QAClD,qBAAAG;AAAA;AAAA,QAGA,SAASzB,EAAS,MAAMZ,EAAM,OAAO;AAAA,QACrC,YAAAmC;AAAA,QACA,SAASvB,EAAS,MAAMZ,EAAM,KAAK,WAAW,CAAC;AAAA,QAC/C,cAAAoC;AAAA,QACA,WAAWxB,EAAS,MAAMZ,EAAM,SAAS;AAAA,QACzC,gBAAAc;AAAA,QACA,SAASH;AAAA,MACV,CAAA;AAAA,IACH,GAEakC,EAAA;AAAA,MACX,MAAMjC,EAAS,MAAMG,EAAa,KAAK;AAAA,MACvC,UAAUH,EAAS,MAAMZ,EAAM,QAAQ;AAAA,MACvC,SAAAmB;AAAA,MACA,YAAAK;AAAA,MACA,YAAAC;AAAA,MACA,UAAUb,EAAS,MAAMe,EAAa,KAAK;AAAA,MAC3C,mBAAAG;AAAA,MACA,QAAQlB,EAAS,MAAMsB,EAAe,KAAK;AAAA,MAC3C,qBAAAG;AAAA,MACA,SAASzB,EAAS,MAAM2B,EAAgB,KAAK;AAAA,MAC7C,sBAAAC;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,6 +4,7 @@ const a = 12, o = Object.freeze({
4
4
  defaults: Object.freeze({
5
5
  // Pagination
6
6
  currentPage: e(() => 1),
7
+ isPaginateNextDisabled: e(() => !1),
7
8
  isPaginationEnabled: e(() => !1),
8
9
  pageCount: e(() => 1),
9
10
  pageSize: e(() => a),
@@ -40,4 +41,4 @@ export {
40
41
  o as D,
41
42
  a
42
43
  };
43
- //# sourceMappingURL=DataView.keys-C7eaZg2G.js.map
44
+ //# sourceMappingURL=DataView.keys-aSOnA4AD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataView.keys-aSOnA4AD.js","sources":["../src/components/DataView/DataView.constants.ts","../src/components/DataView/DataView.keys.ts"],"sourcesContent":["export const DEFAULT_PAGE_SIZE = 12;\n","import { computed, ref } from 'vue';\n\nimport { InjectionWithDefaults } from '../../../types/utils';\nimport { DEFAULT_PAGE_SIZE } from './DataView.constants';\nimport { DataViewInjection } from './DataView.types';\n\n// See: https://vuejs.org/guide/typescript/composition-api.html#typing-provide-inject\n\n/**\n * Miscellaneous data that is not related to pagination, sorting, or searching.\n * TODO: merge all DataView injections into one. https://leaflink.atlassian.net/browse/STASH-507\n */\nexport const DATA_VIEW_INJECTION: InjectionWithDefaults<DataViewInjection> = Object.freeze({\n key: Symbol('DATA_VIEW_INJECTION_KEY'),\n defaults: Object.freeze({\n // Pagination\n currentPage: computed(() => 1),\n isPaginateNextDisabled: computed(() => false),\n isPaginationEnabled: computed(() => false),\n pageCount: computed(() => 1),\n pageSize: computed(() => DEFAULT_PAGE_SIZE),\n totalDataCount: computed(() => 0),\n setPage() {},\n goPrevPage() {},\n goNextPage() {},\n\n // Sorting\n currentSortId: computed(() => undefined),\n currentSortOrder: computed(() => undefined),\n updateCurrentSort() {},\n\n // Search\n currentSearch: computed(() => ''),\n updateCurrentSearch() {},\n\n // Miscellanous\n density: computed(() => undefined),\n isEmpty: computed(() => false),\n isLoading: computed(() => false),\n isSelectable: ref(false),\n isWithinModule: computed(() => false),\n variant: computed(() => undefined),\n }),\n});\n"],"names":["DEFAULT_PAGE_SIZE","DATA_VIEW_INJECTION","computed","ref"],"mappings":";AAAO,MAAMA,IAAoB,ICYpBC,IAAgE,OAAO,OAAO;AAAA,EACzF,KAAK,OAAO,yBAAyB;AAAA,EACrC,UAAU,OAAO,OAAO;AAAA;AAAA,IAEtB,aAAaC,EAAS,MAAM,CAAC;AAAA,IAC7B,wBAAwBA,EAAS,MAAM,EAAK;AAAA,IAC5C,qBAAqBA,EAAS,MAAM,EAAK;AAAA,IACzC,WAAWA,EAAS,MAAM,CAAC;AAAA,IAC3B,UAAUA,EAAS,MAAMF,CAAiB;AAAA,IAC1C,gBAAgBE,EAAS,MAAM,CAAC;AAAA,IAChC,UAAU;AAAA,IAAC;AAAA,IACX,aAAa;AAAA,IAAC;AAAA,IACd,aAAa;AAAA,IAAC;AAAA;AAAA,IAGd,eAAeA,EAAS,MAAA;AAAA,KAAe;AAAA,IACvC,kBAAkBA,EAAS,MAAA;AAAA,KAAe;AAAA,IAC1C,oBAAoB;AAAA,IAAC;AAAA;AAAA,IAGrB,eAAeA,EAAS,MAAM,EAAE;AAAA,IAChC,sBAAsB;AAAA,IAAC;AAAA;AAAA,IAGvB,SAASA,EAAS,MAAA;AAAA,KAAe;AAAA,IACjC,SAASA,EAAS,MAAM,EAAK;AAAA,IAC7B,WAAWA,EAAS,MAAM,EAAK;AAAA,IAC/B,cAAcC,EAAI,EAAK;AAAA,IACvB,gBAAgBD,EAAS,MAAM,EAAK;AAAA,IACpC,SAASA,EAAS;KAAe;AAAA,EAClC,CAAA;AACH,CAAC;"}
@@ -43,6 +43,8 @@ export declare const DATA_VIEW_INJECTION: InjectionWithDefaults<DataViewInjectio
43
43
 
44
44
  export declare interface DataViewInjection {
45
45
  currentPage: ComputedRef<number>;
46
+ /** Optional override for the next button disabled state */
47
+ isPaginateNextDisabled: ComputedRef<boolean>;
46
48
  isPaginationEnabled: ComputedRef<boolean>;
47
49
  pageCount: ComputedRef<number>;
48
50
  pageSize: ComputedRef<number>;
@@ -130,10 +132,16 @@ export declare interface DataViewProps {
130
132
  /**
131
133
  * The total number of records available.
132
134
  * Used to auto-enable pagination when results exist.
135
+ * Use `Infinity` for activating 'n of many' pagination
133
136
  * DataView does not paginate data for you; instead, `props.data` should always show
134
137
  * the current page of results.
135
138
  */
136
139
  totalDataCount?: number;
140
+ /**
141
+ * Whether there is a next page of data or not as informed by the server.
142
+ * This only applies when`totalDataCount="Infinity"` to determine if the "Next" pagination button should be disabled.
143
+ */
144
+ hasNextPage?: boolean;
137
145
  /**
138
146
  * DataView variant. The default value is `undefined`. Will default to `table` when used within
139
147
  * a `<Module variant="table">`.
@@ -157,6 +165,7 @@ density: string;
157
165
  pageSize: number;
158
166
  disablePagination: boolean;
159
167
  totalDataCount: number;
168
+ hasNextPage: undefined;
160
169
  hideBottomPagination: boolean;
161
170
  variant: undefined;
162
171
  }>>, {
@@ -186,6 +195,7 @@ density: string;
186
195
  pageSize: number;
187
196
  disablePagination: boolean;
188
197
  totalDataCount: number;
198
+ hasNextPage: undefined;
189
199
  hideBottomPagination: boolean;
190
200
  variant: undefined;
191
201
  }>>> & Readonly<{
@@ -205,6 +215,7 @@ density: "compact" | "comfortable";
205
215
  currentSort: string;
206
216
  disablePagination: boolean;
207
217
  hideBottomPagination: boolean;
218
+ hasNextPage: boolean;
208
219
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>, {
209
220
  default?(_: {
210
221
  currentPage: number;
@@ -1,14 +1,14 @@
1
- import { ref as B, computed as C, defineComponent as j, useSlots as O, inject as z, provide as J, watch as Q, openBlock as f, createBlock as w, normalizeClass as U, unref as t, withCtx as u, mergeProps as $, createCommentVNode as p, createElementBlock as Z, createElementVNode as A, renderSlot as G, createVNode as I, createTextVNode as k, toDisplayString as m } from "vue";
1
+ import { ref as B, computed as C, defineComponent as j, useSlots as O, inject as z, provide as J, watch as Q, createBlock as w, openBlock as f, normalizeClass as U, unref as t, withCtx as u, createCommentVNode as p, createElementBlock as Z, mergeProps as $, createElementVNode as A, renderSlot as G, createVNode as I, createTextVNode as k, toDisplayString as m } from "vue";
2
2
  import q from "./useMediaQuery.js";
3
3
  import { SCREEN_SIZES as H } from "./constants.js";
4
4
  import { t as d } from "./locale.js";
5
- import { _ as K } from "./Box.vue_vue_type_script_setup_true_lang-DgJHq-09.js";
5
+ import { _ as K } from "./Box.vue_vue_type_script_setup_true_lang-rFnvwLVY.js";
6
6
  import _ from "./Button.js";
7
7
  import L from "lodash-es/cloneDeep";
8
8
  import P from "./Icon.js";
9
- import { D as R } from "./DataView.keys-C7eaZg2G.js";
9
+ import { D as R } from "./DataView.keys-aSOnA4AD.js";
10
10
  import X from "./FilterChip.js";
11
- import { _ as Y } from "./Label.vue_vue_type_script_setup_true_lang-C4JKdqvC.js";
11
+ import { _ as Y } from "./Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.js";
12
12
  import ee from "./Modal.js";
13
13
  import te from "./SearchBar.js";
14
14
  import { D as le } from "./DataViewFilters.keys-BLu07FiP.js";
@@ -1,9 +1,9 @@
1
- import { defineComponent as y, useCssModule as D, inject as S, openBlock as s, createBlock as n, withCtx as o, createVNode as d, createTextVNode as l, toDisplayString as c, unref as t, createElementVNode as i, createElementBlock as f, Fragment as k, renderList as V, normalizeClass as b, createCommentVNode as u } from "vue";
1
+ import { defineComponent as y, useCssModule as D, inject as S, createBlock as n, createCommentVNode as l, openBlock as s, withCtx as o, createElementVNode as c, createElementBlock as f, Fragment as k, renderList as V, unref as t, normalizeClass as b, createVNode as d, createTextVNode as i, toDisplayString as u } from "vue";
2
2
  import { t as B } from "./locale.js";
3
3
  import _ from "./Button.js";
4
4
  import "lodash-es/cloneDeep";
5
5
  import h from "./Icon.js";
6
- import { D as C } from "./DataView.keys-C7eaZg2G.js";
6
+ import { D as C } from "./DataView.keys-aSOnA4AD.js";
7
7
  import E from "./Dropdown.js";
8
8
  import I from "./IconLabel.js";
9
9
  import { _ as N } from "./_plugin-vue_export-helper-CHgC5LLL.js";
@@ -40,7 +40,7 @@ const v = {
40
40
  stacked: ""
41
41
  }, {
42
42
  default: o(() => [
43
- l(c(t(B)("ll.sort")), 1)
43
+ i(u(t(B)("ll.sort")), 1)
44
44
  ]),
45
45
  _: 1
46
46
  })
@@ -49,11 +49,11 @@ const v = {
49
49
  }, 1032, ["aria-expanded", "onClick"])
50
50
  ]),
51
51
  default: o(() => [
52
- i("ul", v, [
52
+ c("ul", v, [
53
53
  (s(!0), f(k, null, V(m.sortOptions, (e) => (s(), f(k, {
54
54
  key: e.id
55
55
  }, [
56
- i("li", {
56
+ c("li", {
57
57
  class: b(["dropdown__item tw-rounded", [
58
58
  t(w).dropdown__item,
59
59
  { "tw-bg-blue-100 tw-text-ice-700": e.id === t(r) && t(a) === "asc" }
@@ -65,17 +65,17 @@ const v = {
65
65
  class: "tw-h-9"
66
66
  }, {
67
67
  default: o(() => [
68
- l(c(e.labelAsc) + " ", 1),
68
+ i(u(e.labelAsc) + " ", 1),
69
69
  e.id === t(r) && t(a) === "asc" ? (s(), n(h, {
70
70
  key: 0,
71
71
  name: "check",
72
72
  class: "tw-ml-auto tw-text-blue-500"
73
- })) : u("", !0)
73
+ })) : l("", !0)
74
74
  ]),
75
75
  _: 2
76
76
  }, 1024)
77
77
  ], 10, A),
78
- i("li", {
78
+ c("li", {
79
79
  class: b(["dropdown__item tw-rounded", [
80
80
  t(w).dropdown__item,
81
81
  { "tw-bg-blue-100 tw-text-ice-700": e.id === t(r) && t(a) === "desc" }
@@ -87,12 +87,12 @@ const v = {
87
87
  class: "tw-h-9"
88
88
  }, {
89
89
  default: o(() => [
90
- l(c(e.labelDesc) + " ", 1),
90
+ i(u(e.labelDesc) + " ", 1),
91
91
  e.id === t(r) && t(a) === "desc" ? (s(), n(h, {
92
92
  key: 0,
93
93
  name: "check",
94
94
  class: "tw-ml-auto tw-text-blue-500"
95
- })) : u("", !0)
95
+ })) : l("", !0)
96
96
  ]),
97
97
  _: 2
98
98
  }, 1024)
@@ -101,7 +101,7 @@ const v = {
101
101
  ])
102
102
  ]),
103
103
  _: 1
104
- })) : u("", !0);
104
+ })) : l("", !0);
105
105
  }
106
106
  }), z = "_dropdown__item_ozq17_2", L = {
107
107
  dropdown__item: z
@@ -1,17 +1,18 @@
1
- import { defineComponent as M, inject as $, ref as j, computed as k, onBeforeMount as U, openBlock as o, createElementBlock as s, normalizeClass as W, unref as e, createElementVNode as y, createBlock as F, createCommentVNode as n, renderSlot as J, toDisplayString as K, Fragment as L, createVNode as r, withCtx as x } from "vue";
2
- import { t as S } from "./locale.js";
3
- import _ from "./Button.js";
4
- import O from "./Checkbox.js";
1
+ import { defineComponent as $, inject as j, ref as M, computed as U, onBeforeMount as W, createElementBlock as l, openBlock as a, normalizeClass as F, unref as e, createElementVNode as h, createCommentVNode as s, createBlock as J, renderSlot as K, toDisplayString as L, Fragment as O, createVNode as i, withCtx as v } from "vue";
2
+ import { u as q } from "./usePaginationStats-d_q39naC.js";
3
+ import { t as n } from "./locale.js";
4
+ import x from "./Button.js";
5
+ import G from "./Checkbox.js";
5
6
  import "lodash-es/cloneDeep";
6
- import C from "./Icon.js";
7
- import { D as B } from "./DataView.keys-C7eaZg2G.js";
8
- const q = { class: "tw-flex tw-place-items-center" }, G = { class: "tw-flex tw-items-center tw-gap-x-2 lg:tw-gap-x-6" }, H = {
7
+ import k from "./Icon.js";
8
+ import { D as y } from "./DataView.keys-aSOnA4AD.js";
9
+ const H = { class: "tw-flex tw-place-items-center" }, Q = { class: "tw-flex tw-items-center tw-gap-x-2 lg:tw-gap-x-6" }, X = {
9
10
  key: 0,
10
11
  class: "tw-flex tw-items-center"
11
- }, Q = {
12
+ }, Y = {
12
13
  key: 0,
13
14
  class: "tw-mr-1.5"
14
- }, le = /* @__PURE__ */ M({
15
+ }, ne = /* @__PURE__ */ $({
15
16
  __name: "DataViewToolbar",
16
17
  props: {
17
18
  allRowsSelected: { type: Boolean, default: !1 },
@@ -21,96 +22,96 @@ const q = { class: "tw-flex tw-place-items-center" }, G = { class: "tw-flex tw-i
21
22
  hasTabsAbove: { type: Boolean, default: !1 }
22
23
  },
23
24
  emits: ["select"],
24
- setup(E, { emit: P }) {
25
- const t = E, V = P, {
26
- isWithinModule: d,
25
+ setup(S, { emit: _ }) {
26
+ const t = S, C = _, {
27
+ isWithinModule: r,
27
28
  variant: m,
28
29
  density: p,
29
- currentPage: l,
30
+ currentPage: d,
30
31
  hasToolbar: w,
31
- isPaginationEnabled: N,
32
- isSelectable: R,
32
+ isPaginateNextDisabled: B,
33
+ isPaginationEnabled: P,
34
+ isSelectable: E,
33
35
  pageCount: f,
34
- pageSize: v,
35
- totalDataCount: b,
36
- goPrevPage: T,
37
- goNextPage: z,
38
- isEmpty: A,
39
- isLoading: D
40
- } = $(B.key, B.defaults), h = j(0), i = k(() => t.radius ? t.radius : d.value ? "none" : m.value === "table" ? t.hasTabsAbove ? "rounded-top-right" : "rounded-top" : "rounded"), I = k(() => {
41
- const u = v.value * (l.value - 1) + 1, a = Math.min(v.value * l.value, b.value), c = b.value;
42
- return S("ll.pageStats", { from: u, to: a, total: c });
43
- });
36
+ pageSize: N,
37
+ totalDataCount: V,
38
+ goPrevPage: D,
39
+ goNextPage: R,
40
+ isEmpty: T,
41
+ isLoading: u
42
+ } = j(y.key, y.defaults), b = M(0), c = U(() => t.radius ? t.radius : r.value ? "none" : m.value === "table" ? t.hasTabsAbove ? "rounded-top-right" : "rounded-top" : "rounded"), z = q({ currentPage: d, pageSize: N, totalItems: V });
44
43
  function g() {
45
- V("select"), h.value++;
44
+ C("select"), b.value++;
46
45
  }
47
- return U(() => {
46
+ return W(() => {
48
47
  w && (w.value = !0);
49
- }), (u, a) => (o(), s("div", {
50
- class: W(["stash-data-view-toolbar tw-flex tw-min-h-15 tw-items-center tw-justify-between tw-bg-white tw-py-1.5 tw-shadow", {
51
- "tw-border-t tw-border-ice-200": e(d),
52
- "tw-rounded-tr": i.value === "rounded-top-right",
53
- "tw-rounded": i.value === "rounded",
54
- "tw-rounded-t": i.value === "rounded-top",
55
- "tw-mb-3": e(m) !== "table" && !e(d),
48
+ }), (A, o) => (a(), l("div", {
49
+ class: F(["stash-data-view-toolbar tw-flex tw-min-h-15 tw-items-center tw-justify-between tw-bg-white tw-py-1.5 tw-shadow", {
50
+ "tw-border-t tw-border-ice-200": e(r),
51
+ "tw-rounded-tr": c.value === "rounded-top-right",
52
+ "tw-rounded": c.value === "rounded",
53
+ "tw-rounded-t": c.value === "rounded-top",
54
+ "tw-mb-3": e(m) !== "table" && !e(r),
56
55
  "tw-px-0": e(p) === "compact",
57
56
  "lg:tw-px-3": e(p) === "comfortable"
58
57
  }]),
59
58
  "data-test": "stash-data-view-toolbar"
60
59
  }, [
61
- y("div", q, [
62
- e(R) && !e(A) ? (o(), F(O, {
63
- key: h.value,
60
+ h("div", H, [
61
+ e(E) && !e(T) ? (a(), J(G, {
62
+ key: b.value,
64
63
  checked: t.allRowsSelected,
65
64
  indeterminate: t.someRowsSelected && !t.allRowsSelected,
66
- title: e(S)("ll.selectAll"),
67
- disabled: e(D),
65
+ title: e(n)("ll.selectAll"),
66
+ disabled: e(u),
68
67
  "onUpdate:indeterminate": g,
69
68
  "onUpdate:checked": g
70
- }, null, 8, ["checked", "indeterminate", "title", "disabled"])) : n("", !0),
71
- y("div", G, [
72
- J(u.$slots, "default")
69
+ }, null, 8, ["checked", "indeterminate", "title", "disabled"])) : s("", !0),
70
+ h("div", Q, [
71
+ K(A.$slots, "default")
73
72
  ])
74
73
  ]),
75
- e(N) ? (o(), s("div", H, [
76
- t.hidePageStats ? n("", !0) : (o(), s("span", Q, K(I.value), 1)),
77
- e(f) > 1 ? (o(), s(L, { key: 1 }, [
78
- r(_, {
74
+ e(P) ? (a(), l("div", X, [
75
+ t.hidePageStats ? s("", !0) : (a(), l("span", Y, L(e(n)("ll.pageStats", e(z))), 1)),
76
+ e(f) > 1 ? (a(), l(O, { key: 1 }, [
77
+ i(x, {
79
78
  icon: "",
79
+ "aria-label": e(n)("ll.previous"),
80
80
  class: "tw-size-9 tw-p-1.5",
81
81
  "data-test": "button|prev-page",
82
- disabled: e(l) === 1,
83
- onClick: a[0] || (a[0] = (c) => e(T)({ shouldEmit: !0 }))
82
+ disabled: e(u) || e(d) === 1,
83
+ onClick: o[0] || (o[0] = (I) => e(D)({ shouldEmit: !0 }))
84
84
  }, {
85
- default: x(() => [
86
- r(C, {
85
+ default: v(() => [
86
+ i(k, {
87
87
  name: "chevron-left",
88
88
  size: "dense"
89
89
  })
90
90
  ]),
91
91
  _: 1
92
- }, 8, ["disabled"]),
93
- r(_, {
92
+ }, 8, ["aria-label", "disabled"]),
93
+ i(x, {
94
94
  icon: "",
95
+ "aria-label": e(n)("ll.next"),
95
96
  class: "tw-h-9 tw-w-9 tw-p-1.5",
96
97
  "data-test": "button|next-page",
97
- disabled: e(l) === e(f),
98
- onClick: a[1] || (a[1] = (c) => e(z)({ shouldEmit: !0 }))
98
+ disabled: e(u) || e(B) || e(d) === e(f),
99
+ onClick: o[1] || (o[1] = (I) => e(R)({ shouldEmit: !0 }))
99
100
  }, {
100
- default: x(() => [
101
- r(C, {
101
+ default: v(() => [
102
+ i(k, {
102
103
  name: "chevron-right",
103
104
  size: "dense"
104
105
  })
105
106
  ]),
106
107
  _: 1
107
- }, 8, ["disabled"])
108
- ], 64)) : n("", !0)
109
- ])) : n("", !0)
108
+ }, 8, ["aria-label", "disabled"])
109
+ ], 64)) : s("", !0)
110
+ ])) : s("", !0)
110
111
  ], 2));
111
112
  }
112
113
  });
113
114
  export {
114
- le as default
115
+ ne as default
115
116
  };
116
117
  //# sourceMappingURL=DataViewToolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataViewToolbar.js","sources":["../src/components/DataViewToolbar/DataViewToolbar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, inject, onBeforeMount, ref } from 'vue';\n\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import Icon from '../Icon/Icon.vue';\n import { ToolbarRadiuses } from './DataViewToolbar.types';\n\n export interface DataViewToolbarProps {\n /**\n * When DataView has `variant=\"table\"` and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever all rows are selected, just like the standalone version on TableHeaderRow.\n */\n allRowsSelected?: boolean;\n\n /**\n * Hides the page statistics (ex: \"1 - 12 of 20\") in the toolbar\n */\n hidePageStats?: boolean;\n\n /**\n * Controls the corners of DataViewToolbar with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: ToolbarRadiuses;\n\n /**\n * When DataView has variant=\"table\" and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever one or more, but not all rows are selected, just like the standalone\n * version on TableHeaderRow.\n */\n someRowsSelected?: boolean;\n\n /**\n * When DataView has tabs above it, we need to remove the top left rounded corner\n */\n hasTabsAbove?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewToolbarProps>(), {\n allRowsSelected: false,\n hidePageStats: false,\n radius: undefined,\n someRowsSelected: false,\n hasTabsAbove: false,\n });\n\n const emit = defineEmits<{\n (e: 'select'): void;\n }>();\n\n const {\n isWithinModule,\n variant: dataViewVariant,\n density,\n currentPage,\n hasToolbar,\n isPaginationEnabled,\n isSelectable,\n pageCount,\n pageSize,\n totalDataCount,\n goPrevPage,\n goNextPage,\n isEmpty,\n isLoading,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const checkboxKey = ref(0);\n\n const computedRadius = computed<ToolbarRadiuses>(() => {\n if (props.radius) {\n return props.radius;\n }\n\n if (isWithinModule.value) {\n return 'none';\n }\n\n if (dataViewVariant.value === 'table') {\n if (props.hasTabsAbove) {\n return 'rounded-top-right';\n }\n\n return 'rounded-top';\n }\n\n return 'rounded';\n });\n\n // #region pagination\n const pageStats = computed(() => {\n const from = pageSize.value * (currentPage.value - 1) + 1;\n const to = Math.min(pageSize.value * currentPage.value, totalDataCount.value);\n const total = totalDataCount.value;\n\n return t('ll.pageStats', { from, to, total });\n });\n // #endregion pagination\n\n function onSelect() {\n emit('select');\n\n /**\n * In Vue (as of this writing), if a user checks a native checkbox but the v-model is `false` and does not change from `false`, then the checkbox will display as checked even though the v-model is still `false`.\n * Forcing a re-render with a `key` change allows the checkbox to stay unchecked if its v-model is still `false` and its v-model not been changed.\n * To verify that this is necessary, test the \"select all\" checkbox in the SelectionWithSomeDisabled story in Table.story.ts with and without the `key` attribute.\n */\n checkboxKey.value++;\n }\n\n onBeforeMount(() => {\n if (hasToolbar) {\n hasToolbar.value = true;\n }\n });\n</script>\n\n<template>\n <div\n class=\"stash-data-view-toolbar tw-flex tw-min-h-15 tw-items-center tw-justify-between tw-bg-white tw-py-1.5 tw-shadow\"\n :class=\"{\n 'tw-border-t tw-border-ice-200': isWithinModule,\n 'tw-rounded-tr': computedRadius === 'rounded-top-right',\n 'tw-rounded': computedRadius === 'rounded',\n 'tw-rounded-t': computedRadius === 'rounded-top',\n 'tw-mb-3': dataViewVariant !== 'table' && !isWithinModule,\n 'tw-px-0': density === 'compact',\n 'lg:tw-px-3': density === 'comfortable',\n }\"\n data-test=\"stash-data-view-toolbar\"\n >\n <div class=\"tw-flex tw-place-items-center\">\n <Checkbox\n v-if=\"isSelectable && !isEmpty\"\n :key=\"checkboxKey\"\n :checked=\"props.allRowsSelected\"\n :indeterminate=\"props.someRowsSelected && !props.allRowsSelected\"\n :title=\"t('ll.selectAll')\"\n :disabled=\"isLoading\"\n @update:indeterminate=\"onSelect\"\n @update:checked=\"onSelect\"\n />\n <div class=\"tw-flex tw-items-center tw-gap-x-2 lg:tw-gap-x-6\">\n <!-- @slot default -->\n <slot></slot>\n </div>\n </div>\n\n <!-- Pagination -->\n <div v-if=\"isPaginationEnabled\" class=\"tw-flex tw-items-center\">\n <span v-if=\"!props.hidePageStats\" class=\"tw-mr-1.5\">\n {{ pageStats }}\n </span>\n <template v-if=\"pageCount > 1\">\n <Button\n icon\n class=\"tw-size-9 tw-p-1.5\"\n data-test=\"button|prev-page\"\n :disabled=\"currentPage === 1\"\n @click=\"goPrevPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-left\" size=\"dense\" />\n </Button>\n <Button\n icon\n class=\"tw-h-9 tw-w-9 tw-p-1.5\"\n data-test=\"button|next-page\"\n :disabled=\"currentPage === pageCount\"\n @click=\"goNextPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-right\" size=\"dense\" />\n </Button>\n </template>\n </div>\n </div>\n</template>\n"],"names":["props","__props","emit","__emit","isWithinModule","dataViewVariant","density","currentPage","hasToolbar","isPaginationEnabled","isSelectable","pageCount","pageSize","totalDataCount","goPrevPage","goNextPage","isEmpty","isLoading","inject","DATA_VIEW_INJECTION","checkboxKey","ref","computedRadius","computed","pageStats","from","to","total","t","onSelect","onBeforeMount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwCE,UAAMA,IAAQC,GAQRC,IAAOC,GAIP;AAAA,MACJ,gBAAAC;AAAA,MACA,SAASC;AAAA,MACT,SAAAC;AAAA,MACA,aAAAC;AAAA,MACA,YAAAC;AAAA,MACA,qBAAAC;AAAA,MACA,cAAAC;AAAA,MACA,WAAAC;AAAA,MACA,UAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,MACA,SAAAC;AAAA,MACA,WAAAC;AAAA,IACE,IAAAC,EAAOC,EAAoB,KAAKA,EAAoB,QAAQ,GAE1DC,IAAcC,EAAI,CAAC,GAEnBC,IAAiBC,EAA0B,MAC3CvB,EAAM,SACDA,EAAM,SAGXI,EAAe,QACV,SAGLC,EAAgB,UAAU,UACxBL,EAAM,eACD,sBAGF,gBAGF,SACR,GAGKwB,IAAYD,EAAS,MAAM;AAC/B,YAAME,IAAOb,EAAS,SAASL,EAAY,QAAQ,KAAK,GAClDmB,IAAK,KAAK,IAAId,EAAS,QAAQL,EAAY,OAAOM,EAAe,KAAK,GACtEc,IAAQd,EAAe;AAE7B,aAAOe,EAAE,gBAAgB,EAAE,MAAAH,GAAM,IAAAC,GAAI,OAAAC,GAAO;AAAA,IAAA,CAC7C;AAGD,aAASE,IAAW;AAClB,MAAA3B,EAAK,QAAQ,GAODkB,EAAA;AAAA,IAAA;AAGd,WAAAU,EAAc,MAAM;AAClB,MAAItB,MACFA,EAAW,QAAQ;AAAA,IACrB,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"DataViewToolbar.js","sources":["../src/components/DataViewToolbar/DataViewToolbar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, inject, onBeforeMount, ref } from 'vue';\n\n import usePaginationStats from '../../composables/usePaginationStats/usePaginationStats';\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import Icon from '../Icon/Icon.vue';\n import { ToolbarRadiuses } from './DataViewToolbar.types';\n\n export interface DataViewToolbarProps {\n /**\n * When DataView has `variant=\"table\"` and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever all rows are selected, just like the standalone version on TableHeaderRow.\n */\n allRowsSelected?: boolean;\n\n /**\n * Hides the page statistics (ex: \"1 - 12 of 20\") in the toolbar\n */\n hidePageStats?: boolean;\n\n /**\n * Controls the corners of DataViewToolbar with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: ToolbarRadiuses;\n\n /**\n * When DataView has variant=\"table\" and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever one or more, but not all rows are selected, just like the standalone\n * version on TableHeaderRow.\n */\n someRowsSelected?: boolean;\n\n /**\n * When DataView has tabs above it, we need to remove the top left rounded corner\n */\n hasTabsAbove?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewToolbarProps>(), {\n allRowsSelected: false,\n hidePageStats: false,\n radius: undefined,\n someRowsSelected: false,\n hasTabsAbove: false,\n });\n\n const emit = defineEmits<{\n (e: 'select'): void;\n }>();\n\n const {\n isWithinModule,\n variant: dataViewVariant,\n density,\n currentPage,\n hasToolbar,\n isPaginateNextDisabled,\n isPaginationEnabled,\n isSelectable,\n pageCount,\n pageSize,\n totalDataCount,\n goPrevPage,\n goNextPage,\n isEmpty,\n isLoading,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const checkboxKey = ref(0);\n\n const computedRadius = computed<ToolbarRadiuses>(() => {\n if (props.radius) {\n return props.radius;\n }\n\n if (isWithinModule.value) {\n return 'none';\n }\n\n if (dataViewVariant.value === 'table') {\n if (props.hasTabsAbove) {\n return 'rounded-top-right';\n }\n\n return 'rounded-top';\n }\n\n return 'rounded';\n });\n\n const pageStats = usePaginationStats({ currentPage, pageSize, totalItems: totalDataCount });\n\n function onSelect() {\n emit('select');\n\n /**\n * In Vue (as of this writing), if a user checks a native checkbox but the v-model is `false` and does not change from `false`, then the checkbox will display as checked even though the v-model is still `false`.\n * Forcing a re-render with a `key` change allows the checkbox to stay unchecked if its v-model is still `false` and its v-model not been changed.\n * To verify that this is necessary, test the \"select all\" checkbox in the SelectionWithSomeDisabled story in Table.story.ts with and without the `key` attribute.\n */\n checkboxKey.value++;\n }\n\n onBeforeMount(() => {\n if (hasToolbar) {\n hasToolbar.value = true;\n }\n });\n</script>\n\n<template>\n <div\n class=\"stash-data-view-toolbar tw-flex tw-min-h-15 tw-items-center tw-justify-between tw-bg-white tw-py-1.5 tw-shadow\"\n :class=\"{\n 'tw-border-t tw-border-ice-200': isWithinModule,\n 'tw-rounded-tr': computedRadius === 'rounded-top-right',\n 'tw-rounded': computedRadius === 'rounded',\n 'tw-rounded-t': computedRadius === 'rounded-top',\n 'tw-mb-3': dataViewVariant !== 'table' && !isWithinModule,\n 'tw-px-0': density === 'compact',\n 'lg:tw-px-3': density === 'comfortable',\n }\"\n data-test=\"stash-data-view-toolbar\"\n >\n <div class=\"tw-flex tw-place-items-center\">\n <Checkbox\n v-if=\"isSelectable && !isEmpty\"\n :key=\"checkboxKey\"\n :checked=\"props.allRowsSelected\"\n :indeterminate=\"props.someRowsSelected && !props.allRowsSelected\"\n :title=\"t('ll.selectAll')\"\n :disabled=\"isLoading\"\n @update:indeterminate=\"onSelect\"\n @update:checked=\"onSelect\"\n />\n <div class=\"tw-flex tw-items-center tw-gap-x-2 lg:tw-gap-x-6\">\n <!-- @slot default -->\n <slot></slot>\n </div>\n </div>\n\n <!-- Pagination -->\n <div v-if=\"isPaginationEnabled\" class=\"tw-flex tw-items-center\">\n <span v-if=\"!props.hidePageStats\" class=\"tw-mr-1.5\">\n {{ t('ll.pageStats', pageStats) }}\n </span>\n <template v-if=\"pageCount > 1\">\n <Button\n icon\n :aria-label=\"t('ll.previous')\"\n class=\"tw-size-9 tw-p-1.5\"\n data-test=\"button|prev-page\"\n :disabled=\"isLoading || currentPage === 1\"\n @click=\"goPrevPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-left\" size=\"dense\" />\n </Button>\n <Button\n icon\n :aria-label=\"t('ll.next')\"\n class=\"tw-h-9 tw-w-9 tw-p-1.5\"\n data-test=\"button|next-page\"\n :disabled=\"isLoading || isPaginateNextDisabled || currentPage === pageCount\"\n @click=\"goNextPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-right\" size=\"dense\" />\n </Button>\n </template>\n </div>\n </div>\n</template>\n"],"names":["props","__props","emit","__emit","isWithinModule","dataViewVariant","density","currentPage","hasToolbar","isPaginateNextDisabled","isPaginationEnabled","isSelectable","pageCount","pageSize","totalDataCount","goPrevPage","goNextPage","isEmpty","isLoading","inject","DATA_VIEW_INJECTION","checkboxKey","ref","computedRadius","computed","pageStats","usePaginationStats","onSelect","onBeforeMount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyCE,UAAMA,IAAQC,GAQRC,IAAOC,GAIP;AAAA,MACJ,gBAAAC;AAAA,MACA,SAASC;AAAA,MACT,SAAAC;AAAA,MACA,aAAAC;AAAA,MACA,YAAAC;AAAA,MACA,wBAAAC;AAAA,MACA,qBAAAC;AAAA,MACA,cAAAC;AAAA,MACA,WAAAC;AAAA,MACA,UAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,MACA,SAAAC;AAAA,MACA,WAAAC;AAAA,IACE,IAAAC,EAAOC,EAAoB,KAAKA,EAAoB,QAAQ,GAE1DC,IAAcC,EAAI,CAAC,GAEnBC,IAAiBC,EAA0B,MAC3CxB,EAAM,SACDA,EAAM,SAGXI,EAAe,QACV,SAGLC,EAAgB,UAAU,UACxBL,EAAM,eACD,sBAGF,gBAGF,SACR,GAEKyB,IAAYC,EAAmB,EAAE,aAAAnB,GAAa,UAAAM,GAAU,YAAYC,GAAgB;AAE1F,aAASa,IAAW;AAClB,MAAAzB,EAAK,QAAQ,GAODmB,EAAA;AAAA,IAAA;AAGd,WAAAO,EAAc,MAAM;AAClB,MAAIpB,MACFA,EAAW,QAAQ;AAAA,IACrB,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}