@leaflink/stash 48.1.0 → 48.2.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/TableRow.js +72 -56
- package/dist/TableRow.js.map +1 -1
- package/dist/TableRow.vue.d.ts +48 -0
- package/package.json +1 -1
package/dist/TableRow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as N, useAttrs as A, useCssModule as D, useSlots as M, inject as V, ref as j, computed as _, watch as P, openBlock as c, createElementBlock as
|
|
1
|
+
import { defineComponent as N, useAttrs as A, useCssModule as D, useSlots as M, inject as V, ref as j, computed as _, watch as P, openBlock as c, createElementBlock as m, Fragment as q, createElementVNode as z, mergeProps as F, unref as e, createBlock as k, normalizeClass as r, withCtx as b, createVNode as f, createCommentVNode as u, renderSlot as g } from "vue";
|
|
2
2
|
import J from "lodash-es/uniqueId";
|
|
3
|
-
import { t as
|
|
3
|
+
import { t as x } from "./locale.js";
|
|
4
4
|
import L from "./Checkbox.js";
|
|
5
5
|
import { _ as O } from "./ChevronToggle.vue_vue_type_script_setup_true_lang-1591294c.js";
|
|
6
6
|
import { _ as U } from "./Expand.vue_vue_type_script_setup_true_lang-1751f4a6.js";
|
|
@@ -11,7 +11,7 @@ import "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
|
|
|
11
11
|
import "./Illustration.vue_vue_type_script_setup_true_lang-4b8944da.js";
|
|
12
12
|
import "./EmptyState.vue_used_vue_type_style_index_0_lang.module-f5d89366.js";
|
|
13
13
|
import "./Loading.vue_used_vue_type_style_index_0_lang.module-ef5a3bc6.js";
|
|
14
|
-
import
|
|
14
|
+
import y from "./TableCell.js";
|
|
15
15
|
import { T as G, a as H } from "./Table.keys-cf93df19.js";
|
|
16
16
|
import { _ as K } from "./_plugin-vue_export-helper-dad06003.js";
|
|
17
17
|
import "lodash-es/get";
|
|
@@ -28,101 +28,117 @@ const Q = /* @__PURE__ */ N({
|
|
|
28
28
|
hideExpansionDivider: { type: Boolean, default: !1 },
|
|
29
29
|
isExpanded: { type: Boolean, default: !1 },
|
|
30
30
|
isSelected: { type: Boolean, default: !1 },
|
|
31
|
-
isSelectDisabled: { type: Boolean, default: !1 }
|
|
31
|
+
isSelectDisabled: { type: Boolean, default: !1 },
|
|
32
|
+
accentColor: { default: void 0 }
|
|
32
33
|
},
|
|
33
34
|
emits: ["update:isSelected", "update:isExpanded"],
|
|
34
|
-
setup(S, { emit:
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
35
|
+
setup(S, { emit: h }) {
|
|
36
|
+
const t = S, T = A(), a = D(), i = M(), C = V(G.key);
|
|
37
|
+
if (!C)
|
|
37
38
|
throw new Error("TableRow must be used within a Table component");
|
|
38
|
-
const { hasActions: B, hasCustomExpandToggle:
|
|
39
|
+
const { hasActions: B, hasCustomExpandToggle: v, isExpandable: R, isSelectable: w, layout: d } = C, l = j(t.isExpanded), n = _(() => R.value && !!i.expansion), $ = _(() => {
|
|
39
40
|
var s;
|
|
40
|
-
let
|
|
41
|
-
return
|
|
42
|
-
}),
|
|
43
|
-
function p(
|
|
44
|
-
if (!
|
|
41
|
+
let o = ((s = i.default) == null ? void 0 : s.call(i, { toggleExpand: p }).length) ?? 0;
|
|
42
|
+
return w.value && (o += 1), n.value && !v.value && (o += 1), o;
|
|
43
|
+
}), E = J("table-row-");
|
|
44
|
+
function p(o) {
|
|
45
|
+
if (!n.value)
|
|
45
46
|
throw new Error("Cannot call `toggleExpand` on a non-expandable row. Provide an `expansion` slot.");
|
|
46
|
-
const s = typeof
|
|
47
|
-
|
|
47
|
+
const s = typeof o == "boolean" ? o : !l.value;
|
|
48
|
+
l.value = s, h("update:isExpanded", s);
|
|
48
49
|
}
|
|
49
50
|
return P(
|
|
50
|
-
() =>
|
|
51
|
-
() => p(
|
|
52
|
-
), (
|
|
51
|
+
() => t.isExpanded,
|
|
52
|
+
() => p(t.isExpanded)
|
|
53
|
+
), (o, s) => (c(), m(q, null, [
|
|
53
54
|
z("tr", F({
|
|
54
55
|
class: ["stash-table-row", [
|
|
55
|
-
e(
|
|
56
|
-
e(
|
|
56
|
+
e(a).root,
|
|
57
|
+
e(a)[`layout--${e(d)}`],
|
|
57
58
|
{
|
|
58
|
-
[e(
|
|
59
|
-
[e(
|
|
60
|
-
[e(
|
|
59
|
+
[e(a)["is-expandable"]]: n.value,
|
|
60
|
+
[e(a)["is-expanded"]]: l.value,
|
|
61
|
+
[e(a)["root--hidden-divider"]]: o.hideExpansionDivider,
|
|
61
62
|
"tw-p-gutter": e(d) === "stack",
|
|
62
|
-
"tw-mb-6 tw-shadow lg:tw-mb-0 lg:tw-shadow-none": e(d) === "stack" && !
|
|
63
|
-
"tw-pt-[60px]": e(B) && e(d) === "stack" && !e(
|
|
63
|
+
"tw-mb-6 tw-shadow lg:tw-mb-0 lg:tw-shadow-none": e(d) === "stack" && !n.value,
|
|
64
|
+
"tw-pt-[60px]": e(B) && e(d) === "stack" && !e(w),
|
|
65
|
+
"stash-table-row--accent": t.accentColor,
|
|
66
|
+
"tw-relative": t.accentColor
|
|
64
67
|
}
|
|
65
68
|
]],
|
|
66
69
|
"data-test": "stash-table-row"
|
|
67
70
|
}, e(T)), [
|
|
68
|
-
e(
|
|
71
|
+
e(w) ? (c(), k(y, {
|
|
69
72
|
key: 0,
|
|
70
73
|
"is-control": "",
|
|
71
|
-
class:
|
|
74
|
+
class: r(["stash-table-row__selection-cell tw-min-w-[48px]", e(a)["row-control-cell"]]),
|
|
72
75
|
"data-test": "stash-table-row|selection-cell"
|
|
73
76
|
}, {
|
|
74
|
-
default:
|
|
75
|
-
|
|
76
|
-
class:
|
|
77
|
-
checked:
|
|
78
|
-
disabled:
|
|
79
|
-
title: e(
|
|
80
|
-
"onUpdate:checked": s[0] || (s[0] = (I) =>
|
|
77
|
+
default: b(() => [
|
|
78
|
+
f(L, {
|
|
79
|
+
class: r(e(a)["row-selection-checkbox"]),
|
|
80
|
+
checked: t.isSelected,
|
|
81
|
+
disabled: t.isSelectDisabled,
|
|
82
|
+
title: e(x)("ll.select.self"),
|
|
83
|
+
"onUpdate:checked": s[0] || (s[0] = (I) => h("update:isSelected", I))
|
|
81
84
|
}, null, 8, ["class", "checked", "disabled", "title"])
|
|
82
85
|
]),
|
|
83
86
|
_: 1
|
|
84
|
-
}, 8, ["class"])) :
|
|
85
|
-
|
|
87
|
+
}, 8, ["class"])) : u("", !0),
|
|
88
|
+
n.value && !e(v) ? (c(), k(y, {
|
|
86
89
|
key: 1,
|
|
87
|
-
class:
|
|
90
|
+
class: r(["stash-table-row__toggle-expansion-cell tw-px-0", e(a)["row-control-cell"]]),
|
|
88
91
|
"data-test": "stash-table-row|custom-expansion-cell",
|
|
89
92
|
"is-control": ""
|
|
90
93
|
}, {
|
|
91
|
-
default:
|
|
92
|
-
|
|
93
|
-
"aria-controls": e(
|
|
94
|
-
"aria-label":
|
|
95
|
-
direction:
|
|
96
|
-
"is-expanded":
|
|
94
|
+
default: b(() => [
|
|
95
|
+
f(O, {
|
|
96
|
+
"aria-controls": e(E),
|
|
97
|
+
"aria-label": l.value ? e(x)("ll.table.collapseRow") : e(x)("ll.table.expandRow"),
|
|
98
|
+
direction: l.value ? "up" : "down",
|
|
99
|
+
"is-expanded": l.value,
|
|
97
100
|
onClick: p
|
|
98
101
|
}, null, 8, ["aria-controls", "aria-label", "direction", "is-expanded"])
|
|
99
102
|
]),
|
|
100
103
|
_: 1
|
|
101
|
-
}, 8, ["class"])) :
|
|
102
|
-
|
|
103
|
-
isRowExpanded:
|
|
104
|
+
}, 8, ["class"])) : u("", !0),
|
|
105
|
+
g(o.$slots, "default", {
|
|
106
|
+
isRowExpanded: l.value,
|
|
104
107
|
toggleExpand: p
|
|
105
|
-
})
|
|
108
|
+
}),
|
|
109
|
+
t.accentColor ? (c(), m("div", {
|
|
110
|
+
key: 2,
|
|
111
|
+
"data-test": "stash-table-row|accent",
|
|
112
|
+
class: r({
|
|
113
|
+
"tw-absolute": t.accentColor,
|
|
114
|
+
[`tw-bg-${t.accentColor}`]: t.accentColor,
|
|
115
|
+
"tw-block": t.accentColor,
|
|
116
|
+
"tw-h-full": t.accentColor,
|
|
117
|
+
"tw-w-1": t.accentColor,
|
|
118
|
+
"tw-top-0": t.accentColor,
|
|
119
|
+
"tw-left-0": t.accentColor
|
|
120
|
+
})
|
|
121
|
+
}, null, 2)) : u("", !0)
|
|
106
122
|
], 16),
|
|
107
|
-
|
|
123
|
+
n.value ? (c(), m("tr", {
|
|
108
124
|
key: 0,
|
|
109
|
-
class:
|
|
125
|
+
class: r(["stash-table-row stash-table-row--expandable", e(a)["row-expansion"]]),
|
|
110
126
|
"data-test": "stash-table-row|expansion-row"
|
|
111
127
|
}, [
|
|
112
|
-
|
|
128
|
+
f(U, {
|
|
113
129
|
is: "td",
|
|
114
|
-
id: e(
|
|
115
|
-
class:
|
|
130
|
+
id: e(E),
|
|
131
|
+
class: r(["tw-border-none tw-bg-white tw-px-3 tw-py-0", e(a)["row-expansion-content"]]),
|
|
116
132
|
"data-test": "stash-table-row|expansion-cell",
|
|
117
133
|
colspan: $.value,
|
|
118
|
-
"is-expanded":
|
|
134
|
+
"is-expanded": l.value
|
|
119
135
|
}, {
|
|
120
|
-
default:
|
|
121
|
-
|
|
136
|
+
default: b(() => [
|
|
137
|
+
g(o.$slots, "expansion")
|
|
122
138
|
]),
|
|
123
139
|
_: 3
|
|
124
140
|
}, 8, ["id", "class", "colspan", "is-expanded"])
|
|
125
|
-
], 2)) :
|
|
141
|
+
], 2)) : u("", !0)
|
|
126
142
|
], 64));
|
|
127
143
|
}
|
|
128
144
|
}), W = {
|
package/dist/TableRow.js.map
CHANGED
|
@@ -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.value && !!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-mb-6 tw-shadow lg:tw-mb-0 lg:tw-shadow-none': 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 data-test=\"stash-table-row|selection-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=\"stash-table-row__toggle-expansion-cell tw-px-0\"\n data-test=\"stash-table-row|custom-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--expandable\"\n :class=\"classes['row-expansion']\"\n data-test=\"stash-table-row|expansion-row\"\n >\n <Expand\n is=\"td\"\n :id=\"rowId\"\n class=\"tw-border-none tw-bg-white tw-px-3 tw-py-0\"\n data-test=\"stash-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: theme('borderRadius.DEFAULT');\n transition: border-radius 0.5s;\n }\n\n .layout--stack.is-expanded {\n border-top-left-radius: theme('borderRadius.DEFAULT');\n border-top-right-radius: theme('borderRadius.DEFAULT');\n }\n\n .row-selection-checkbox label {\n padding: 0;\n min-height: theme('spacing.6');\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: theme('borderRadius.DEFAULT');\n border-bottom-right-radius: theme('borderRadius.DEFAULT');\n margin-bottom: theme('spacing.6');\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,EAAa,SAAS,CAAC,CAACP,EAAM,SAAS,GAExEe,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 { StashCommonColor } from '../../../types/colors';\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 * The accent color for the TableRow.\n */\n accentColor?: StashCommonColor;\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 accentColor: undefined,\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.value && !!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-mb-6 tw-shadow lg:tw-mb-0 lg:tw-shadow-none': layout === 'stack' && !isRowExpandable,\n 'tw-pt-[60px]': hasActions && layout === 'stack' && !isSelectable,\n 'stash-table-row--accent': props.accentColor,\n 'tw-relative': props.accentColor,\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 data-test=\"stash-table-row|selection-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=\"stash-table-row__toggle-expansion-cell tw-px-0\"\n data-test=\"stash-table-row|custom-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 <!-- Displays a 4px accent on the left of the table row -->\n <div\n v-if=\"props.accentColor\"\n data-test=\"stash-table-row|accent\"\n :class=\"{\n 'tw-absolute': props.accentColor,\n [`tw-bg-${props.accentColor}`]: props.accentColor,\n 'tw-block': props.accentColor,\n 'tw-h-full': props.accentColor,\n 'tw-w-1': props.accentColor,\n 'tw-top-0': props.accentColor,\n 'tw-left-0': props.accentColor,\n }\"\n ></div>\n </tr>\n <tr\n v-if=\"isRowExpandable\"\n class=\"stash-table-row stash-table-row--expandable\"\n :class=\"classes['row-expansion']\"\n data-test=\"stash-table-row|expansion-row\"\n >\n <Expand\n is=\"td\"\n :id=\"rowId\"\n class=\"tw-border-none tw-bg-white tw-px-3 tw-py-0\"\n data-test=\"stash-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: theme('borderRadius.DEFAULT');\n transition: border-radius 0.5s;\n }\n\n .layout--stack.is-expanded {\n border-top-left-radius: theme('borderRadius.DEFAULT');\n border-top-right-radius: theme('borderRadius.DEFAULT');\n }\n\n .row-selection-checkbox label {\n padding: 0;\n min-height: theme('spacing.6');\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: theme('borderRadius.DEFAULT');\n border-bottom-right-radius: theme('borderRadius.DEFAULT');\n margin-bottom: theme('spacing.6');\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0CQA,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,EAAa,SAAS,CAAC,CAACP,EAAM,SAAS,GAExEe,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/TableRow.vue.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaul
|
|
|
41
41
|
isExpanded: boolean;
|
|
42
42
|
isSelected: boolean;
|
|
43
43
|
isSelectDisabled: boolean;
|
|
44
|
+
accentColor: undefined;
|
|
44
45
|
}>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
45
46
|
"update:isSelected": (isChecked: boolean | (string | number)[]) => void;
|
|
46
47
|
"update:isExpanded": (isExpanded: boolean) => void;
|
|
@@ -52,12 +53,14 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaul
|
|
|
52
53
|
isExpanded: boolean;
|
|
53
54
|
isSelected: boolean;
|
|
54
55
|
isSelectDisabled: boolean;
|
|
56
|
+
accentColor: undefined;
|
|
55
57
|
}>>> & {
|
|
56
58
|
"onUpdate:isSelected"?: ((isChecked: boolean | (string | number)[]) => any) | undefined;
|
|
57
59
|
"onUpdate:isExpanded"?: ((isExpanded: boolean) => any) | undefined;
|
|
58
60
|
}, {
|
|
59
61
|
isSelected: boolean;
|
|
60
62
|
isExpanded: boolean;
|
|
63
|
+
accentColor: "ice-700" | "purple-700" | "purple-500" | "purple-100" | "royal-700" | "royal-500" | "royal-100" | "blue-700" | "blue-500" | "blue-100" | "teal-700" | "teal-500" | "teal-100" | "green-700" | "green-500" | "green-100" | "seafoam-700" | "seafoam-500" | "seafoam-100" | "yellow-700" | "yellow-500" | "yellow-100" | "orange-700" | "orange-500" | "orange-100" | "red-700" | "red-500" | "red-100" | "ice-500" | "ice-200" | "ice-100" | "white" | "black";
|
|
61
64
|
hideExpansionDivider: boolean;
|
|
62
65
|
isSelectDisabled: boolean;
|
|
63
66
|
}, {}>, {
|
|
@@ -69,11 +72,56 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaul
|
|
|
69
72
|
}>;
|
|
70
73
|
export default _default;
|
|
71
74
|
|
|
75
|
+
declare type StashCommonColor = `${StashCommonColors}`;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A limited list of stash brand colors, only including their 100, 500, and 700 shades.
|
|
79
|
+
*/
|
|
80
|
+
declare enum StashCommonColors {
|
|
81
|
+
Purple700 = "purple-700",
|
|
82
|
+
Purple500 = "purple-500",
|
|
83
|
+
Purple100 = "purple-100",
|
|
84
|
+
Royal700 = "royal-700",
|
|
85
|
+
Royal500 = "royal-500",
|
|
86
|
+
Royal100 = "royal-100",
|
|
87
|
+
Blue700 = "blue-700",
|
|
88
|
+
Blue500 = "blue-500",
|
|
89
|
+
Blue100 = "blue-100",
|
|
90
|
+
Teal700 = "teal-700",
|
|
91
|
+
Teal500 = "teal-500",
|
|
92
|
+
Teal100 = "teal-100",
|
|
93
|
+
Green700 = "green-700",
|
|
94
|
+
Green500 = "green-500",
|
|
95
|
+
Green100 = "green-100",
|
|
96
|
+
Seafoam700 = "seafoam-700",
|
|
97
|
+
Seafoam500 = "seafoam-500",
|
|
98
|
+
Seafoam100 = "seafoam-100",
|
|
99
|
+
Yellow700 = "yellow-700",
|
|
100
|
+
Yellow500 = "yellow-500",
|
|
101
|
+
Yellow100 = "yellow-100",
|
|
102
|
+
Orange700 = "orange-700",
|
|
103
|
+
Orange500 = "orange-500",
|
|
104
|
+
Orange100 = "orange-100",
|
|
105
|
+
Red700 = "red-700",
|
|
106
|
+
Red500 = "red-500",
|
|
107
|
+
Red100 = "red-100",
|
|
108
|
+
Ice700 = "ice-700",
|
|
109
|
+
Ice500 = "ice-500",
|
|
110
|
+
Ice200 = "ice-200",// This is the one outlier, but it's used purposefully in a few places
|
|
111
|
+
Ice100 = "ice-100",
|
|
112
|
+
White = "white",
|
|
113
|
+
Black = "black"
|
|
114
|
+
}
|
|
115
|
+
|
|
72
116
|
export declare interface TableRowProps {
|
|
73
117
|
hideExpansionDivider?: boolean;
|
|
74
118
|
isExpanded?: boolean;
|
|
75
119
|
isSelected?: boolean;
|
|
76
120
|
isSelectDisabled?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* The accent color for the TableRow.
|
|
123
|
+
*/
|
|
124
|
+
accentColor?: StashCommonColor;
|
|
77
125
|
}
|
|
78
126
|
|
|
79
127
|
declare function toggleExpand(value?: boolean): void;
|