@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.
- package/dist/Accordion.js +30 -31
- package/dist/Accordion.js.map +1 -1
- package/dist/Accordion.vue.d.ts +6 -1
- package/dist/ActionsDropdown.js +2 -2
- package/dist/AddressSelect.js +2 -2
- package/dist/Alert.js +6 -6
- package/dist/AppNavigationItem.js +8 -8
- package/dist/AppNavigationItem.vue.d.ts +5 -0
- package/dist/AppSidebar.js +9 -9
- package/dist/AppSidebar.js.map +1 -1
- package/dist/AppTopbar.js +3 -3
- package/dist/Avatar.js +3 -3
- package/dist/Backdrop.js +2 -2
- package/dist/Badge.js +2 -2
- package/dist/Box.js +1 -1
- 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
- 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
- package/dist/Button.js +3 -3
- package/dist/ButtonGroup.js +4 -4
- package/dist/Card.js +7 -7
- package/dist/CardContent.js +2 -2
- package/dist/CardFooter.js +2 -2
- package/dist/CardHeader.js +4 -4
- package/dist/CardMedia.js +6 -6
- package/dist/Carousel.js +33 -33
- package/dist/Carousel.js.map +1 -1
- package/dist/Checkbox.js +7 -7
- package/dist/ChevronToggle.js +1 -1
- 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
- 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
- package/dist/Chip.js +7 -7
- package/dist/ConfirmationCodeInput.js +6 -6
- package/dist/ContextSwitcher.js +1 -1
- package/dist/Copy.js +1 -1
- package/dist/CurrencyInput.js +115 -111
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/DataView.js +102 -98
- package/dist/DataView.js.map +1 -1
- package/dist/{DataView.keys-C7eaZg2G.js → DataView.keys-aSOnA4AD.js} +2 -1
- package/dist/DataView.keys-aSOnA4AD.js.map +1 -0
- package/dist/DataView.vue.d.ts +11 -0
- package/dist/DataViewFilters.js +4 -4
- package/dist/DataViewSortButton.js +11 -11
- package/dist/DataViewToolbar.js +61 -60
- package/dist/DataViewToolbar.js.map +1 -1
- package/dist/DatePicker.js +1080 -1037
- package/dist/DatePicker.js.map +1 -1
- package/dist/DescriptionList.js +2 -2
- package/dist/DescriptionListDetail.js +2 -2
- package/dist/DescriptionListGroup.js +2 -2
- package/dist/DescriptionListTerm.js +3 -3
- package/dist/Dialog.js +1 -1
- package/dist/Divider.js +2 -2
- package/dist/Dropdown.js +19 -19
- package/dist/Dropdown.js.map +1 -1
- package/dist/EmptyState.js +2 -2
- package/dist/Expand.js +1 -1
- package/dist/{Expand.vue_vue_type_script_setup_true_lang-D0fSAtHr.js → Expand.vue_vue_type_script_setup_true_lang-CiONJfAp.js} +5 -5
- 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
- package/dist/Field.js +1 -1
- package/dist/{Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js → Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js} +6 -6
- package/dist/Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js.map +1 -0
- package/dist/FileUpload.js +7 -7
- package/dist/FilterChip.js +1 -1
- package/dist/FilterDrawerItem.js +9 -9
- package/dist/FilterDropdown.js +2 -2
- package/dist/FilterSelect.js +4 -4
- package/dist/Filters.js +18 -18
- package/dist/Filters.js.map +1 -1
- package/dist/HttpError.js +9 -9
- package/dist/Icon.js +2 -2
- package/dist/Icon.js.map +1 -1
- package/dist/Icon.vue.d.ts +5 -0
- package/dist/IconLabel.js +2 -2
- package/dist/IconLabel.vue.d.ts +5 -0
- package/dist/Illustration.js +2 -2
- package/dist/{Illustration.vue_vue_type_script_setup_true_lang-CYddAFtS.js → Illustration.vue_vue_type_script_setup_true_lang-BBqgoJO8.js} +3 -3
- 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
- package/dist/Image.js +2 -2
- package/dist/{Image.vue_vue_type_script_setup_true_lang-YUNunj71.js → Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js} +3 -3
- 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
- package/dist/InlineEdit.js +5 -5
- package/dist/InlineEdit.js.map +1 -1
- package/dist/Input.js +2 -2
- package/dist/InputOptions.js +2 -2
- package/dist/InputOptions.js.map +1 -1
- package/dist/IntegrationIcon.js +2 -2
- package/dist/Label.js +1 -1
- package/dist/{Label.vue_vue_type_script_setup_true_lang-C4JKdqvC.js → Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.js} +3 -3
- 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
- package/dist/LicenseChip.js +2 -2
- package/dist/ListItem.js +1 -1
- package/dist/ListItemCell.js +2 -2
- package/dist/ListView.js +11 -11
- package/dist/ListView.js.map +1 -1
- package/dist/ListView.vue.d.ts +38 -13
- package/dist/Loading.js +2 -2
- package/dist/Logo.js +1 -1
- package/dist/{Logo.vue_vue_type_script_setup_true_lang-BfUU9J9O.js → Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js} +4 -4
- 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
- package/dist/Menu.js +2 -2
- package/dist/MenuItem.js +2 -2
- package/dist/Metric.js +5 -5
- package/dist/Modal.js +20 -20
- package/dist/Modals.js +12 -12
- package/dist/Modals.js.map +1 -1
- package/dist/Module.js +3 -3
- package/dist/ModuleContent.js +3 -3
- package/dist/ModuleFooter.js +2 -2
- package/dist/ModuleHeader.js +2 -2
- package/dist/ModuleHeader.js.map +1 -1
- package/dist/ObfuscateText.js +7 -7
- package/dist/PageContent.js +3 -3
- package/dist/PageHeader.js +6 -6
- package/dist/PageNavigation.js +1 -1
- package/dist/Paginate.js +73 -55
- package/dist/Paginate.js.map +1 -1
- package/dist/Paginate.vue.d.ts +12 -1
- package/dist/PlaidLink.js +2 -2
- package/dist/QuickAction.js +2 -2
- package/dist/QuickAction.vue.d.ts +5 -0
- package/dist/Radio.js +2 -2
- package/dist/RadioGroup.js +2 -2
- package/dist/RadioNew.js +1 -1
- package/dist/RangeInput.js +2 -2
- package/dist/SearchBar.js +4 -4
- package/dist/SearchBar.js.map +1 -1
- package/dist/Select.js +7 -7
- package/dist/Select.js.map +1 -1
- package/dist/SelectStatus.js +19 -19
- package/dist/SelectStatus.js.map +1 -1
- package/dist/SelectStatus.vue.d.ts +5 -0
- package/dist/Skeleton.js +4 -4
- package/dist/Step.js +19 -19
- package/dist/Step.js.map +1 -1
- package/dist/Stepper.js +9 -9
- package/dist/Switch.js +7 -7
- package/dist/Tab.js +4 -4
- package/dist/TabPanel.js +2 -2
- package/dist/Table.js +6 -6
- package/dist/Table.js.map +1 -1
- package/dist/TableCell.js +7 -7
- package/dist/TableHeaderCell.js +4 -4
- package/dist/TableHeaderRow.js +5 -5
- package/dist/TableRow.js +5 -5
- package/dist/TableRow.js.map +1 -1
- package/dist/TableRow.vue.d.ts +12 -8
- package/dist/Tabs.js +2 -2
- package/dist/{Tabs.vue_vue_type_script_setup_true_lang-NZm1OrRT.js → Tabs.vue_vue_type_script_setup_true_lang-CmnBP4i1.js} +4 -4
- 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
- package/dist/TextEditor.js +3314 -3291
- package/dist/TextEditor.js.map +1 -1
- package/dist/TextEditor.vue.d.ts +5 -0
- package/dist/Textarea.js +3 -3
- package/dist/Textarea.js.map +1 -1
- package/dist/Thumbnail.js +7 -7
- package/dist/Thumbnail.js.map +1 -1
- package/dist/ThumbnailEmpty.js +3 -3
- package/dist/ThumbnailGroup.js +6 -6
- package/dist/ThumbnailGroup.js.map +1 -1
- package/dist/{ThumbnailGroup.keys-D6WL5xQ5.js → ThumbnailGroup.keys-EJ4qFNhx.js} +2 -2
- package/dist/{ThumbnailGroup.keys-D6WL5xQ5.js.map → ThumbnailGroup.keys-EJ4qFNhx.js.map} +1 -1
- package/dist/Timeline.js +2 -2
- package/dist/TimelineItem.js +3 -3
- package/dist/Toast.js +277 -280
- package/dist/Toast.js.map +1 -1
- package/dist/Toasts.js +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/components.css +1 -1
- package/dist/directives/autofocus.js +2 -2
- package/dist/directives/autofocus.js.map +1 -1
- package/dist/directives/sticky.js.map +1 -1
- package/dist/{formatDateTime-C8CYECpd.js → formatDateTime-Dz8bXV0R.js} +98 -12
- package/dist/{formatDateTime-C8CYECpd.js.map → formatDateTime-Dz8bXV0R.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/locale.js +3 -2
- package/dist/locale.js.map +1 -1
- package/dist/searchFuzzy-DRasJ33G.js +409 -0
- package/dist/{searchFuzzy-DKooyZM8.js.map → searchFuzzy-DRasJ33G.js.map} +1 -1
- package/dist/storage.js +3 -3
- package/dist/tailwind-base.js +0 -2
- package/dist/tailwind-base.js.map +1 -1
- package/dist/{toTimeZone-CVE1ZmsS.js → toTimeZone-Coq1oPTt.js} +7 -9
- package/dist/{toTimeZone-CVE1ZmsS.js.map → toTimeZone-Coq1oPTt.js.map} +1 -1
- package/dist/useModals.js.map +1 -1
- package/dist/usePaginationStats-d_q39naC.js +12 -0
- package/dist/usePaginationStats-d_q39naC.js.map +1 -0
- package/dist/useSearch.js +1 -1
- package/dist/useSelection.js +4 -1
- package/dist/useSelection.js.map +1 -1
- package/dist/useValidation.js +39 -36
- package/dist/useValidation.js.map +1 -1
- package/dist/utils/formatDateTime.js +2 -2
- package/dist/utils/helpers.js +29 -29
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/searchFuzzy.js +1 -1
- package/dist/utils/toTimeZone.js +1 -1
- package/package.json +42 -20
- package/tailwind-base.ts +0 -2
- package/types/jsonApi.ts +8 -8
- package/dist/DataView.keys-C7eaZg2G.js.map +0 -1
- package/dist/Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js.map +0 -1
- package/dist/searchFuzzy-DKooyZM8.js +0 -407
package/dist/DataView.js.map
CHANGED
|
@@ -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","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;AAAA,QAAIA,MAAUE;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AAS,MAAMZ,EAAM,QAAQ;AAAA,QACvC,gBAAgBY,EAAS,MAAMZ,EAAM,cAAc;AAAA,QACnD,SAAAkB;AAAA,QACA,YAAAK;AAAA,QACA,YAAAC;AAAA;AAAA,QAGA,eAAeG;AAAA,QACf,kBAAkBC;AAAA,QAClB,mBAAAC;AAAA;AAAA,QAGA,eAAejB,EAAS,MAAMqB,EAAe,KAAK;AAAA,QAClD,qBAAAG;AAAA;AAAA,QAGA,SAASxB,EAAS,MAAMZ,EAAM,OAAO;AAAA,QACrC,YAAAkC;AAAA,QACA,SAAStB,EAAS,MAAMZ,EAAM,KAAK,WAAW,CAAC;AAAA,QAC/C,cAAAmC;AAAA,QACA,WAAWvB,EAAS,MAAMZ,EAAM,SAAS;AAAA,QACzC,gBAAAc;AAAA,QACA,SAASH;AAAA,MACV,CAAA;AAAA,IACH,GAEaiC,EAAA;AAAA,MACX,MAAMhC,EAAS,MAAMG,EAAa,KAAK;AAAA,MACvC,UAAUH,EAAS,MAAMZ,EAAM,QAAQ;AAAA,MACvC,SAAAkB;AAAA,MACA,YAAAK;AAAA,MACA,YAAAC;AAAA,MACA,UAAUZ,EAAS,MAAMc,EAAa,KAAK;AAAA,MAC3C,mBAAAG;AAAA,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;AAAA,QAAIA,MAAUE;AAEZ,aAAOL,GAAmB,EAAE,IAAIG,GAAO,OAAOC,KAAY,OAAO;AAS/D,QAAA,CAACA,KAAY,CAACE;AACT,aAAAH;AAGL,QAAA,GAACC,KAAYE,MAAa,SAI1B;AAAA,UAAA,CAACF,KAAYE,MAAa;AAC5B,eAAO,IAAIH,CAAK;AAKd,UAAAC,MAAa,SAAS,CAACE;AAClB,eAAAH;AAGL,UAAA,EAAAC,MAAa,SAASE,MAAa,QAInC;AAAA,YAAAF,MAAa,SAASE,MAAa;AAC9B,iBAAAH;AAKL,YAAAC,MAAa,UAAU,CAACE;AAC1B,iBAAO,IAAIH,CAAK;AAGd,YAAA,EAAAC,MAAa,UAAUE,MAAa,WAIpCF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,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-
|
|
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;"}
|
package/dist/DataView.vue.d.ts
CHANGED
|
@@ -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;
|
package/dist/DataViewFilters.js
CHANGED
|
@@ -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,
|
|
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-
|
|
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-
|
|
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-
|
|
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,
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
})) :
|
|
73
|
+
})) : l("", !0)
|
|
74
74
|
]),
|
|
75
75
|
_: 2
|
|
76
76
|
}, 1024)
|
|
77
77
|
], 10, A),
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
})) :
|
|
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
|
-
})) :
|
|
104
|
+
})) : l("", !0);
|
|
105
105
|
}
|
|
106
106
|
}), z = "_dropdown__item_ozq17_2", L = {
|
|
107
107
|
dropdown__item: z
|
package/dist/DataViewToolbar.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
|
|
7
|
-
import { D as
|
|
8
|
-
const
|
|
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
|
-
},
|
|
12
|
+
}, Y = {
|
|
12
13
|
key: 0,
|
|
13
14
|
class: "tw-mr-1.5"
|
|
14
|
-
},
|
|
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(
|
|
25
|
-
const t =
|
|
26
|
-
isWithinModule:
|
|
25
|
+
setup(S, { emit: _ }) {
|
|
26
|
+
const t = S, C = _, {
|
|
27
|
+
isWithinModule: r,
|
|
27
28
|
variant: m,
|
|
28
29
|
density: p,
|
|
29
|
-
currentPage:
|
|
30
|
+
currentPage: d,
|
|
30
31
|
hasToolbar: w,
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
isPaginateNextDisabled: B,
|
|
33
|
+
isPaginationEnabled: P,
|
|
34
|
+
isSelectable: E,
|
|
33
35
|
pageCount: f,
|
|
34
|
-
pageSize:
|
|
35
|
-
totalDataCount:
|
|
36
|
-
goPrevPage:
|
|
37
|
-
goNextPage:
|
|
38
|
-
isEmpty:
|
|
39
|
-
isLoading:
|
|
40
|
-
} =
|
|
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
|
-
|
|
44
|
+
C("select"), b.value++;
|
|
46
45
|
}
|
|
47
|
-
return
|
|
46
|
+
return W(() => {
|
|
48
47
|
w && (w.value = !0);
|
|
49
|
-
}), (
|
|
50
|
-
class:
|
|
51
|
-
"tw-border-t tw-border-ice-200": e(
|
|
52
|
-
"tw-rounded-tr":
|
|
53
|
-
"tw-rounded":
|
|
54
|
-
"tw-rounded-t":
|
|
55
|
-
"tw-mb-3": e(m) !== "table" && !e(
|
|
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
|
-
|
|
62
|
-
e(
|
|
63
|
-
key:
|
|
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(
|
|
67
|
-
disabled: e(
|
|
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"])) :
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
}, null, 8, ["checked", "indeterminate", "title", "disabled"])) : s("", !0),
|
|
70
|
+
h("div", Q, [
|
|
71
|
+
K(A.$slots, "default")
|
|
73
72
|
])
|
|
74
73
|
]),
|
|
75
|
-
e(
|
|
76
|
-
t.hidePageStats ?
|
|
77
|
-
e(f) > 1 ? (
|
|
78
|
-
|
|
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(
|
|
83
|
-
onClick:
|
|
82
|
+
disabled: e(u) || e(d) === 1,
|
|
83
|
+
onClick: o[0] || (o[0] = (I) => e(D)({ shouldEmit: !0 }))
|
|
84
84
|
}, {
|
|
85
|
-
default:
|
|
86
|
-
|
|
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
|
-
|
|
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(
|
|
98
|
-
onClick:
|
|
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:
|
|
101
|
-
|
|
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)) :
|
|
109
|
-
])) :
|
|
108
|
+
}, 8, ["aria-label", "disabled"])
|
|
109
|
+
], 64)) : s("", !0)
|
|
110
|
+
])) : s("", !0)
|
|
110
111
|
], 2));
|
|
111
112
|
}
|
|
112
113
|
});
|
|
113
114
|
export {
|
|
114
|
-
|
|
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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|