@leaflink/stash 41.6.4 → 42.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Switch.js CHANGED
@@ -1,9 +1,9 @@
1
- import { defineComponent as v, useAttrs as x, useSlots as k, computed as c, openBlock as i, createElementBlock as d, normalizeClass as a, unref as n, createElementVNode as l, mergeProps as g, withDirectives as y, vModelCheckbox as S, toDisplayString as u, createCommentVNode as p, renderSlot as I, createTextVNode as A, pushScopeId as C, popScopeId as V } from "vue";
1
+ import { defineComponent as v, useAttrs as x, useSlots as k, computed as o, openBlock as d, createElementBlock as i, normalizeClass as a, unref as n, createElementVNode as l, mergeProps as g, withDirectives as y, vModelCheckbox as S, toDisplayString as u, createCommentVNode as p, renderSlot as I, createTextVNode as A, pushScopeId as C, popScopeId as V } from "vue";
2
2
  import { u as B } from "./uniqueId-847efe53.js";
3
3
  import { _ as T } from "./_plugin-vue_export-helper-dad06003.js";
4
4
  import "./toString-7d5bf363.js";
5
5
  import "./isObjectLike-54341556.js";
6
- const E = (s) => (C("data-v-67f51f58"), s = s(), V(), s), N = ["data-test"], D = ["for"], q = /* @__PURE__ */ E(() => /* @__PURE__ */ l("span", { class: "stash-switch__control tw-bg-white tw-border tw-border-solid tw-border-ice-500 tw-rounded-[10px] tw-h-5 tw-absolute tw-left-0 tw-w-5 tw-shadow-low" }, null, -1)), z = ["id", "disabled", "name", "value"], M = /* @__PURE__ */ v({
6
+ const E = (s) => (C("data-v-dc85b7ec"), s = s(), V(), s), N = ["data-test"], D = ["for"], q = /* @__PURE__ */ E(() => /* @__PURE__ */ l("span", { class: "stash-switch__control tw-bg-white tw-border tw-border-solid tw-border-ice-500 tw-rounded-[10px] tw-h-5 tw-absolute tw-left-0 tw-w-5 tw-shadow" }, null, -1)), z = ["id", "disabled", "name", "value"], M = /* @__PURE__ */ v({
7
7
  name: "ll-switch",
8
8
  inheritAttrs: !1,
9
9
  __name: "Switch",
@@ -17,30 +17,30 @@ const E = (s) => (C("data-v-67f51f58"), s = s(), V(), s), N = ["data-test"], D =
17
17
  value: { default: "" }
18
18
  },
19
19
  emits: ["update:checked"],
20
- setup(s, { emit: f }) {
21
- const t = s, o = x(), b = k();
22
- if (typeof t.value == "boolean" && console.warn("Switch: use `checked` to toggle the state; `value` is what will be set if `checked` is true"), o.onChange)
20
+ setup(s, { emit: b }) {
21
+ const t = s, c = x(), m = k();
22
+ if (typeof t.value == "boolean" && console.warn("Switch: use `checked` to toggle the state; `value` is what will be set if `checked` is true"), c.onChange)
23
23
  throw new Error("ll-switch: use the @update:checked event instead of @change.");
24
- const m = c(() => {
25
- const e = { ...o };
24
+ const _ = o(() => {
25
+ const e = { ...c };
26
26
  return delete e["data-test"], delete e.class, e;
27
- }), r = c({
27
+ }), r = o({
28
28
  get() {
29
29
  return t.checked;
30
30
  },
31
31
  set(e) {
32
- f("update:checked", e);
32
+ b("update:checked", e);
33
33
  }
34
- }), w = c(() => t.id || B("switch-"));
35
- return (e, h) => (i(), d("div", {
36
- class: a(["stash-switch", n(o).class]),
37
- "data-test": n(o)["data-test"] || "stash-switch"
34
+ }), w = o(() => t.id || B("switch-"));
35
+ return (e, h) => (d(), i("div", {
36
+ class: a(["stash-switch", n(c).class]),
37
+ "data-test": n(c)["data-test"] || "stash-switch"
38
38
  }, [
39
39
  l("label", g({
40
40
  for: w.value,
41
41
  class: [{ "tw-pointer-events-none": t.disabled }, "tw-flex tw-cursor-pointer"],
42
42
  "data-test": "stash-switch|label"
43
- }, m.value), [
43
+ }, _.value), [
44
44
  l("span", {
45
45
  class: a(["tw-inline-block tw-h-5 tw-relative tw-min-w-[34px] tw-w-[34px]", { "is-active": t.checked }])
46
46
  }, [
@@ -51,7 +51,7 @@ const E = (s) => (C("data-v-67f51f58"), s = s(), V(), s), N = ["data-test"], D =
51
51
  ], 2),
52
52
  y(l("input", {
53
53
  id: w.value,
54
- "onUpdate:modelValue": h[0] || (h[0] = (_) => r.value = _),
54
+ "onUpdate:modelValue": h[0] || (h[0] = (f) => r.value = f),
55
55
  type: "checkbox",
56
56
  disabled: t.disabled,
57
57
  name: t.name,
@@ -61,7 +61,7 @@ const E = (s) => (C("data-v-67f51f58"), s = s(), V(), s), N = ["data-test"], D =
61
61
  }, null, 8, z), [
62
62
  [S, r.value]
63
63
  ]),
64
- t.label ? (i(), d("span", {
64
+ t.label ? (d(), i("span", {
65
65
  key: 0,
66
66
  class: a([{
67
67
  "tw-text-ice-700": !t.checked && !t.disabled,
@@ -71,7 +71,7 @@ const E = (s) => (C("data-v-67f51f58"), s = s(), V(), s), N = ["data-test"], D =
71
71
  "data-test": "stash-switch|label-text"
72
72
  }, u(t.label), 3)) : p("", !0)
73
73
  ], 16, D),
74
- t.hintText || n(b).hint ? (i(), d("span", {
74
+ t.hintText || n(m).hint ? (d(), i("span", {
75
75
  key: 0,
76
76
  class: a(["tw-block tw-text-xs tw-mt-1.5 tw-ml-[40px] tw-whitespace-pre-line", { "tw-text-ice-500": t.disabled }]),
77
77
  "data-test": "stash-switch|hint"
@@ -83,7 +83,7 @@ const E = (s) => (C("data-v-67f51f58"), s = s(), V(), s), N = ["data-test"], D =
83
83
  ], 10, N));
84
84
  }
85
85
  });
86
- const G = /* @__PURE__ */ T(M, [["__scopeId", "data-v-67f51f58"]]);
86
+ const G = /* @__PURE__ */ T(M, [["__scopeId", "data-v-dc85b7ec"]]);
87
87
  export {
88
88
  G as default
89
89
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sources":["../src/components/Switch/Switch.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, useAttrs, useSlots } from 'vue';\n\n export interface SwitchProps {\n /**\n * The current checked value, can be a boolean or an array of values\n */\n checked?: boolean | Array<string | number>;\n /**\n * Prevent the user from changing the switch state.\n */\n disabled?: boolean;\n /**\n * Displays text below the input; hidden when the isReadOnly prop is truthy.\n */\n hintText?: string;\n /**\n * Unique ID for the switch, required for accessibility purposes\n */\n id?: string;\n /**\n * Label text to display with switch\n */\n label?: string;\n /**\n * HTML name property\n */\n name?: string;\n /**\n * Value associated with switch when it is `checked`. This value is\n * used to compare against `checked` property when passed as an array.\n */\n value?: string | number;\n }\n\n defineOptions({\n name: 'll-switch',\n inheritAttrs: false,\n });\n\n const props = withDefaults(defineProps<SwitchProps>(), {\n checked: false,\n disabled: false,\n hintText: '',\n id: undefined,\n label: '',\n name: '',\n value: '',\n });\n\n const attrs = useAttrs();\n const slots = useSlots();\n\n const emit =\n defineEmits<{\n (e: 'update:checked', value: SwitchProps['checked']): void;\n }>();\n\n if (typeof props.value === 'boolean') {\n console.warn('Switch: use `checked` to toggle the state; `value` is what will be set if `checked` is true');\n }\n\n if (attrs.onChange) {\n throw new Error('ll-switch: use the @update:checked event instead of @change.');\n }\n\n const switchAttrs = computed(() => {\n const tempAttrs = { ...attrs };\n\n delete tempAttrs['data-test'];\n delete tempAttrs.class;\n\n return tempAttrs;\n });\n\n const internalValue = computed({\n get() {\n return props.checked;\n },\n set(value) {\n emit('update:checked', value);\n },\n });\n\n const switchId = computed(() => props.id || uniqueId('switch-'));\n</script>\n\n<template>\n <div class=\"stash-switch\" :class=\"attrs['class']\" :data-test=\"attrs['data-test'] || 'stash-switch'\">\n <label\n :for=\"switchId\"\n :class=\"{ 'tw-pointer-events-none': props.disabled }\"\n class=\"tw-flex tw-cursor-pointer\"\n data-test=\"stash-switch|label\"\n v-bind=\"switchAttrs\"\n >\n <span\n class=\"tw-inline-block tw-h-5 tw-relative tw-min-w-[34px] tw-w-[34px]\"\n :class=\"{ 'is-active': props.checked }\"\n >\n <span\n class=\"stash-switch__track tw-rounded-[10px] tw-h-4 tw-absolute tw-top-0.5 tw-w-full\"\n :class=\"props.disabled ? 'tw-bg-ice-500' : 'tw-bg-ice-700'\"\n ></span>\n <span\n class=\"\n stash-switch__control\n tw-bg-white\n tw-border\n tw-border-solid\n tw-border-ice-500\n tw-rounded-[10px]\n tw-h-5\n tw-absolute\n tw-left-0\n tw-w-5\n tw-shadow-low\n \"\n ></span>\n </span>\n <input\n :id=\"switchId\"\n v-model=\"internalValue\"\n type=\"checkbox\"\n :disabled=\"props.disabled\"\n :name=\"props.name\"\n tabindex=\"0\"\n :value=\"value\"\n class=\"tw-sr-only\"\n />\n <span\n v-if=\"props.label\"\n :class=\"{\n 'tw-text-ice-700': !props.checked && !props.disabled,\n 'tw-text-ice-900': props.checked,\n 'tw-text-ice-500': props.disabled,\n }\"\n class=\"tw-relative tw-top-[1px] tw-ml-1.5\"\n data-test=\"stash-switch|label-text\"\n >{{ props.label }}</span\n >\n </label>\n <span\n v-if=\"props.hintText || slots.hint\"\n class=\"tw-block tw-text-xs tw-mt-1.5 tw-ml-[40px] tw-whitespace-pre-line\"\n :class=\"{ 'tw-text-ice-500': props.disabled }\"\n data-test=\"stash-switch|hint\"\n >\n <!-- @slot for displaying hint text -->\n <slot name=\"hint\">{{ props.hintText }}</slot>\n </span>\n </div>\n</template>\n\n<style scoped>\n .is-active .stash-switch__track {\n @apply tw-bg-blue-500;\n }\n\n .stash-switch__control {\n transition: left 0.2s ease-in-out;\n\n .is-active & {\n @apply tw-left-3.5; /* track width - switch width */\n }\n }\n</style>\n"],"names":["attrs","useAttrs","slots","useSlots","props","switchAttrs","computed","tempAttrs","internalValue","value","emit","switchId","uniqueId"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAmDQA,IAAQC,KACRC,IAAQC;AAWd,QAJI,OAAOC,EAAM,SAAU,aACzB,QAAQ,KAAK,6FAA6F,GAGxGJ,EAAM;AACF,YAAA,IAAI,MAAM,8DAA8D;AAG1E,UAAAK,IAAcC,EAAS,MAAM;AAC3B,YAAAC,IAAY,EAAE,GAAGP;AAEvB,oBAAOO,EAAU,WAAW,GAC5B,OAAOA,EAAU,OAEVA;AAAA,IAAA,CACR,GAEKC,IAAgBF,EAAS;AAAA,MAC7B,MAAM;AACJ,eAAOF,EAAM;AAAA,MACf;AAAA,MACA,IAAIK,GAAO;AACT,QAAAC,EAAK,kBAAkBD,CAAK;AAAA,MAC9B;AAAA,IAAA,CACD,GAEKE,IAAWL,EAAS,MAAMF,EAAM,MAAMQ,EAAS,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Switch.js","sources":["../src/components/Switch/Switch.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, useAttrs, useSlots } from 'vue';\n\n export interface SwitchProps {\n /**\n * The current checked value, can be a boolean or an array of values\n */\n checked?: boolean | Array<string | number>;\n /**\n * Prevent the user from changing the switch state.\n */\n disabled?: boolean;\n /**\n * Displays text below the input; hidden when the isReadOnly prop is truthy.\n */\n hintText?: string;\n /**\n * Unique ID for the switch, required for accessibility purposes\n */\n id?: string;\n /**\n * Label text to display with switch\n */\n label?: string;\n /**\n * HTML name property\n */\n name?: string;\n /**\n * Value associated with switch when it is `checked`. This value is\n * used to compare against `checked` property when passed as an array.\n */\n value?: string | number;\n }\n\n defineOptions({\n name: 'll-switch',\n inheritAttrs: false,\n });\n\n const props = withDefaults(defineProps<SwitchProps>(), {\n checked: false,\n disabled: false,\n hintText: '',\n id: undefined,\n label: '',\n name: '',\n value: '',\n });\n\n const attrs = useAttrs();\n const slots = useSlots();\n\n const emit =\n defineEmits<{\n (e: 'update:checked', value: SwitchProps['checked']): void;\n }>();\n\n if (typeof props.value === 'boolean') {\n console.warn('Switch: use `checked` to toggle the state; `value` is what will be set if `checked` is true');\n }\n\n if (attrs.onChange) {\n throw new Error('ll-switch: use the @update:checked event instead of @change.');\n }\n\n const switchAttrs = computed(() => {\n const tempAttrs = { ...attrs };\n\n delete tempAttrs['data-test'];\n delete tempAttrs.class;\n\n return tempAttrs;\n });\n\n const internalValue = computed({\n get() {\n return props.checked;\n },\n set(value) {\n emit('update:checked', value);\n },\n });\n\n const switchId = computed(() => props.id || uniqueId('switch-'));\n</script>\n\n<template>\n <div class=\"stash-switch\" :class=\"attrs['class']\" :data-test=\"attrs['data-test'] || 'stash-switch'\">\n <label\n :for=\"switchId\"\n :class=\"{ 'tw-pointer-events-none': props.disabled }\"\n class=\"tw-flex tw-cursor-pointer\"\n data-test=\"stash-switch|label\"\n v-bind=\"switchAttrs\"\n >\n <span\n class=\"tw-inline-block tw-h-5 tw-relative tw-min-w-[34px] tw-w-[34px]\"\n :class=\"{ 'is-active': props.checked }\"\n >\n <span\n class=\"stash-switch__track tw-rounded-[10px] tw-h-4 tw-absolute tw-top-0.5 tw-w-full\"\n :class=\"props.disabled ? 'tw-bg-ice-500' : 'tw-bg-ice-700'\"\n ></span>\n <span\n class=\"\n stash-switch__control\n tw-bg-white\n tw-border\n tw-border-solid\n tw-border-ice-500\n tw-rounded-[10px]\n tw-h-5\n tw-absolute\n tw-left-0\n tw-w-5\n tw-shadow\n \"\n ></span>\n </span>\n <input\n :id=\"switchId\"\n v-model=\"internalValue\"\n type=\"checkbox\"\n :disabled=\"props.disabled\"\n :name=\"props.name\"\n tabindex=\"0\"\n :value=\"value\"\n class=\"tw-sr-only\"\n />\n <span\n v-if=\"props.label\"\n :class=\"{\n 'tw-text-ice-700': !props.checked && !props.disabled,\n 'tw-text-ice-900': props.checked,\n 'tw-text-ice-500': props.disabled,\n }\"\n class=\"tw-relative tw-top-[1px] tw-ml-1.5\"\n data-test=\"stash-switch|label-text\"\n >{{ props.label }}</span\n >\n </label>\n <span\n v-if=\"props.hintText || slots.hint\"\n class=\"tw-block tw-text-xs tw-mt-1.5 tw-ml-[40px] tw-whitespace-pre-line\"\n :class=\"{ 'tw-text-ice-500': props.disabled }\"\n data-test=\"stash-switch|hint\"\n >\n <!-- @slot for displaying hint text -->\n <slot name=\"hint\">{{ props.hintText }}</slot>\n </span>\n </div>\n</template>\n\n<style scoped>\n .is-active .stash-switch__track {\n @apply tw-bg-blue-500;\n }\n\n .stash-switch__control {\n transition: left 0.2s ease-in-out;\n\n .is-active & {\n @apply tw-left-3.5; /* track width - switch width */\n }\n }\n</style>\n"],"names":["attrs","useAttrs","slots","useSlots","props","switchAttrs","computed","tempAttrs","internalValue","value","emit","switchId","uniqueId"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAmDQA,IAAQC,KACRC,IAAQC;AAWd,QAJI,OAAOC,EAAM,SAAU,aACzB,QAAQ,KAAK,6FAA6F,GAGxGJ,EAAM;AACF,YAAA,IAAI,MAAM,8DAA8D;AAG1E,UAAAK,IAAcC,EAAS,MAAM;AAC3B,YAAAC,IAAY,EAAE,GAAGP;AAEvB,oBAAOO,EAAU,WAAW,GAC5B,OAAOA,EAAU,OAEVA;AAAA,IAAA,CACR,GAEKC,IAAgBF,EAAS;AAAA,MAC7B,MAAM;AACJ,eAAOF,EAAM;AAAA,MACf;AAAA,MACA,IAAIK,GAAO;AACT,QAAAC,EAAK,kBAAkBD,CAAK;AAAA,MAC9B;AAAA,IAAA,CACD,GAEKE,IAAWL,EAAS,MAAMF,EAAM,MAAMQ,EAAS,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/Table.js CHANGED
@@ -70,8 +70,8 @@ const J = { class: "tw-relative tw-border-separate tw-max-w-initial tw-min-w-ful
70
70
  { "tw-rounded": c.value === "rounded" },
71
71
  { "tw-rounded-b": c.value === "rounded-bottom" },
72
72
  { "tw-border-t tw-border-ice-200": n(p) === "table" },
73
- { "tw-shadow-low tw-overflow-auto": r.value === "scroll" },
74
- { "lg:tw-shadow-low tw-overflow-visble lg:tw-overflow-auto": r.value === "stack" },
73
+ { "tw-shadow tw-overflow-auto": r.value === "scroll" },
74
+ { "lg:tw-shadow tw-overflow-visble lg:tw-overflow-auto": r.value === "stack" },
75
75
  { "tw-min-h-[300px]": f.value && !t.isLoading }
76
76
  // prevent the table from collapsing on small screen heights when the max-height is dynamic
77
77
  ]]),
package/dist/Table.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["../src/components/Table/Table.types.ts","../src/components/Table/Table.vue"],"sourcesContent":["import { ComputedRef } from 'vue';\n\nimport { SpacingDensities } from '../../../types/misc';\n\nexport enum Layout {\n Scroll = 'scroll',\n Stack = 'stack',\n}\n\nexport type Layouts = `${Layout}`;\n\nexport enum TableRadius {\n None = 'none',\n Rounded = 'rounded',\n RoundedBottom = 'rounded-bottom',\n}\n\nexport type TableRadiuses = `${TableRadius}`;\n\n/**\n * Properties and utilities provided to children of a Table instance\n */\nexport interface TableInjection {\n /**\n * Controls the Table's padding; the default value is \"comfortable\". On small screens, the density will always be \"compact\".\n */\n density: ComputedRef<SpacingDensities>;\n\n /**\n * Styles the last column for \"row actions\"\n */\n hasActions: ComputedRef<boolean>;\n\n /**\n * If true, hides the default expansion toggle column\n */\n hasCustomExpandToggle: ComputedRef<boolean>;\n\n /**\n * Adds a toggle column for row expansion. This is primarily needed for ensuring the corresponding empty TableHeaderRow is included.\n */\n isExpandable: ComputedRef<boolean>;\n\n /**\n * Adds a checkbox column for selecting rows; intended for use with the `useSelection` composable.\n */\n isSelectable: ComputedRef<boolean>;\n\n /**\n * Sets the table layout; the default value is \"scroll\".\n */\n layout: ComputedRef<Layouts>;\n}\n","<script lang=\"ts\">\n import { SpacingDensities, SpacingDensity } from '../../../types/misc';\n import { MODULE_INJECTION } from '../Module/Module.keys';\n import { Layouts, TableRadiuses } from './Table.types';\n\n export * from './Table.keys';\n export * from './Table.types';\n\n export interface TableProps {\n /**\n * Controls the Table'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 /**\n * Sets the text for the empty state; the default value is \"No Results\".\n */\n emptyStateText?: string;\n\n /**\n * Styles the last column for \"row actions\"\n */\n hasActions?: boolean;\n\n /**\n * If true, hides the default expansion toggle column\n */\n hasCustomExpandToggle?: boolean;\n\n /**\n * Shows the empty state\n */\n isEmpty?: boolean;\n\n /**\n * Shows the loading state\n */\n isLoading?: boolean;\n\n /**\n * Adds a toggle column for row expansion. This is primarily needed for ensuring the corresponding empty TableHeaderRow is included.\n */\n isExpandable?: boolean;\n\n /**\n * Adds a checkbox column for selecting rows; intended for use with the `useSelection` composable.\n */\n isSelectable?: boolean;\n\n /**\n * Sets the table layout; the default value is \"scroll\".\n */\n layout?: Layouts;\n\n /**\n * Controls the corners of the table with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: TableRadiuses;\n\n /**\n * Allows the table head to be sticky when scrolling inside the table body\n */\n stickyHeader?: {\n listLength: number;\n maxHeight: string;\n };\n }\n</script>\n\n<script setup lang=\"ts\">\n import { computed, inject, provide } from 'vue';\n\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import EmptyState from '../EmptyState/EmptyState.vue';\n import Loading from '../Loading/Loading.vue';\n import TableCell from '../TableCell/TableCell.vue';\n import TableRow from '../TableRow/TableRow.vue';\n import { TABLE_INJECTION } from './Table.keys';\n\n const props = withDefaults(defineProps<TableProps>(), {\n density: undefined,\n emptyStateText: '',\n hasActions: false,\n hasCustomExpandToggle: false,\n isEmpty: false,\n isLoading: false,\n isExpandable: false,\n isSelectable: false,\n layout: 'scroll',\n radius: 'rounded',\n stickyHeader: undefined,\n });\n\n const {\n density: dataViewDensity,\n variant: dataViewVariant,\n isLoading: isDataViewLoading,\n isEmpty: isDataViewEmpty,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const { variant: moduleVariant } = inject(MODULE_INJECTION.key, MODULE_INJECTION.defaults);\n\n const computedRadius = computed<TableRadiuses>(() => {\n // Will work for tables when rendered inside of a Module with OR without a DataView.\n if (moduleVariant?.value === 'table') {\n return 'rounded-bottom';\n }\n\n if (dataViewVariant.value === 'table') {\n return 'rounded-bottom';\n }\n\n return props.radius;\n });\n\n const computedLayout = computed<Layouts>(() => {\n if (props.stickyHeader) {\n return 'scroll';\n }\n\n return props.layout;\n });\n\n const isStickyHeaderEnabled = computed<boolean>(() => {\n return !!(\n (\n props.stickyHeader?.maxHeight && // table can't scroll without a max height; sticky headers only needed for a scrollable table\n props.stickyHeader?.listLength > 3\n ) // scrollable table and sticky headers not needed when list is small\n );\n });\n\n const rootStyle = computed(() => ({\n maxHeight: isStickyHeaderEnabled.value ? props.stickyHeader?.maxHeight : '',\n }));\n\n provide(TABLE_INJECTION.key, {\n density: computed(() => props.density || dataViewDensity.value || SpacingDensity.Comfortable),\n hasCustomExpandToggle: computed(() => props.hasCustomExpandToggle),\n hasActions: computed(() => props.hasActions),\n isExpandable: computed(() => props.isExpandable),\n isSelectable: computed(() => props.isSelectable && !props.isLoading && !props.isEmpty),\n layout: computedLayout,\n });\n</script>\n\n<template>\n <div\n class=\"stash-table tw-relative\"\n :class=\"[\n { 'tw-rounded': computedRadius === 'rounded' },\n { 'tw-rounded-b': computedRadius === 'rounded-bottom' },\n { 'tw-border-t tw-border-ice-200': dataViewVariant === 'table' },\n { 'tw-shadow-low tw-overflow-auto': computedLayout === 'scroll' },\n { 'lg:tw-shadow-low tw-overflow-visble lg:tw-overflow-auto': computedLayout === 'stack' },\n { 'tw-min-h-[300px]': isStickyHeaderEnabled && !props.isLoading }, // prevent the table from collapsing on small screen heights when the max-height is dynamic\n ]\"\n data-test=\"stash-table\"\n :style=\"rootStyle\"\n >\n <table class=\"tw-relative tw-border-separate tw-max-w-initial tw-min-w-full\">\n <thead\n class=\"tw-border-b tw-border-ice-200\"\n :class=\"{\n 'tw-hidden lg:tw-table-header-group': computedLayout === 'stack',\n }\"\n >\n <!-- @slot head -->\n <slot name=\"head\"> </slot>\n </thead>\n <tbody>\n <TableRow v-if=\"props.isLoading || isDataViewLoading\">\n <TableCell colspan=\"100%\">\n <Loading />\n </TableCell>\n </TableRow>\n <!-- @slot empty -->\n <slot v-else-if=\"props.isEmpty || isDataViewEmpty\" name=\"empty\">\n <TableRow>\n <TableCell colspan=\"100%\">\n <EmptyState class=\"tw-bg-white tw-w-full\" :text=\"props.emptyStateText\" />\n </TableCell>\n </TableRow>\n </slot>\n <!-- @slot body -->\n <slot v-else name=\"body\"></slot>\n </tbody>\n </table>\n </div>\n</template>\n"],"names":["Layout","TableRadius","dataViewDensity","dataViewVariant","isDataViewLoading","isDataViewEmpty","inject","DATA_VIEW_INJECTION","moduleVariant","MODULE_INJECTION","computedRadius","computed","props","computedLayout","isStickyHeaderEnabled","_a","_b","rootStyle","provide","TABLE_INJECTION","SpacingDensity"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,QAAQ,SAFEA,IAAAA,KAAA,CAAA,CAAA,GAOAC,sBAAAA,OACVA,EAAA,OAAO,QACPA,EAAA,UAAU,WACVA,EAAA,gBAAgB,kBAHNA,IAAAA,KAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;iBCkFJ;AAAA,MACJ,SAASC;AAAA,MACT,SAASC;AAAA,MACT,WAAWC;AAAA,MACX,SAASC;AAAA,IACP,IAAAC,EAAOC,EAAoB,KAAKA,EAAoB,QAAQ,GAE1D,EAAE,SAASC,MAAkBF,EAAOG,EAAiB,KAAKA,EAAiB,QAAQ,GAEnFC,IAAiBC,EAAwB,OAEzCH,KAAA,gBAAAA,EAAe,WAAU,WAIzBL,EAAgB,UAAU,UACrB,mBAGFS,EAAM,MACd,GAEKC,IAAiBF,EAAkB,MACnCC,EAAM,eACD,WAGFA,EAAM,MACd,GAEKE,IAAwBH,EAAkB,MAAM;;AAC7C,aAAA,CAAC,GAEJI,IAAAH,EAAM,iBAAN,QAAAG,EAAoB;AAAA,QACpBC,IAAAJ,EAAM,iBAAN,gBAAAI,EAAoB,cAAa;AAAA,IAAA,CAGtC,GAEKC,IAAYN,EAAS,MAAO;;AAAA;AAAA,QAChC,WAAWG,EAAsB,SAAQC,IAAAH,EAAM,iBAAN,gBAAAG,EAAoB,YAAY;AAAA,MACzE;AAAA,KAAA;AAEF,WAAAG,EAAQC,EAAgB,KAAK;AAAA,MAC3B,SAASR,EAAS,MAAMC,EAAM,WAAWV,EAAgB,SAASkB,EAAe,WAAW;AAAA,MAC5F,uBAAuBT,EAAS,MAAMC,EAAM,qBAAqB;AAAA,MACjE,YAAYD,EAAS,MAAMC,EAAM,UAAU;AAAA,MAC3C,cAAcD,EAAS,MAAMC,EAAM,YAAY;AAAA,MAC/C,cAAcD,EAAS,MAAMC,EAAM,gBAAgB,CAACA,EAAM,aAAa,CAACA,EAAM,OAAO;AAAA,MACrF,QAAQC;AAAA,IAAA,CACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Table.js","sources":["../src/components/Table/Table.types.ts","../src/components/Table/Table.vue"],"sourcesContent":["import { ComputedRef } from 'vue';\n\nimport { SpacingDensities } from '../../../types/misc';\n\nexport enum Layout {\n Scroll = 'scroll',\n Stack = 'stack',\n}\n\nexport type Layouts = `${Layout}`;\n\nexport enum TableRadius {\n None = 'none',\n Rounded = 'rounded',\n RoundedBottom = 'rounded-bottom',\n}\n\nexport type TableRadiuses = `${TableRadius}`;\n\n/**\n * Properties and utilities provided to children of a Table instance\n */\nexport interface TableInjection {\n /**\n * Controls the Table's padding; the default value is \"comfortable\". On small screens, the density will always be \"compact\".\n */\n density: ComputedRef<SpacingDensities>;\n\n /**\n * Styles the last column for \"row actions\"\n */\n hasActions: ComputedRef<boolean>;\n\n /**\n * If true, hides the default expansion toggle column\n */\n hasCustomExpandToggle: ComputedRef<boolean>;\n\n /**\n * Adds a toggle column for row expansion. This is primarily needed for ensuring the corresponding empty TableHeaderRow is included.\n */\n isExpandable: ComputedRef<boolean>;\n\n /**\n * Adds a checkbox column for selecting rows; intended for use with the `useSelection` composable.\n */\n isSelectable: ComputedRef<boolean>;\n\n /**\n * Sets the table layout; the default value is \"scroll\".\n */\n layout: ComputedRef<Layouts>;\n}\n","<script lang=\"ts\">\n import { SpacingDensities, SpacingDensity } from '../../../types/misc';\n import { MODULE_INJECTION } from '../Module/Module.keys';\n import { Layouts, TableRadiuses } from './Table.types';\n\n export * from './Table.keys';\n export * from './Table.types';\n\n export interface TableProps {\n /**\n * Controls the Table'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 /**\n * Sets the text for the empty state; the default value is \"No Results\".\n */\n emptyStateText?: string;\n\n /**\n * Styles the last column for \"row actions\"\n */\n hasActions?: boolean;\n\n /**\n * If true, hides the default expansion toggle column\n */\n hasCustomExpandToggle?: boolean;\n\n /**\n * Shows the empty state\n */\n isEmpty?: boolean;\n\n /**\n * Shows the loading state\n */\n isLoading?: boolean;\n\n /**\n * Adds a toggle column for row expansion. This is primarily needed for ensuring the corresponding empty TableHeaderRow is included.\n */\n isExpandable?: boolean;\n\n /**\n * Adds a checkbox column for selecting rows; intended for use with the `useSelection` composable.\n */\n isSelectable?: boolean;\n\n /**\n * Sets the table layout; the default value is \"scroll\".\n */\n layout?: Layouts;\n\n /**\n * Controls the corners of the table with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: TableRadiuses;\n\n /**\n * Allows the table head to be sticky when scrolling inside the table body\n */\n stickyHeader?: {\n listLength: number;\n maxHeight: string;\n };\n }\n</script>\n\n<script setup lang=\"ts\">\n import { computed, inject, provide } from 'vue';\n\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import EmptyState from '../EmptyState/EmptyState.vue';\n import Loading from '../Loading/Loading.vue';\n import TableCell from '../TableCell/TableCell.vue';\n import TableRow from '../TableRow/TableRow.vue';\n import { TABLE_INJECTION } from './Table.keys';\n\n const props = withDefaults(defineProps<TableProps>(), {\n density: undefined,\n emptyStateText: '',\n hasActions: false,\n hasCustomExpandToggle: false,\n isEmpty: false,\n isLoading: false,\n isExpandable: false,\n isSelectable: false,\n layout: 'scroll',\n radius: 'rounded',\n stickyHeader: undefined,\n });\n\n const {\n density: dataViewDensity,\n variant: dataViewVariant,\n isLoading: isDataViewLoading,\n isEmpty: isDataViewEmpty,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const { variant: moduleVariant } = inject(MODULE_INJECTION.key, MODULE_INJECTION.defaults);\n\n const computedRadius = computed<TableRadiuses>(() => {\n // Will work for tables when rendered inside of a Module with OR without a DataView.\n if (moduleVariant?.value === 'table') {\n return 'rounded-bottom';\n }\n\n if (dataViewVariant.value === 'table') {\n return 'rounded-bottom';\n }\n\n return props.radius;\n });\n\n const computedLayout = computed<Layouts>(() => {\n if (props.stickyHeader) {\n return 'scroll';\n }\n\n return props.layout;\n });\n\n const isStickyHeaderEnabled = computed<boolean>(() => {\n return !!(\n (\n props.stickyHeader?.maxHeight && // table can't scroll without a max height; sticky headers only needed for a scrollable table\n props.stickyHeader?.listLength > 3\n ) // scrollable table and sticky headers not needed when list is small\n );\n });\n\n const rootStyle = computed(() => ({\n maxHeight: isStickyHeaderEnabled.value ? props.stickyHeader?.maxHeight : '',\n }));\n\n provide(TABLE_INJECTION.key, {\n density: computed(() => props.density || dataViewDensity.value || SpacingDensity.Comfortable),\n hasCustomExpandToggle: computed(() => props.hasCustomExpandToggle),\n hasActions: computed(() => props.hasActions),\n isExpandable: computed(() => props.isExpandable),\n isSelectable: computed(() => props.isSelectable && !props.isLoading && !props.isEmpty),\n layout: computedLayout,\n });\n</script>\n\n<template>\n <div\n class=\"stash-table tw-relative\"\n :class=\"[\n { 'tw-rounded': computedRadius === 'rounded' },\n { 'tw-rounded-b': computedRadius === 'rounded-bottom' },\n { 'tw-border-t tw-border-ice-200': dataViewVariant === 'table' },\n { 'tw-shadow tw-overflow-auto': computedLayout === 'scroll' },\n { 'lg:tw-shadow tw-overflow-visble lg:tw-overflow-auto': computedLayout === 'stack' },\n { 'tw-min-h-[300px]': isStickyHeaderEnabled && !props.isLoading }, // prevent the table from collapsing on small screen heights when the max-height is dynamic\n ]\"\n data-test=\"stash-table\"\n :style=\"rootStyle\"\n >\n <table class=\"tw-relative tw-border-separate tw-max-w-initial tw-min-w-full\">\n <thead\n class=\"tw-border-b tw-border-ice-200\"\n :class=\"{\n 'tw-hidden lg:tw-table-header-group': computedLayout === 'stack',\n }\"\n >\n <!-- @slot head -->\n <slot name=\"head\"> </slot>\n </thead>\n <tbody>\n <TableRow v-if=\"props.isLoading || isDataViewLoading\">\n <TableCell colspan=\"100%\">\n <Loading />\n </TableCell>\n </TableRow>\n <!-- @slot empty -->\n <slot v-else-if=\"props.isEmpty || isDataViewEmpty\" name=\"empty\">\n <TableRow>\n <TableCell colspan=\"100%\">\n <EmptyState class=\"tw-bg-white tw-w-full\" :text=\"props.emptyStateText\" />\n </TableCell>\n </TableRow>\n </slot>\n <!-- @slot body -->\n <slot v-else name=\"body\"></slot>\n </tbody>\n </table>\n </div>\n</template>\n"],"names":["Layout","TableRadius","dataViewDensity","dataViewVariant","isDataViewLoading","isDataViewEmpty","inject","DATA_VIEW_INJECTION","moduleVariant","MODULE_INJECTION","computedRadius","computed","props","computedLayout","isStickyHeaderEnabled","_a","_b","rootStyle","provide","TABLE_INJECTION","SpacingDensity"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,QAAQ,SAFEA,IAAAA,KAAA,CAAA,CAAA,GAOAC,sBAAAA,OACVA,EAAA,OAAO,QACPA,EAAA,UAAU,WACVA,EAAA,gBAAgB,kBAHNA,IAAAA,KAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;iBCkFJ;AAAA,MACJ,SAASC;AAAA,MACT,SAASC;AAAA,MACT,WAAWC;AAAA,MACX,SAASC;AAAA,IACP,IAAAC,EAAOC,EAAoB,KAAKA,EAAoB,QAAQ,GAE1D,EAAE,SAASC,MAAkBF,EAAOG,EAAiB,KAAKA,EAAiB,QAAQ,GAEnFC,IAAiBC,EAAwB,OAEzCH,KAAA,gBAAAA,EAAe,WAAU,WAIzBL,EAAgB,UAAU,UACrB,mBAGFS,EAAM,MACd,GAEKC,IAAiBF,EAAkB,MACnCC,EAAM,eACD,WAGFA,EAAM,MACd,GAEKE,IAAwBH,EAAkB,MAAM;;AAC7C,aAAA,CAAC,GAEJI,IAAAH,EAAM,iBAAN,QAAAG,EAAoB;AAAA,QACpBC,IAAAJ,EAAM,iBAAN,gBAAAI,EAAoB,cAAa;AAAA,IAAA,CAGtC,GAEKC,IAAYN,EAAS,MAAO;;AAAA;AAAA,QAChC,WAAWG,EAAsB,SAAQC,IAAAH,EAAM,iBAAN,gBAAAG,EAAoB,YAAY;AAAA,MACzE;AAAA,KAAA;AAEF,WAAAG,EAAQC,EAAgB,KAAK;AAAA,MAC3B,SAASR,EAAS,MAAMC,EAAM,WAAWV,EAAgB,SAASkB,EAAe,WAAW;AAAA,MAC5F,uBAAuBT,EAAS,MAAMC,EAAM,qBAAqB;AAAA,MACjE,YAAYD,EAAS,MAAMC,EAAM,UAAU;AAAA,MAC3C,cAAcD,EAAS,MAAMC,EAAM,YAAY;AAAA,MAC/C,cAAcD,EAAS,MAAMC,EAAM,gBAAgB,CAACA,EAAM,aAAa,CAACA,EAAM,OAAO;AAAA,MACrF,QAAQC;AAAA,IAAA,CACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/TableRow.js CHANGED
@@ -59,7 +59,7 @@ const Q = /* @__PURE__ */ A({
59
59
  [e(t)["is-expanded"]]: a.value,
60
60
  [e(t)["root--hidden-divider"]]: o.hideExpansionDivider,
61
61
  "tw-p-gutter": e(r) === "stack",
62
- "tw-shadow-low lg:tw-shadow-none tw-mb-6 lg:tw-mb-0": e(r) === "stack" && !s.value,
62
+ "tw-shadow lg:tw-shadow-none tw-mb-6 lg:tw-mb-0": e(r) === "stack" && !s.value,
63
63
  "tw-pt-[60px]": e(R) && e(r) === "stack" && !e(u)
64
64
  }
65
65
  ]],
@@ -1 +1 @@
1
- {"version":3,"file":"TableRow.js","sources":["../src/components/TableRow/TableRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, inject, ref, useAttrs, useCssModule, useSlots, watch } from 'vue';\n\n import { t } from '../../locale';\n import Checkbox, { CheckboxProps } from '../Checkbox/Checkbox.vue';\n import ChevronToggle from '../ChevronToggle/ChevronToggle.vue';\n import Expand from '../Expand/Expand.vue';\n import { TABLE_INJECTION } from '../Table/Table.vue';\n import TableCell from '../TableCell/TableCell.vue';\n\n defineOptions({ inheritAttrs: false });\n\n export interface TableRowProps {\n hideExpansionDivider?: boolean;\n isExpanded?: boolean;\n isSelected?: boolean;\n isSelectDisabled?: boolean;\n }\n\n const props = withDefaults(defineProps<TableRowProps>(), {\n /**\n * If true, hides the divider between the parent row and expansion row\n */\n hideExpansionDivider: false,\n isExpanded: false,\n isSelected: false,\n isSelectDisabled: false,\n });\n\n const emit =\n defineEmits<{\n 'update:isSelected': [isChecked: CheckboxProps['checked']];\n 'update:isExpanded': [isExpanded: boolean];\n }>();\n\n const attrs = useAttrs();\n const classes = useCssModule();\n const slots = useSlots();\n\n const tableInjection = inject(TABLE_INJECTION.key);\n\n if (!tableInjection) {\n throw new Error('TableRow must be used within a Table component');\n }\n\n const { hasActions, hasCustomExpandToggle, isExpandable, isSelectable, layout } = tableInjection;\n\n const isRowExpanded = ref(props.isExpanded);\n const isRowExpandable = computed(() => isExpandable && !!slots.expansion);\n\n const childCellCount = computed(() => {\n let count = slots.default?.({ toggleExpand }).length ?? 0;\n\n if (isSelectable.value) {\n count += 1;\n }\n\n if (isRowExpandable.value && !hasCustomExpandToggle.value) {\n count += 1;\n }\n\n return count;\n });\n const rowId = uniqueId('table-row-');\n\n function toggleExpand(value?: boolean) {\n if (!isRowExpandable.value) {\n throw new Error('Cannot call `toggleExpand` on a non-expandable row. Provide an `expansion` slot.');\n }\n\n const isExpanded = typeof value === 'boolean' ? value : !isRowExpanded.value;\n\n isRowExpanded.value = isExpanded;\n emit('update:isExpanded', isExpanded);\n }\n\n watch(\n () => props.isExpanded,\n () => toggleExpand(props.isExpanded),\n );\n</script>\n\n<template>\n <tr\n class=\"stash-table-row\"\n :class=\"[\n classes.root,\n classes[`layout--${layout}`],\n {\n [classes['is-expandable']]: isRowExpandable,\n [classes['is-expanded']]: isRowExpanded,\n [classes['root--hidden-divider']]: hideExpansionDivider,\n 'tw-p-gutter': layout === 'stack',\n 'tw-shadow-low lg:tw-shadow-none tw-mb-6 lg:tw-mb-0': layout === 'stack' && !isRowExpandable,\n 'tw-pt-[60px]': hasActions && layout === 'stack' && !isSelectable,\n },\n ]\"\n data-test=\"stash-table-row\"\n v-bind=\"attrs\"\n >\n <TableCell\n v-if=\"isSelectable\"\n is-control\n class=\"stash-table-row__selection-cell tw-min-w-[48px]\"\n :class=\"classes['row-control-cell']\"\n >\n <Checkbox\n :class=\"classes['row-selection-checkbox']\"\n :checked=\"props.isSelected\"\n :disabled=\"props.isSelectDisabled\"\n :title=\"t('ll.select.self')\"\n @update:checked=\"emit('update:isSelected', $event)\"\n />\n </TableCell>\n <TableCell\n v-if=\"isRowExpandable && !hasCustomExpandToggle\"\n class=\"row-toggle-expansion-cell tw-px-0\"\n data-test=\"table-row-toggle-expansion-cell\"\n is-control\n :class=\"classes['row-control-cell']\"\n >\n <ChevronToggle\n :aria-controls=\"rowId\"\n :aria-label=\"isRowExpanded ? t('ll.table.collapseRow') : t('ll.table.expandRow')\"\n :direction=\"isRowExpanded ? 'up' : 'down'\"\n :is-expanded=\"isRowExpanded\"\n @click=\"toggleExpand\"\n />\n </TableCell>\n <!-- @slot default -->\n <slot :is-row-expanded=\"isRowExpanded\" :toggle-expand=\"toggleExpand\"></slot>\n </tr>\n <tr\n v-if=\"isRowExpandable\"\n class=\"stash-table-row stash-table-row-expansion\"\n :class=\"classes['row-expansion']\"\n data-test=\"stash-table-row\"\n v-bind=\"attrs\"\n >\n <Expand\n is=\"td\"\n :id=\"rowId\"\n class=\"tw-py-0 tw-px-3 tw-bg-white tw-border-none\"\n data-test=\"table-row-expansion-cell\"\n :class=\"classes['row-expansion-content']\"\n :colspan=\"childCellCount\"\n :is-expanded=\"isRowExpanded\"\n >\n <!-- @slot expansion, for expandable content -->\n <slot name=\"expansion\"></slot>\n </Expand>\n </tr>\n</template>\n\n<style module>\n .root {\n border: 0;\n }\n\n /**\n * Only takes effect when hideExpansionDivider is true, for a softer collapse transition as the bottom border re-appears\n */\n .is-expandable > td {\n border-bottom-color: var(--color-ice-200);\n transition: border-bottom-color 0.5s;\n }\n\n .root--hidden-divider.is-expanded > td {\n transition: border-bottom-color 0s;\n /**\n * Removes the grey cell background for 'control' cells at lower breakpoints, letting the white of the tr come through.\n */\n border-bottom-color: transparent;\n }\n\n .layout--scroll {\n border-radius: 0;\n box-shadow: none !important;\n margin: 0;\n }\n\n .layout--scroll:last-of-type {\n border: 0;\n }\n\n .layout--scroll:last-of-type td {\n border-bottom: none;\n }\n\n .layout--stack {\n align-items: stretch;\n background-color: var(--color-white);\n column-gap: var(--grid-gutter);\n display: grid;\n grid-template-columns: repeat(12, 1fr);\n position: relative;\n row-gap: var(--grid-gutter);\n }\n\n .layout--stack:not(.is-expanded) {\n border-radius: var(--border-radius);\n transition: border-radius 0.5s;\n }\n\n .layout--stack.is-expanded {\n border-top-left-radius: var(--border-radius);\n border-top-right-radius: var(--border-radius);\n }\n\n .row-selection-checkbox label {\n padding: 0;\n min-height: var(--ll-space-3);\n vertical-align: middle;\n }\n\n .layout--stack .row-control-cell {\n display: flex;\n align-items: center;\n min-width: 0;\n }\n\n /* On mobile, display controls on their own row, pushing other cells below */\n .row-control-cell + :not(.row-control-cell) {\n grid-column-start: 1;\n }\n\n .row-expansion-content {\n box-shadow: inset 0 -1px 0 0 var(--color-ice-200);\n }\n\n .layout--stack + .row-expansion,\n .layout--stack + .row-expansion > .row-expansion-content {\n display: block;\n }\n\n .layout--stack + .row-expansion > .row-expansion-content {\n border-top: 1px solid var(--color-ice-200);\n border-bottom-left-radius: var(--border-radius);\n border-bottom-right-radius: var(--border-radius);\n margin-bottom: var(--ll-space-3);\n }\n\n .layout--stack.root--hidden-divider + .row-expansion > .row-expansion-content {\n border-top: none;\n }\n\n /* On large screens, match the styles for layout-SCROLL */\n @media screen(lg) {\n .layout--stack {\n align-items: unset;\n background-color: unset;\n border: 0;\n border-bottom: 1px solid var(--color-ice-200);\n border-radius: 0;\n box-shadow: none;\n column-gap: unset;\n display: table-row;\n grid-template-columns: unset;\n row-gap: unset;\n }\n\n .layout--stack:last-of-type {\n border-bottom: 0;\n }\n\n .layout--stack .row-control-cell {\n display: table-cell;\n }\n\n .layout--stack + .row-expansion {\n display: table-row;\n }\n\n .layout--stack + .row-expansion > .row-expansion-content {\n border-top: unset;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n display: table-cell;\n margin-bottom: unset;\n }\n\n .row-control-cell + :not(.row-control-cell) {\n grid-column-start: unset;\n }\n }\n</style>\n"],"names":["attrs","useAttrs","classes","useCssModule","slots","useSlots","tableInjection","inject","TABLE_INJECTION","hasActions","hasCustomExpandToggle","isExpandable","isSelectable","layout","isRowExpanded","ref","props","isRowExpandable","computed","childCellCount","count","_a","toggleExpand","rowId","uniqueId","value","isExpanded","emit","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCQA,IAAQC,KACRC,IAAUC,KACVC,IAAQC,KAERC,IAAiBC,EAAOC,EAAgB,GAAG;AAEjD,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,gDAAgD;AAGlE,UAAM,EAAE,YAAAG,GAAY,uBAAAC,GAAuB,cAAAC,GAAc,cAAAC,GAAc,QAAAC,EAAW,IAAAP,GAE5EQ,IAAgBC,EAAIC,EAAM,UAAU,GACpCC,IAAkBC,EAAS,MAAMP,KAAgB,CAAC,CAACP,EAAM,SAAS,GAElEe,IAAiBD,EAAS,MAAM;;AACpC,UAAIE,MAAQC,IAAAjB,EAAM,YAAN,gBAAAiB,EAAA,KAAAjB,GAAgB,EAAE,cAAAkB,KAAgB,WAAU;AAExD,aAAIV,EAAa,UACNQ,KAAA,IAGPH,EAAgB,SAAS,CAACP,EAAsB,UACzCU,KAAA,IAGJA;AAAA,IAAA,CACR,GACKG,IAAQC,EAAS,YAAY;AAEnC,aAASF,EAAaG,GAAiB;AACjC,UAAA,CAACR,EAAgB;AACb,cAAA,IAAI,MAAM,kFAAkF;AAGpG,YAAMS,IAAa,OAAOD,KAAU,YAAYA,IAAQ,CAACX,EAAc;AAEvE,MAAAA,EAAc,QAAQY,GACtBC,EAAK,qBAAqBD,CAAU;AAAA,IACtC;AAEA,WAAAE;AAAA,MACE,MAAMZ,EAAM;AAAA,MACZ,MAAMM,EAAaN,EAAM,UAAU;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"TableRow.js","sources":["../src/components/TableRow/TableRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, inject, ref, useAttrs, useCssModule, useSlots, watch } from 'vue';\n\n import { t } from '../../locale';\n import Checkbox, { CheckboxProps } from '../Checkbox/Checkbox.vue';\n import ChevronToggle from '../ChevronToggle/ChevronToggle.vue';\n import Expand from '../Expand/Expand.vue';\n import { TABLE_INJECTION } from '../Table/Table.vue';\n import TableCell from '../TableCell/TableCell.vue';\n\n defineOptions({ inheritAttrs: false });\n\n export interface TableRowProps {\n hideExpansionDivider?: boolean;\n isExpanded?: boolean;\n isSelected?: boolean;\n isSelectDisabled?: boolean;\n }\n\n const props = withDefaults(defineProps<TableRowProps>(), {\n /**\n * If true, hides the divider between the parent row and expansion row\n */\n hideExpansionDivider: false,\n isExpanded: false,\n isSelected: false,\n isSelectDisabled: false,\n });\n\n const emit =\n defineEmits<{\n 'update:isSelected': [isChecked: CheckboxProps['checked']];\n 'update:isExpanded': [isExpanded: boolean];\n }>();\n\n const attrs = useAttrs();\n const classes = useCssModule();\n const slots = useSlots();\n\n const tableInjection = inject(TABLE_INJECTION.key);\n\n if (!tableInjection) {\n throw new Error('TableRow must be used within a Table component');\n }\n\n const { hasActions, hasCustomExpandToggle, isExpandable, isSelectable, layout } = tableInjection;\n\n const isRowExpanded = ref(props.isExpanded);\n const isRowExpandable = computed(() => isExpandable && !!slots.expansion);\n\n const childCellCount = computed(() => {\n let count = slots.default?.({ toggleExpand }).length ?? 0;\n\n if (isSelectable.value) {\n count += 1;\n }\n\n if (isRowExpandable.value && !hasCustomExpandToggle.value) {\n count += 1;\n }\n\n return count;\n });\n const rowId = uniqueId('table-row-');\n\n function toggleExpand(value?: boolean) {\n if (!isRowExpandable.value) {\n throw new Error('Cannot call `toggleExpand` on a non-expandable row. Provide an `expansion` slot.');\n }\n\n const isExpanded = typeof value === 'boolean' ? value : !isRowExpanded.value;\n\n isRowExpanded.value = isExpanded;\n emit('update:isExpanded', isExpanded);\n }\n\n watch(\n () => props.isExpanded,\n () => toggleExpand(props.isExpanded),\n );\n</script>\n\n<template>\n <tr\n class=\"stash-table-row\"\n :class=\"[\n classes.root,\n classes[`layout--${layout}`],\n {\n [classes['is-expandable']]: isRowExpandable,\n [classes['is-expanded']]: isRowExpanded,\n [classes['root--hidden-divider']]: hideExpansionDivider,\n 'tw-p-gutter': layout === 'stack',\n 'tw-shadow lg:tw-shadow-none tw-mb-6 lg:tw-mb-0': layout === 'stack' && !isRowExpandable,\n 'tw-pt-[60px]': hasActions && layout === 'stack' && !isSelectable,\n },\n ]\"\n data-test=\"stash-table-row\"\n v-bind=\"attrs\"\n >\n <TableCell\n v-if=\"isSelectable\"\n is-control\n class=\"stash-table-row__selection-cell tw-min-w-[48px]\"\n :class=\"classes['row-control-cell']\"\n >\n <Checkbox\n :class=\"classes['row-selection-checkbox']\"\n :checked=\"props.isSelected\"\n :disabled=\"props.isSelectDisabled\"\n :title=\"t('ll.select.self')\"\n @update:checked=\"emit('update:isSelected', $event)\"\n />\n </TableCell>\n <TableCell\n v-if=\"isRowExpandable && !hasCustomExpandToggle\"\n class=\"row-toggle-expansion-cell tw-px-0\"\n data-test=\"table-row-toggle-expansion-cell\"\n is-control\n :class=\"classes['row-control-cell']\"\n >\n <ChevronToggle\n :aria-controls=\"rowId\"\n :aria-label=\"isRowExpanded ? t('ll.table.collapseRow') : t('ll.table.expandRow')\"\n :direction=\"isRowExpanded ? 'up' : 'down'\"\n :is-expanded=\"isRowExpanded\"\n @click=\"toggleExpand\"\n />\n </TableCell>\n <!-- @slot default -->\n <slot :is-row-expanded=\"isRowExpanded\" :toggle-expand=\"toggleExpand\"></slot>\n </tr>\n <tr\n v-if=\"isRowExpandable\"\n class=\"stash-table-row stash-table-row-expansion\"\n :class=\"classes['row-expansion']\"\n data-test=\"stash-table-row\"\n v-bind=\"attrs\"\n >\n <Expand\n is=\"td\"\n :id=\"rowId\"\n class=\"tw-py-0 tw-px-3 tw-bg-white tw-border-none\"\n data-test=\"table-row-expansion-cell\"\n :class=\"classes['row-expansion-content']\"\n :colspan=\"childCellCount\"\n :is-expanded=\"isRowExpanded\"\n >\n <!-- @slot expansion, for expandable content -->\n <slot name=\"expansion\"></slot>\n </Expand>\n </tr>\n</template>\n\n<style module>\n .root {\n border: 0;\n }\n\n /**\n * Only takes effect when hideExpansionDivider is true, for a softer collapse transition as the bottom border re-appears\n */\n .is-expandable > td {\n border-bottom-color: var(--color-ice-200);\n transition: border-bottom-color 0.5s;\n }\n\n .root--hidden-divider.is-expanded > td {\n transition: border-bottom-color 0s;\n /**\n * Removes the grey cell background for 'control' cells at lower breakpoints, letting the white of the tr come through.\n */\n border-bottom-color: transparent;\n }\n\n .layout--scroll {\n border-radius: 0;\n box-shadow: none !important;\n margin: 0;\n }\n\n .layout--scroll:last-of-type {\n border: 0;\n }\n\n .layout--scroll:last-of-type td {\n border-bottom: none;\n }\n\n .layout--stack {\n align-items: stretch;\n background-color: var(--color-white);\n column-gap: var(--grid-gutter);\n display: grid;\n grid-template-columns: repeat(12, 1fr);\n position: relative;\n row-gap: var(--grid-gutter);\n }\n\n .layout--stack:not(.is-expanded) {\n border-radius: var(--border-radius);\n transition: border-radius 0.5s;\n }\n\n .layout--stack.is-expanded {\n border-top-left-radius: var(--border-radius);\n border-top-right-radius: var(--border-radius);\n }\n\n .row-selection-checkbox label {\n padding: 0;\n min-height: var(--ll-space-3);\n vertical-align: middle;\n }\n\n .layout--stack .row-control-cell {\n display: flex;\n align-items: center;\n min-width: 0;\n }\n\n /* On mobile, display controls on their own row, pushing other cells below */\n .row-control-cell + :not(.row-control-cell) {\n grid-column-start: 1;\n }\n\n .row-expansion-content {\n box-shadow: inset 0 -1px 0 0 var(--color-ice-200);\n }\n\n .layout--stack + .row-expansion,\n .layout--stack + .row-expansion > .row-expansion-content {\n display: block;\n }\n\n .layout--stack + .row-expansion > .row-expansion-content {\n border-top: 1px solid var(--color-ice-200);\n border-bottom-left-radius: var(--border-radius);\n border-bottom-right-radius: var(--border-radius);\n margin-bottom: var(--ll-space-3);\n }\n\n .layout--stack.root--hidden-divider + .row-expansion > .row-expansion-content {\n border-top: none;\n }\n\n /* On large screens, match the styles for layout-SCROLL */\n @media screen(lg) {\n .layout--stack {\n align-items: unset;\n background-color: unset;\n border: 0;\n border-bottom: 1px solid var(--color-ice-200);\n border-radius: 0;\n box-shadow: none;\n column-gap: unset;\n display: table-row;\n grid-template-columns: unset;\n row-gap: unset;\n }\n\n .layout--stack:last-of-type {\n border-bottom: 0;\n }\n\n .layout--stack .row-control-cell {\n display: table-cell;\n }\n\n .layout--stack + .row-expansion {\n display: table-row;\n }\n\n .layout--stack + .row-expansion > .row-expansion-content {\n border-top: unset;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n display: table-cell;\n margin-bottom: unset;\n }\n\n .row-control-cell + :not(.row-control-cell) {\n grid-column-start: unset;\n }\n }\n</style>\n"],"names":["attrs","useAttrs","classes","useCssModule","slots","useSlots","tableInjection","inject","TABLE_INJECTION","hasActions","hasCustomExpandToggle","isExpandable","isSelectable","layout","isRowExpanded","ref","props","isRowExpandable","computed","childCellCount","count","_a","toggleExpand","rowId","uniqueId","value","isExpanded","emit","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCQA,IAAQC,KACRC,IAAUC,KACVC,IAAQC,KAERC,IAAiBC,EAAOC,EAAgB,GAAG;AAEjD,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,gDAAgD;AAGlE,UAAM,EAAE,YAAAG,GAAY,uBAAAC,GAAuB,cAAAC,GAAc,cAAAC,GAAc,QAAAC,EAAW,IAAAP,GAE5EQ,IAAgBC,EAAIC,EAAM,UAAU,GACpCC,IAAkBC,EAAS,MAAMP,KAAgB,CAAC,CAACP,EAAM,SAAS,GAElEe,IAAiBD,EAAS,MAAM;;AACpC,UAAIE,MAAQC,IAAAjB,EAAM,YAAN,gBAAAiB,EAAA,KAAAjB,GAAgB,EAAE,cAAAkB,KAAgB,WAAU;AAExD,aAAIV,EAAa,UACNQ,KAAA,IAGPH,EAAgB,SAAS,CAACP,EAAsB,UACzCU,KAAA,IAGJA;AAAA,IAAA,CACR,GACKG,IAAQC,EAAS,YAAY;AAEnC,aAASF,EAAaG,GAAiB;AACjC,UAAA,CAACR,EAAgB;AACb,cAAA,IAAI,MAAM,kFAAkF;AAGpG,YAAMS,IAAa,OAAOD,KAAU,YAAYA,IAAQ,CAACX,EAAc;AAEvE,MAAAA,EAAc,QAAQY,GACtBC,EAAK,qBAAqBD,CAAU;AAAA,IACtC;AAEA,WAAAE;AAAA,MACE,MAAMZ,EAAM;AAAA,MACZ,MAAMM,EAAaN,EAAM,UAAU;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}