@treeui/vue 0.19.1 → 0.20.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/components/TAppShell.cjs.map +1 -1
- package/dist/components/TAppShell.js.map +1 -1
- package/dist/components/TAppShell.vue.d.ts +4 -0
- package/dist/components/TAppShell.vue.d.ts.map +1 -1
- package/dist/components/TAppShell.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/TAppShell.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/TAppShell.vue_vue_type_script_setup_true_lang.js +51 -44
- package/dist/components/TAppShell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/TButton.cjs.map +1 -1
- package/dist/components/TButton.js.map +1 -1
- package/dist/components/TButton.vue.d.ts.map +1 -1
- package/dist/components/TButton.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/TButton.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/TButton.vue_vue_type_script_setup_true_lang.js +36 -32
- package/dist/components/TButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/TCard.cjs.map +1 -1
- package/dist/components/TCard.js.map +1 -1
- package/dist/components/TCard.vue.d.ts +8 -0
- package/dist/components/TCard.vue.d.ts.map +1 -1
- package/dist/components/TCard.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/TCard.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/TCard.vue_vue_type_script_setup_true_lang.js +7 -2
- package/dist/components/TCard.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/TLink.cjs.map +1 -1
- package/dist/components/TLink.js.map +1 -1
- package/dist/components/TLink.vue.d.ts +8 -0
- package/dist/components/TLink.vue.d.ts.map +1 -1
- package/dist/components/TLink.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/TLink.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/TLink.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/TLink.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/TPopover.cjs.map +1 -1
- package/dist/components/TPopover.js.map +1 -1
- package/dist/components/TPopover.vue.d.ts +4 -1
- package/dist/components/TPopover.vue.d.ts.map +1 -1
- package/dist/components/TPopover.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/TPopover.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/TPopover.vue_vue_type_script_setup_true_lang.js +3 -1
- package/dist/components/TPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/TStack.cjs.map +1 -1
- package/dist/components/TStack.js.map +1 -1
- package/dist/components/TStack.vue.d.ts +9 -0
- package/dist/components/TStack.vue.d.ts.map +1 -1
- package/dist/components/TStack.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/TStack.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/TStack.vue_vue_type_script_setup_true_lang.js +3 -1
- package/dist/components/TStack.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/TSteps.vue.d.ts +1 -1
- package/dist/components/TSteps.vue.d.ts.map +1 -1
- package/dist/components/TTable.cjs.map +1 -1
- package/dist/components/TTable.js.map +1 -1
- package/dist/components/TTable.vue.d.ts +16 -0
- package/dist/components/TTable.vue.d.ts.map +1 -1
- package/dist/components/TTable.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/TTable.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/TTable.vue_vue_type_script_setup_true_lang.js +29 -9
- package/dist/components/TTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/TText.cjs.map +1 -1
- package/dist/components/TText.js.map +1 -1
- package/dist/components/TText.vue.d.ts +9 -0
- package/dist/components/TText.vue.d.ts.map +1 -1
- package/dist/components/TText.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/TText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/TText.vue_vue_type_script_setup_true_lang.js +2 -0
- package/dist/components/TText.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/index.d.ts +4 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TStack.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/components/TStack.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\n\ndefineOptions({\n inheritAttrs: false,\n});\n\nconst _treeStackDirections = ['vertical', 'horizontal'] as const;\n\nexport type TStackDirection = (typeof _treeStackDirections)[number];\n\nconst props = withDefaults(\n defineProps<{\n as?: string;\n direction?: TStackDirection;\n gap?: string;\n align?: string;\n justify?: string;\n wrap?: boolean;\n reverse?: boolean;\n /** Expand to fill available space along the parent's main axis. */\n grow?: boolean;\n }>(),\n {\n as: 'div',\n direction: 'vertical',\n gap: 'var(--tree-space-4)',\n align: 'stretch',\n justify: 'flex-start',\n wrap: false,\n reverse: false,\n grow: false,\n },\n);\n\nconst attrs = useAttrs();\n\nconst rootClasses = computed(() => [\n 't-stack',\n `t-stack--${props.direction}`,\n {\n 'is-wrapping': props.wrap,\n 'is-reversed': props.reverse,\n 'is-grow': props.grow,\n },\n attrs.class,\n]);\n\nconst rootStyle = computed(() => [\n {\n gap: props.gap,\n alignItems: props.align,\n justifyContent: props.justify,\n },\n attrs.style,\n]);\n\nconst rootAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <component\n :is=\"as\"\n v-bind=\"rootAttrs\"\n :class=\"rootClasses\"\n :style=\"rootStyle\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TStack.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/components/TStack.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\n\ndefineOptions({\n inheritAttrs: false,\n});\n\nconst _treeStackDirections = ['vertical', 'horizontal'] as const;\nconst _treeStackFills = ['viewport', 'parent'] as const;\n\nexport type TStackDirection = (typeof _treeStackDirections)[number];\nexport type TStackFill = (typeof _treeStackFills)[number];\n\nconst props = withDefaults(\n defineProps<{\n as?: string;\n direction?: TStackDirection;\n gap?: string;\n align?: string;\n justify?: string;\n wrap?: boolean;\n reverse?: boolean;\n /** Expand to fill available space along the parent's main axis. */\n grow?: boolean;\n /**\n * Give the stack a minimum block size so a centered child fills the screen\n * or its parent: `viewport` → `100dvh`, `parent` → `100%`. Compose with\n * `align`/`justify=\"center\"` for a centered loading or empty state.\n */\n fill?: TStackFill;\n }>(),\n {\n as: 'div',\n direction: 'vertical',\n gap: 'var(--tree-space-4)',\n align: 'stretch',\n justify: 'flex-start',\n wrap: false,\n reverse: false,\n grow: false,\n fill: undefined,\n },\n);\n\nconst attrs = useAttrs();\n\nconst rootClasses = computed(() => [\n 't-stack',\n `t-stack--${props.direction}`,\n props.fill ? `t-stack--fill-${props.fill}` : null,\n {\n 'is-wrapping': props.wrap,\n 'is-reversed': props.reverse,\n 'is-grow': props.grow,\n },\n attrs.class,\n]);\n\nconst rootStyle = computed(() => [\n {\n gap: props.gap,\n alignItems: props.align,\n justifyContent: props.justify,\n },\n attrs.style,\n]);\n\nconst rootAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <component\n :is=\"as\"\n v-bind=\"rootAttrs\"\n :class=\"rootClasses\"\n :style=\"rootStyle\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":"wWAaA,IAAM,EAAQ,EA+BR,GAAA,EAAA,EAAA,SAAA,CAAiB,EAEjB,GAAA,EAAA,EAAA,SAAA,KAA6B,CACjC,UACA,YAAY,EAAM,YAClB,EAAM,KAAO,iBAAiB,EAAM,OAAS,KAC7C,CACE,cAAe,EAAM,KACrB,cAAe,EAAM,QACrB,UAAW,EAAM,IACnB,EACA,EAAM,KACR,CAAC,EAEK,GAAA,EAAA,EAAA,SAAA,KAA2B,CAC/B,CACE,IAAK,EAAM,IACX,WAAY,EAAM,MAClB,eAAgB,EAAM,OACxB,EACA,EAAM,KACR,CAAC,EAEK,GAAA,EAAA,EAAA,SAAA,KAA2B,CAC/B,GAAM,CAAE,MAAO,EAAQ,MAAO,EAAQ,GAAG,GAAS,EAClD,OAAO,CACT,CAAC,kFAKQ,EAAA,EAAE,GAAA,EAAA,EAAA,WAAA,CACC,EAKE,MALO,CAChB,MAAO,EAAA,MACP,MAAO,EAAA,mCAEA,EAAA,EAAA,EAAA,WAAA,CAAA,EAAA,OAAA,SAAA,CAAA,CAAA"}
|
|
@@ -20,12 +20,14 @@ var l = /*@__PURE__*/ n({
|
|
|
20
20
|
grow: {
|
|
21
21
|
type: Boolean,
|
|
22
22
|
default: !1
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
|
+
fill: { default: void 0 }
|
|
24
25
|
},
|
|
25
26
|
setup(n) {
|
|
26
27
|
let l = n, u = s(), d = e(() => [
|
|
27
28
|
"t-stack",
|
|
28
29
|
`t-stack--${l.direction}`,
|
|
30
|
+
l.fill ? `t-stack--fill-${l.fill}` : null,
|
|
29
31
|
{
|
|
30
32
|
"is-wrapping": l.wrap,
|
|
31
33
|
"is-reversed": l.reverse,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TStack.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/TStack.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\n\ndefineOptions({\n inheritAttrs: false,\n});\n\nconst _treeStackDirections = ['vertical', 'horizontal'] as const;\n\nexport type TStackDirection = (typeof _treeStackDirections)[number];\n\nconst props = withDefaults(\n defineProps<{\n as?: string;\n direction?: TStackDirection;\n gap?: string;\n align?: string;\n justify?: string;\n wrap?: boolean;\n reverse?: boolean;\n /** Expand to fill available space along the parent's main axis. */\n grow?: boolean;\n }>(),\n {\n as: 'div',\n direction: 'vertical',\n gap: 'var(--tree-space-4)',\n align: 'stretch',\n justify: 'flex-start',\n wrap: false,\n reverse: false,\n grow: false,\n },\n);\n\nconst attrs = useAttrs();\n\nconst rootClasses = computed(() => [\n 't-stack',\n `t-stack--${props.direction}`,\n {\n 'is-wrapping': props.wrap,\n 'is-reversed': props.reverse,\n 'is-grow': props.grow,\n },\n attrs.class,\n]);\n\nconst rootStyle = computed(() => [\n {\n gap: props.gap,\n alignItems: props.align,\n justifyContent: props.justify,\n },\n attrs.style,\n]);\n\nconst rootAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <component\n :is=\"as\"\n v-bind=\"rootAttrs\"\n :class=\"rootClasses\"\n :style=\"rootStyle\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TStack.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/TStack.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\n\ndefineOptions({\n inheritAttrs: false,\n});\n\nconst _treeStackDirections = ['vertical', 'horizontal'] as const;\nconst _treeStackFills = ['viewport', 'parent'] as const;\n\nexport type TStackDirection = (typeof _treeStackDirections)[number];\nexport type TStackFill = (typeof _treeStackFills)[number];\n\nconst props = withDefaults(\n defineProps<{\n as?: string;\n direction?: TStackDirection;\n gap?: string;\n align?: string;\n justify?: string;\n wrap?: boolean;\n reverse?: boolean;\n /** Expand to fill available space along the parent's main axis. */\n grow?: boolean;\n /**\n * Give the stack a minimum block size so a centered child fills the screen\n * or its parent: `viewport` → `100dvh`, `parent` → `100%`. Compose with\n * `align`/`justify=\"center\"` for a centered loading or empty state.\n */\n fill?: TStackFill;\n }>(),\n {\n as: 'div',\n direction: 'vertical',\n gap: 'var(--tree-space-4)',\n align: 'stretch',\n justify: 'flex-start',\n wrap: false,\n reverse: false,\n grow: false,\n fill: undefined,\n },\n);\n\nconst attrs = useAttrs();\n\nconst rootClasses = computed(() => [\n 't-stack',\n `t-stack--${props.direction}`,\n props.fill ? `t-stack--fill-${props.fill}` : null,\n {\n 'is-wrapping': props.wrap,\n 'is-reversed': props.reverse,\n 'is-grow': props.grow,\n },\n attrs.class,\n]);\n\nconst rootStyle = computed(() => [\n {\n gap: props.gap,\n alignItems: props.align,\n justifyContent: props.justify,\n },\n attrs.style,\n]);\n\nconst rootAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <component\n :is=\"as\"\n v-bind=\"rootAttrs\"\n :class=\"rootClasses\"\n :style=\"rootStyle\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAaA,IAAM,IAAQ,GA+BR,IAAQ,EAAS,GAEjB,IAAc,QAAe;GACjC;GACA,YAAY,EAAM;GAClB,EAAM,OAAO,iBAAiB,EAAM,SAAS;GAC7C;IACE,eAAe,EAAM;IACrB,eAAe,EAAM;IACrB,WAAW,EAAM;GACnB;GACA,EAAM;EACR,CAAC,GAEK,IAAY,QAAe,CAC/B;GACE,KAAK,EAAM;GACX,YAAY,EAAM;GAClB,gBAAgB,EAAM;EACxB,GACA,EAAM,KACR,CAAC,GAEK,IAAY,QAAe;GAC/B,IAAM,EAAE,OAAO,GAAQ,OAAO,GAAQ,GAAG,MAAS;GAClD,OAAO;EACT,CAAC;yBAIC,EAOY,EANL,EAAA,EAAE,GADT,EAEU,EAKE,OALO;GAChB,OAAO,EAAA;GACP,OAAO,EAAA;;oBAEA,CAAR,EAAQ,EAAA,QAAA,SAAA,CAAA,CAAA"}
|
|
@@ -48,9 +48,9 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
|
|
|
48
48
|
modelValue: string;
|
|
49
49
|
defaultValue: string;
|
|
50
50
|
size: TSize;
|
|
51
|
+
interactive: boolean;
|
|
51
52
|
items: TStepItem[];
|
|
52
53
|
orientation: TStepOrientation;
|
|
53
|
-
interactive: boolean;
|
|
54
54
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
55
55
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
56
56
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TSteps.vue.d.ts","sourceRoot":"","sources":["../../src/components/TSteps.vue"],"names":[],"mappings":"AAiMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAMhD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,iBAAiB,uDAAwD,CAAC;AAChF,QAAA,MAAM,qBAAqB,qCAAsC,CAAC;AAElE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7D,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAItE,KAAK,WAAW,GAAG;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAwGJ,iBAAS,cAAc;WA0FT,OAAO,IAA6B;;eA/KzC,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,SAAS,CAAC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AE,gBAAgB,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAwGJ,iBAAS,cAAc;WA0FT,OAAO,IAA6B;;eA/KzC,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,SAAS,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,WAAW,CAAC;YACpB,OAAO,EAAE,OAAO,CAAC;SAClB,KAAK,OAAO;;eALN,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,SAAS,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,WAAW,CAAC;YACpB,OAAO,EAAE,OAAO,CAAC;SAClB,KAAK,OAAO;;;;EA+Kd;AAiBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;gBA/NJ,MAAM;kBACJ,MAAM;UAEd,KAAK;iBAEE,OAAO;WAHb,SAAS,EAAE;iBAEL,gBAAgB;6EAmOhC,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TTable.cjs","names":[],"sources":["../../src/components/TTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue';\nimport type { TIconName } from '@treeui/icons';\nimport type { TSize } from '../types/contracts';\nimport TIcon from './TIcon.vue';\n\n// The scroll container is the root element, but the accessible name and any\n// aria-*/id belong on the <table> itself, so attrs are split rather than\n// inherited onto the wrapper.\ndefineOptions({\n inheritAttrs: false,\n});\n\nexport type TTableColumn = {\n key: string;\n label: string;\n sortable?: boolean;\n align?: 'left' | 'center' | 'right';\n width?: string;\n};\n\nexport type TTableSortDirection = 'asc' | 'desc' | 'none';\n\nexport type TTableSortState = {\n key: string;\n direction: TTableSortDirection;\n};\n\nconst props = withDefaults(\n defineProps<{\n columns: TTableColumn[];\n rows: Record<string, unknown>[];\n size?: TSize;\n sortBy?: TTableSortState;\n /**\n * Visible `<caption>` naming the table. For a name without visible text,\n * pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.\n */\n caption?: string;\n }>(),\n {\n size: 'md',\n sortBy: undefined,\n caption: undefined,\n },\n);\n\nconst emit = defineEmits<{\n (e: 'sort', state: TTableSortState): void;\n}>();\n\ndefineSlots<{\n [key: `cell-${string}`]: (props: { row: Record<string, unknown>; value: unknown }) => void;\n [key: `header-${string}`]: (props: { column: TTableColumn }) => void;\n empty: () => void;\n}>();\n\nconst internalSort = ref<TTableSortState | undefined>(undefined);\n\nconst currentSort = computed(() => props.sortBy ?? internalSort.value);\n\nconst classes = computed(() => [\n 't-table',\n `t-table--${props.size}`,\n]);\n\nconst sortedRows = computed(() => {\n const sort = currentSort.value;\n if (!sort || sort.direction === 'none') return props.rows;\n\n return [...props.rows].sort((a, b) => {\n const aVal = a[sort.key];\n const bVal = b[sort.key];\n\n if (aVal == null && bVal == null) return 0;\n if (aVal == null) return 1;\n if (bVal == null) return -1;\n\n const cmp =\n typeof aVal === 'number' && typeof bVal === 'number'\n ? aVal - bVal\n : String(aVal).localeCompare(String(bVal));\n\n return sort.direction === 'desc' ? -cmp : cmp;\n });\n});\n\nfunction handleSort(column: TTableColumn) {\n if (!column.sortable) return;\n\n const cur = currentSort.value;\n let direction: TTableSortDirection = 'asc';\n\n if (cur?.key === column.key) {\n if (cur.direction === 'asc') direction = 'desc';\n else if (cur.direction === 'desc') direction = 'none';\n else direction = 'asc';\n }\n\n const state: TTableSortState = { key: column.key, direction };\n internalSort.value = state;\n emit('sort', state);\n}\n\nfunction sortAriaSort(column: TTableColumn): 'none' | 'ascending' | 'descending' | undefined {\n if (!column.sortable) return undefined;\n const cur = currentSort.value;\n if (cur?.key !== column.key || cur.direction === 'none') return 'none';\n return cur.direction === 'asc' ? 'ascending' : 'descending';\n}\n\nfunction handleHeaderKeydown(event: KeyboardEvent, column: TTableColumn) {\n if (column.sortable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n handleSort(column);\n }\n}\n\nfunction isSortedBy(column: TTableColumn): boolean {\n const cur = currentSort.value;\n return cur?.key === column.key && cur.direction !== 'none';\n}\n\nfunction sortIconName(column: TTableColumn): TIconName {\n const cur = currentSort.value;\n if (!isSortedBy(column)) return 'chevrons-up-down';\n return cur?.direction === 'asc' ? 'chevron-up' : 'chevron-down';\n}\n\nconst attrs = useAttrs();\n\n// class/style stay on the scroll wrapper (the root); everything else —\n// aria-label, aria-labelledby, id, data-* — is forwarded to the <table>.\nconst tableAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <div\n class=\"t-table-wrapper\"\n :class=\"attrs.class\"\n :style=\"attrs.style\"\n >\n <table\n v-bind=\"tableAttrs\"\n :class=\"classes\"\n >\n <caption\n v-if=\"caption\"\n class=\"t-table__caption\"\n >\n {{ caption }}\n </caption>\n <thead class=\"t-table__head\">\n <tr class=\"t-table__row\">\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__header\"\n :class=\"[\n column.sortable ? 't-table__header--sortable' : '',\n column.align ? `t-table__header--${column.align}` : '',\n ]\"\n :style=\"column.width ? { width: column.width } : undefined\"\n :aria-sort=\"sortAriaSort(column)\"\n :tabindex=\"column.sortable ? 0 : undefined\"\n scope=\"col\"\n @click=\"handleSort(column)\"\n @keydown=\"handleHeaderKeydown($event, column)\"\n >\n <slot\n :name=\"`header-${column.key}`\"\n :column=\"column\"\n >\n <span class=\"t-table__header-content\">\n {{ column.label }}\n <span\n v-if=\"column.sortable\"\n class=\"t-table__sort-icon\"\n :class=\"{ 'is-inactive': !isSortedBy(column) }\"\n aria-hidden=\"true\"\n >\n <TIcon\n :name=\"sortIconName(column)\"\n :size=\"14\"\n />\n </span>\n </span>\n </slot>\n </th>\n </tr>\n </thead>\n <tbody class=\"t-table__body\">\n <tr\n v-if=\"sortedRows.length === 0\"\n class=\"t-table__row t-table__row--empty\"\n >\n <td\n :colspan=\"columns.length\"\n class=\"t-table__cell t-table__cell--empty\"\n >\n <slot name=\"empty\">\n No data available.\n </slot>\n </td>\n </tr>\n <tr\n v-for=\"(row, index) in sortedRows\"\n :key=\"index\"\n class=\"t-table__row\"\n >\n <td\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__cell\"\n :class=\"column.align ? `t-table__cell--${column.align}` : ''\"\n >\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"row\"\n :value=\"row[column.key]\"\n >\n {{ row[column.key] ?? '' }}\n </slot>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"TTable.cjs","names":[],"sources":["../../src/components/TTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue';\nimport type { TIconName } from '@treeui/icons';\nimport type { TSize } from '../types/contracts';\nimport TIcon from './TIcon.vue';\n\n// The scroll container is the root element, but the accessible name and any\n// aria-*/id belong on the <table> itself, so attrs are split rather than\n// inherited onto the wrapper.\ndefineOptions({\n inheritAttrs: false,\n});\n\nexport type TTableColumn = {\n key: string;\n label: string;\n sortable?: boolean;\n align?: 'left' | 'center' | 'right';\n width?: string;\n};\n\nexport type TTableSortDirection = 'asc' | 'desc' | 'none';\n\nexport type TTableSortState = {\n key: string;\n direction: TTableSortDirection;\n};\n\nexport type TTableRowState = 'default' | 'muted';\n\nconst props = withDefaults(\n defineProps<{\n columns: TTableColumn[];\n rows: Record<string, unknown>[];\n size?: TSize;\n sortBy?: TTableSortState;\n /**\n * Visible `<caption>` naming the table. For a name without visible text,\n * pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.\n */\n caption?: string;\n /**\n * Stable identity per row. A key (or a function of the row) so rows keep\n * their identity across sorting — otherwise Vue keys by array index and\n * `rowState` styling follows the position, not the data.\n */\n rowKey?: string | ((row: Record<string, unknown>, index: number) => string | number);\n /**\n * Semantic per-row state. `muted` recesses a row (e.g. a resource that no\n * longer exists). It is applied by data, not position, so it survives\n * sorting. Dimming is not an accessible signal on its own — pair it with a\n * status cell or visually hidden text conveying the same meaning.\n */\n rowState?: (row: Record<string, unknown>, index: number) => TTableRowState;\n }>(),\n {\n size: 'md',\n sortBy: undefined,\n caption: undefined,\n rowKey: undefined,\n rowState: undefined,\n },\n);\n\nconst emit = defineEmits<{\n (e: 'sort', state: TTableSortState): void;\n}>();\n\ndefineSlots<{\n [key: `cell-${string}`]: (props: { row: Record<string, unknown>; value: unknown }) => void;\n [key: `header-${string}`]: (props: { column: TTableColumn }) => void;\n empty: () => void;\n}>();\n\nconst internalSort = ref<TTableSortState | undefined>(undefined);\n\nconst currentSort = computed(() => props.sortBy ?? internalSort.value);\n\nconst classes = computed(() => [\n 't-table',\n `t-table--${props.size}`,\n]);\n\nconst sortedRows = computed(() => {\n const sort = currentSort.value;\n if (!sort || sort.direction === 'none') return props.rows;\n\n return [...props.rows].sort((a, b) => {\n const aVal = a[sort.key];\n const bVal = b[sort.key];\n\n if (aVal == null && bVal == null) return 0;\n if (aVal == null) return 1;\n if (bVal == null) return -1;\n\n const cmp =\n typeof aVal === 'number' && typeof bVal === 'number'\n ? aVal - bVal\n : String(aVal).localeCompare(String(bVal));\n\n return sort.direction === 'desc' ? -cmp : cmp;\n });\n});\n\nfunction handleSort(column: TTableColumn) {\n if (!column.sortable) return;\n\n const cur = currentSort.value;\n let direction: TTableSortDirection = 'asc';\n\n if (cur?.key === column.key) {\n if (cur.direction === 'asc') direction = 'desc';\n else if (cur.direction === 'desc') direction = 'none';\n else direction = 'asc';\n }\n\n const state: TTableSortState = { key: column.key, direction };\n internalSort.value = state;\n emit('sort', state);\n}\n\nfunction sortAriaSort(column: TTableColumn): 'none' | 'ascending' | 'descending' | undefined {\n if (!column.sortable) return undefined;\n const cur = currentSort.value;\n if (cur?.key !== column.key || cur.direction === 'none') return 'none';\n return cur.direction === 'asc' ? 'ascending' : 'descending';\n}\n\nfunction handleHeaderKeydown(event: KeyboardEvent, column: TTableColumn) {\n if (column.sortable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n handleSort(column);\n }\n}\n\nfunction isSortedBy(column: TTableColumn): boolean {\n const cur = currentSort.value;\n return cur?.key === column.key && cur.direction !== 'none';\n}\n\nfunction sortIconName(column: TTableColumn): TIconName {\n const cur = currentSort.value;\n if (!isSortedBy(column)) return 'chevrons-up-down';\n return cur?.direction === 'asc' ? 'chevron-up' : 'chevron-down';\n}\n\nfunction resolveRowKey(row: Record<string, unknown>, index: number): string | number {\n if (typeof props.rowKey === 'function') return props.rowKey(row, index);\n if (typeof props.rowKey === 'string') {\n const value = row[props.rowKey];\n if (typeof value === 'string' || typeof value === 'number') return value;\n }\n return index;\n}\n\nfunction rowStateClass(row: Record<string, unknown>, index: number): string | null {\n const state = props.rowState?.(row, index);\n return state && state !== 'default' ? `t-table__row--${state}` : null;\n}\n\nconst attrs = useAttrs();\n\n// class/style stay on the scroll wrapper (the root); everything else —\n// aria-label, aria-labelledby, id, data-* — is forwarded to the <table>.\nconst tableAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <div\n class=\"t-table-wrapper\"\n :class=\"attrs.class\"\n :style=\"attrs.style\"\n >\n <table\n v-bind=\"tableAttrs\"\n :class=\"classes\"\n >\n <caption\n v-if=\"caption\"\n class=\"t-table__caption\"\n >\n {{ caption }}\n </caption>\n <thead class=\"t-table__head\">\n <tr class=\"t-table__row\">\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__header\"\n :class=\"[\n column.sortable ? 't-table__header--sortable' : '',\n column.align ? `t-table__header--${column.align}` : '',\n ]\"\n :style=\"column.width ? { width: column.width } : undefined\"\n :aria-sort=\"sortAriaSort(column)\"\n :tabindex=\"column.sortable ? 0 : undefined\"\n scope=\"col\"\n @click=\"handleSort(column)\"\n @keydown=\"handleHeaderKeydown($event, column)\"\n >\n <slot\n :name=\"`header-${column.key}`\"\n :column=\"column\"\n >\n <span class=\"t-table__header-content\">\n {{ column.label }}\n <span\n v-if=\"column.sortable\"\n class=\"t-table__sort-icon\"\n :class=\"{ 'is-inactive': !isSortedBy(column) }\"\n aria-hidden=\"true\"\n >\n <TIcon\n :name=\"sortIconName(column)\"\n :size=\"14\"\n />\n </span>\n </span>\n </slot>\n </th>\n </tr>\n </thead>\n <tbody class=\"t-table__body\">\n <tr\n v-if=\"sortedRows.length === 0\"\n class=\"t-table__row t-table__row--empty\"\n >\n <td\n :colspan=\"columns.length\"\n class=\"t-table__cell t-table__cell--empty\"\n >\n <slot name=\"empty\">\n No data available.\n </slot>\n </td>\n </tr>\n <tr\n v-for=\"(row, index) in sortedRows\"\n :key=\"resolveRowKey(row, index)\"\n class=\"t-table__row\"\n :class=\"rowStateClass(row, index)\"\n >\n <td\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__cell\"\n :class=\"column.align ? `t-table__cell--${column.align}` : ''\"\n >\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"row\"\n :value=\"row[column.key]\"\n >\n {{ row[column.key] ?? '' }}\n </slot>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TTable.js","names":[],"sources":["../../src/components/TTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue';\nimport type { TIconName } from '@treeui/icons';\nimport type { TSize } from '../types/contracts';\nimport TIcon from './TIcon.vue';\n\n// The scroll container is the root element, but the accessible name and any\n// aria-*/id belong on the <table> itself, so attrs are split rather than\n// inherited onto the wrapper.\ndefineOptions({\n inheritAttrs: false,\n});\n\nexport type TTableColumn = {\n key: string;\n label: string;\n sortable?: boolean;\n align?: 'left' | 'center' | 'right';\n width?: string;\n};\n\nexport type TTableSortDirection = 'asc' | 'desc' | 'none';\n\nexport type TTableSortState = {\n key: string;\n direction: TTableSortDirection;\n};\n\nconst props = withDefaults(\n defineProps<{\n columns: TTableColumn[];\n rows: Record<string, unknown>[];\n size?: TSize;\n sortBy?: TTableSortState;\n /**\n * Visible `<caption>` naming the table. For a name without visible text,\n * pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.\n */\n caption?: string;\n }>(),\n {\n size: 'md',\n sortBy: undefined,\n caption: undefined,\n },\n);\n\nconst emit = defineEmits<{\n (e: 'sort', state: TTableSortState): void;\n}>();\n\ndefineSlots<{\n [key: `cell-${string}`]: (props: { row: Record<string, unknown>; value: unknown }) => void;\n [key: `header-${string}`]: (props: { column: TTableColumn }) => void;\n empty: () => void;\n}>();\n\nconst internalSort = ref<TTableSortState | undefined>(undefined);\n\nconst currentSort = computed(() => props.sortBy ?? internalSort.value);\n\nconst classes = computed(() => [\n 't-table',\n `t-table--${props.size}`,\n]);\n\nconst sortedRows = computed(() => {\n const sort = currentSort.value;\n if (!sort || sort.direction === 'none') return props.rows;\n\n return [...props.rows].sort((a, b) => {\n const aVal = a[sort.key];\n const bVal = b[sort.key];\n\n if (aVal == null && bVal == null) return 0;\n if (aVal == null) return 1;\n if (bVal == null) return -1;\n\n const cmp =\n typeof aVal === 'number' && typeof bVal === 'number'\n ? aVal - bVal\n : String(aVal).localeCompare(String(bVal));\n\n return sort.direction === 'desc' ? -cmp : cmp;\n });\n});\n\nfunction handleSort(column: TTableColumn) {\n if (!column.sortable) return;\n\n const cur = currentSort.value;\n let direction: TTableSortDirection = 'asc';\n\n if (cur?.key === column.key) {\n if (cur.direction === 'asc') direction = 'desc';\n else if (cur.direction === 'desc') direction = 'none';\n else direction = 'asc';\n }\n\n const state: TTableSortState = { key: column.key, direction };\n internalSort.value = state;\n emit('sort', state);\n}\n\nfunction sortAriaSort(column: TTableColumn): 'none' | 'ascending' | 'descending' | undefined {\n if (!column.sortable) return undefined;\n const cur = currentSort.value;\n if (cur?.key !== column.key || cur.direction === 'none') return 'none';\n return cur.direction === 'asc' ? 'ascending' : 'descending';\n}\n\nfunction handleHeaderKeydown(event: KeyboardEvent, column: TTableColumn) {\n if (column.sortable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n handleSort(column);\n }\n}\n\nfunction isSortedBy(column: TTableColumn): boolean {\n const cur = currentSort.value;\n return cur?.key === column.key && cur.direction !== 'none';\n}\n\nfunction sortIconName(column: TTableColumn): TIconName {\n const cur = currentSort.value;\n if (!isSortedBy(column)) return 'chevrons-up-down';\n return cur?.direction === 'asc' ? 'chevron-up' : 'chevron-down';\n}\n\nconst attrs = useAttrs();\n\n// class/style stay on the scroll wrapper (the root); everything else —\n// aria-label, aria-labelledby, id, data-* — is forwarded to the <table>.\nconst tableAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <div\n class=\"t-table-wrapper\"\n :class=\"attrs.class\"\n :style=\"attrs.style\"\n >\n <table\n v-bind=\"tableAttrs\"\n :class=\"classes\"\n >\n <caption\n v-if=\"caption\"\n class=\"t-table__caption\"\n >\n {{ caption }}\n </caption>\n <thead class=\"t-table__head\">\n <tr class=\"t-table__row\">\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__header\"\n :class=\"[\n column.sortable ? 't-table__header--sortable' : '',\n column.align ? `t-table__header--${column.align}` : '',\n ]\"\n :style=\"column.width ? { width: column.width } : undefined\"\n :aria-sort=\"sortAriaSort(column)\"\n :tabindex=\"column.sortable ? 0 : undefined\"\n scope=\"col\"\n @click=\"handleSort(column)\"\n @keydown=\"handleHeaderKeydown($event, column)\"\n >\n <slot\n :name=\"`header-${column.key}`\"\n :column=\"column\"\n >\n <span class=\"t-table__header-content\">\n {{ column.label }}\n <span\n v-if=\"column.sortable\"\n class=\"t-table__sort-icon\"\n :class=\"{ 'is-inactive': !isSortedBy(column) }\"\n aria-hidden=\"true\"\n >\n <TIcon\n :name=\"sortIconName(column)\"\n :size=\"14\"\n />\n </span>\n </span>\n </slot>\n </th>\n </tr>\n </thead>\n <tbody class=\"t-table__body\">\n <tr\n v-if=\"sortedRows.length === 0\"\n class=\"t-table__row t-table__row--empty\"\n >\n <td\n :colspan=\"columns.length\"\n class=\"t-table__cell t-table__cell--empty\"\n >\n <slot name=\"empty\">\n No data available.\n </slot>\n </td>\n </tr>\n <tr\n v-for=\"(row, index) in sortedRows\"\n :key=\"index\"\n class=\"t-table__row\"\n >\n <td\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__cell\"\n :class=\"column.align ? `t-table__cell--${column.align}` : ''\"\n >\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"row\"\n :value=\"row[column.key]\"\n >\n {{ row[column.key] ?? '' }}\n </slot>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"TTable.js","names":[],"sources":["../../src/components/TTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue';\nimport type { TIconName } from '@treeui/icons';\nimport type { TSize } from '../types/contracts';\nimport TIcon from './TIcon.vue';\n\n// The scroll container is the root element, but the accessible name and any\n// aria-*/id belong on the <table> itself, so attrs are split rather than\n// inherited onto the wrapper.\ndefineOptions({\n inheritAttrs: false,\n});\n\nexport type TTableColumn = {\n key: string;\n label: string;\n sortable?: boolean;\n align?: 'left' | 'center' | 'right';\n width?: string;\n};\n\nexport type TTableSortDirection = 'asc' | 'desc' | 'none';\n\nexport type TTableSortState = {\n key: string;\n direction: TTableSortDirection;\n};\n\nexport type TTableRowState = 'default' | 'muted';\n\nconst props = withDefaults(\n defineProps<{\n columns: TTableColumn[];\n rows: Record<string, unknown>[];\n size?: TSize;\n sortBy?: TTableSortState;\n /**\n * Visible `<caption>` naming the table. For a name without visible text,\n * pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.\n */\n caption?: string;\n /**\n * Stable identity per row. A key (or a function of the row) so rows keep\n * their identity across sorting — otherwise Vue keys by array index and\n * `rowState` styling follows the position, not the data.\n */\n rowKey?: string | ((row: Record<string, unknown>, index: number) => string | number);\n /**\n * Semantic per-row state. `muted` recesses a row (e.g. a resource that no\n * longer exists). It is applied by data, not position, so it survives\n * sorting. Dimming is not an accessible signal on its own — pair it with a\n * status cell or visually hidden text conveying the same meaning.\n */\n rowState?: (row: Record<string, unknown>, index: number) => TTableRowState;\n }>(),\n {\n size: 'md',\n sortBy: undefined,\n caption: undefined,\n rowKey: undefined,\n rowState: undefined,\n },\n);\n\nconst emit = defineEmits<{\n (e: 'sort', state: TTableSortState): void;\n}>();\n\ndefineSlots<{\n [key: `cell-${string}`]: (props: { row: Record<string, unknown>; value: unknown }) => void;\n [key: `header-${string}`]: (props: { column: TTableColumn }) => void;\n empty: () => void;\n}>();\n\nconst internalSort = ref<TTableSortState | undefined>(undefined);\n\nconst currentSort = computed(() => props.sortBy ?? internalSort.value);\n\nconst classes = computed(() => [\n 't-table',\n `t-table--${props.size}`,\n]);\n\nconst sortedRows = computed(() => {\n const sort = currentSort.value;\n if (!sort || sort.direction === 'none') return props.rows;\n\n return [...props.rows].sort((a, b) => {\n const aVal = a[sort.key];\n const bVal = b[sort.key];\n\n if (aVal == null && bVal == null) return 0;\n if (aVal == null) return 1;\n if (bVal == null) return -1;\n\n const cmp =\n typeof aVal === 'number' && typeof bVal === 'number'\n ? aVal - bVal\n : String(aVal).localeCompare(String(bVal));\n\n return sort.direction === 'desc' ? -cmp : cmp;\n });\n});\n\nfunction handleSort(column: TTableColumn) {\n if (!column.sortable) return;\n\n const cur = currentSort.value;\n let direction: TTableSortDirection = 'asc';\n\n if (cur?.key === column.key) {\n if (cur.direction === 'asc') direction = 'desc';\n else if (cur.direction === 'desc') direction = 'none';\n else direction = 'asc';\n }\n\n const state: TTableSortState = { key: column.key, direction };\n internalSort.value = state;\n emit('sort', state);\n}\n\nfunction sortAriaSort(column: TTableColumn): 'none' | 'ascending' | 'descending' | undefined {\n if (!column.sortable) return undefined;\n const cur = currentSort.value;\n if (cur?.key !== column.key || cur.direction === 'none') return 'none';\n return cur.direction === 'asc' ? 'ascending' : 'descending';\n}\n\nfunction handleHeaderKeydown(event: KeyboardEvent, column: TTableColumn) {\n if (column.sortable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n handleSort(column);\n }\n}\n\nfunction isSortedBy(column: TTableColumn): boolean {\n const cur = currentSort.value;\n return cur?.key === column.key && cur.direction !== 'none';\n}\n\nfunction sortIconName(column: TTableColumn): TIconName {\n const cur = currentSort.value;\n if (!isSortedBy(column)) return 'chevrons-up-down';\n return cur?.direction === 'asc' ? 'chevron-up' : 'chevron-down';\n}\n\nfunction resolveRowKey(row: Record<string, unknown>, index: number): string | number {\n if (typeof props.rowKey === 'function') return props.rowKey(row, index);\n if (typeof props.rowKey === 'string') {\n const value = row[props.rowKey];\n if (typeof value === 'string' || typeof value === 'number') return value;\n }\n return index;\n}\n\nfunction rowStateClass(row: Record<string, unknown>, index: number): string | null {\n const state = props.rowState?.(row, index);\n return state && state !== 'default' ? `t-table__row--${state}` : null;\n}\n\nconst attrs = useAttrs();\n\n// class/style stay on the scroll wrapper (the root); everything else —\n// aria-label, aria-labelledby, id, data-* — is forwarded to the <table>.\nconst tableAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <div\n class=\"t-table-wrapper\"\n :class=\"attrs.class\"\n :style=\"attrs.style\"\n >\n <table\n v-bind=\"tableAttrs\"\n :class=\"classes\"\n >\n <caption\n v-if=\"caption\"\n class=\"t-table__caption\"\n >\n {{ caption }}\n </caption>\n <thead class=\"t-table__head\">\n <tr class=\"t-table__row\">\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__header\"\n :class=\"[\n column.sortable ? 't-table__header--sortable' : '',\n column.align ? `t-table__header--${column.align}` : '',\n ]\"\n :style=\"column.width ? { width: column.width } : undefined\"\n :aria-sort=\"sortAriaSort(column)\"\n :tabindex=\"column.sortable ? 0 : undefined\"\n scope=\"col\"\n @click=\"handleSort(column)\"\n @keydown=\"handleHeaderKeydown($event, column)\"\n >\n <slot\n :name=\"`header-${column.key}`\"\n :column=\"column\"\n >\n <span class=\"t-table__header-content\">\n {{ column.label }}\n <span\n v-if=\"column.sortable\"\n class=\"t-table__sort-icon\"\n :class=\"{ 'is-inactive': !isSortedBy(column) }\"\n aria-hidden=\"true\"\n >\n <TIcon\n :name=\"sortIconName(column)\"\n :size=\"14\"\n />\n </span>\n </span>\n </slot>\n </th>\n </tr>\n </thead>\n <tbody class=\"t-table__body\">\n <tr\n v-if=\"sortedRows.length === 0\"\n class=\"t-table__row t-table__row--empty\"\n >\n <td\n :colspan=\"columns.length\"\n class=\"t-table__cell t-table__cell--empty\"\n >\n <slot name=\"empty\">\n No data available.\n </slot>\n </td>\n </tr>\n <tr\n v-for=\"(row, index) in sortedRows\"\n :key=\"resolveRowKey(row, index)\"\n class=\"t-table__row\"\n :class=\"rowStateClass(row, index)\"\n >\n <td\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__cell\"\n :class=\"column.align ? `t-table__cell--${column.align}` : ''\"\n >\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"row\"\n :value=\"row[column.key]\"\n >\n {{ row[column.key] ?? '' }}\n </slot>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -11,6 +11,7 @@ export type TTableSortState = {
|
|
|
11
11
|
key: string;
|
|
12
12
|
direction: TTableSortDirection;
|
|
13
13
|
};
|
|
14
|
+
export type TTableRowState = 'default' | 'muted';
|
|
14
15
|
type __VLS_Props = {
|
|
15
16
|
columns: TTableColumn[];
|
|
16
17
|
rows: Record<string, unknown>[];
|
|
@@ -21,6 +22,19 @@ type __VLS_Props = {
|
|
|
21
22
|
* pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.
|
|
22
23
|
*/
|
|
23
24
|
caption?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Stable identity per row. A key (or a function of the row) so rows keep
|
|
27
|
+
* their identity across sorting — otherwise Vue keys by array index and
|
|
28
|
+
* `rowState` styling follows the position, not the data.
|
|
29
|
+
*/
|
|
30
|
+
rowKey?: string | ((row: Record<string, unknown>, index: number) => string | number);
|
|
31
|
+
/**
|
|
32
|
+
* Semantic per-row state. `muted` recesses a row (e.g. a resource that no
|
|
33
|
+
* longer exists). It is applied by data, not position, so it survives
|
|
34
|
+
* sorting. Dimming is not an accessible signal on its own — pair it with a
|
|
35
|
+
* status cell or visually hidden text conveying the same meaning.
|
|
36
|
+
*/
|
|
37
|
+
rowState?: (row: Record<string, unknown>, index: number) => TTableRowState;
|
|
24
38
|
};
|
|
25
39
|
declare function __VLS_template(): {
|
|
26
40
|
attrs: Partial<{}>;
|
|
@@ -55,6 +69,8 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
|
|
|
55
69
|
size: TSize;
|
|
56
70
|
caption: string;
|
|
57
71
|
sortBy: TTableSortState;
|
|
72
|
+
rowKey: string | ((row: Record<string, unknown>, index: number) => string | number);
|
|
73
|
+
rowState: (row: Record<string, unknown>, index: number) => TTableRowState;
|
|
58
74
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
59
75
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
60
76
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TTable.vue.d.ts","sourceRoot":"","sources":["../../src/components/TTable.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TTable.vue.d.ts","sourceRoot":"","sources":["../../src/components/TTable.vue"],"names":[],"mappings":"AA4QA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CA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AA;SAAE,KAAK,IAAI;eAC7D,MAAM,IAAI;;yCAFgB;YAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAAC,KAAK,EAAE,OAAO,CAAA;SAAE,KAAK,IAAI;2CACvD;YAAE,MAAM,EAAE,YAAY,CAAA;SAAE,KAAK,IAAI;eAC7D,MAAM,IAAI;;;;EAmOlB;AAsBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;UAlSV,KAAK;aAMF,MAAM;YALP,eAAe;YAWf,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC;cAOzE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,cAAc;6EAuR5E,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./TIcon.cjs");let t=require("vue");var n={key:0,class:`t-table__caption`},r={class:`t-table__head`},i={class:`t-table__row`},a=[`aria-sort`,`tabindex`,`onClick`,`onKeydown`],o={class:`t-table__header-content`},s={class:`t-table__body`},c={key:0,class:`t-table__row t-table__row--empty`},l=[`colspan`],u=(0,t.defineComponent)({inheritAttrs:!1,__name:`TTable`,props:{columns:{},rows:{},size:{default:`md`},sortBy:{default:void 0},caption:{default:void 0}},emits:[`sort`],setup(u,{emit:d}){let f=u,p=d,m=(0,t.ref)(void 0),h=(0,t.computed)(()=>f.sortBy??m.value),g=(0,t.computed)(()=>[`t-table`,`t-table--${f.size}`]),_=(0,t.computed)(()=>{let e=h.value;return!e||e.direction===`none`?f.rows:[...f.rows].sort((t,n)=>{let r=t[e.key],i=n[e.key];if(r==null&&i==null)return 0;if(r==null)return 1;if(i==null)return-1;let a=typeof r==`number`&&typeof i==`number`?r-i:String(r).localeCompare(String(i));return e.direction===`desc`?-a:a})});function v(e){if(!e.sortable)return;let t=h.value,n=`asc`;t?.key===e.key&&(n=t.direction===`asc`?`desc`:t.direction===`desc`?`none`:`asc`);let r={key:e.key,direction:n};m.value=r,p(`sort`,r)}function y(e){if(!e.sortable)return;let t=h.value;return t?.key!==e.key||t.direction===`none`?`none`:t.direction===`asc`?`ascending`:`descending`}function b(e,t){t.sortable&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v(t))}function x(e){let t=h.value;return t?.key===e.key&&t.direction!==`none`}function S(e){let t=h.value;return x(e)?t?.direction===`asc`?`chevron-up`:`chevron-down`:`chevrons-up-down`}let
|
|
1
|
+
const e=require("./TIcon.cjs");let t=require("vue");var n={key:0,class:`t-table__caption`},r={class:`t-table__head`},i={class:`t-table__row`},a=[`aria-sort`,`tabindex`,`onClick`,`onKeydown`],o={class:`t-table__header-content`},s={class:`t-table__body`},c={key:0,class:`t-table__row t-table__row--empty`},l=[`colspan`],u=(0,t.defineComponent)({inheritAttrs:!1,__name:`TTable`,props:{columns:{},rows:{},size:{default:`md`},sortBy:{default:void 0},caption:{default:void 0},rowKey:{type:[String,Function],default:void 0},rowState:{type:Function,default:void 0}},emits:[`sort`],setup(u,{emit:d}){let f=u,p=d,m=(0,t.ref)(void 0),h=(0,t.computed)(()=>f.sortBy??m.value),g=(0,t.computed)(()=>[`t-table`,`t-table--${f.size}`]),_=(0,t.computed)(()=>{let e=h.value;return!e||e.direction===`none`?f.rows:[...f.rows].sort((t,n)=>{let r=t[e.key],i=n[e.key];if(r==null&&i==null)return 0;if(r==null)return 1;if(i==null)return-1;let a=typeof r==`number`&&typeof i==`number`?r-i:String(r).localeCompare(String(i));return e.direction===`desc`?-a:a})});function v(e){if(!e.sortable)return;let t=h.value,n=`asc`;t?.key===e.key&&(n=t.direction===`asc`?`desc`:t.direction===`desc`?`none`:`asc`);let r={key:e.key,direction:n};m.value=r,p(`sort`,r)}function y(e){if(!e.sortable)return;let t=h.value;return t?.key!==e.key||t.direction===`none`?`none`:t.direction===`asc`?`ascending`:`descending`}function b(e,t){t.sortable&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v(t))}function x(e){let t=h.value;return t?.key===e.key&&t.direction!==`none`}function S(e){let t=h.value;return x(e)?t?.direction===`asc`?`chevron-up`:`chevron-down`:`chevrons-up-down`}function C(e,t){if(typeof f.rowKey==`function`)return f.rowKey(e,t);if(typeof f.rowKey==`string`){let t=e[f.rowKey];if(typeof t==`string`||typeof t==`number`)return t}return t}function w(e,t){let n=f.rowState?.(e,t);return n&&n!=="default"?`t-table__row--${n}`:null}let T=(0,t.useAttrs)(),E=(0,t.computed)(()=>{let{class:e,style:t,...n}=T;return n});return(d,f)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)([`t-table-wrapper`,(0,t.unref)(T).class]),style:(0,t.normalizeStyle)((0,t.unref)(T).style)},[(0,t.createElementVNode)(`table`,(0,t.mergeProps)(E.value,{class:g.value}),[u.caption?((0,t.openBlock)(),(0,t.createElementBlock)(`caption`,n,(0,t.toDisplayString)(u.caption),1)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`thead`,r,[(0,t.createElementVNode)(`tr`,i,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(u.columns,n=>((0,t.openBlock)(),(0,t.createElementBlock)(`th`,{key:n.key,class:(0,t.normalizeClass)([`t-table__header`,[n.sortable?`t-table__header--sortable`:``,n.align?`t-table__header--${n.align}`:``]]),style:(0,t.normalizeStyle)(n.width?{width:n.width}:void 0),"aria-sort":y(n),tabindex:n.sortable?0:void 0,scope:`col`,onClick:e=>v(n),onKeydown:e=>b(e,n)},[(0,t.renderSlot)(d.$slots,`header-${n.key}`,{column:n},()=>[(0,t.createElementVNode)(`span`,o,[(0,t.createTextVNode)((0,t.toDisplayString)(n.label)+` `,1),n.sortable?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:0,class:(0,t.normalizeClass)([`t-table__sort-icon`,{"is-inactive":!x(n)}]),"aria-hidden":`true`},[(0,t.createVNode)(e.default,{name:S(n),size:14},null,8,[`name`])],2)):(0,t.createCommentVNode)(``,!0)])])],46,a))),128))])]),(0,t.createElementVNode)(`tbody`,s,[_.value.length===0?((0,t.openBlock)(),(0,t.createElementBlock)(`tr`,c,[(0,t.createElementVNode)(`td`,{colspan:u.columns.length,class:`t-table__cell t-table__cell--empty`},[(0,t.renderSlot)(d.$slots,`empty`,{},()=>[f[0]||=(0,t.createTextVNode)(` No data available. `,-1)])],8,l)])):(0,t.createCommentVNode)(``,!0),((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(_.value,(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`tr`,{key:C(e,n),class:(0,t.normalizeClass)([`t-table__row`,w(e,n)])},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(u.columns,n=>((0,t.openBlock)(),(0,t.createElementBlock)(`td`,{key:n.key,class:(0,t.normalizeClass)([`t-table__cell`,n.align?`t-table__cell--${n.align}`:``])},[(0,t.renderSlot)(d.$slots,`cell-${n.key}`,{row:e,value:e[n.key]},()=>[(0,t.createTextVNode)((0,t.toDisplayString)(e[n.key]??``),1)])],2))),128))],2))),128))])],16)],6))}});exports.default=u;
|
|
2
2
|
//# sourceMappingURL=TTable.vue_vue_type_script_setup_true_lang.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TTable.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/components/TTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue';\nimport type { TIconName } from '@treeui/icons';\nimport type { TSize } from '../types/contracts';\nimport TIcon from './TIcon.vue';\n\n// The scroll container is the root element, but the accessible name and any\n// aria-*/id belong on the <table> itself, so attrs are split rather than\n// inherited onto the wrapper.\ndefineOptions({\n inheritAttrs: false,\n});\n\nexport type TTableColumn = {\n key: string;\n label: string;\n sortable?: boolean;\n align?: 'left' | 'center' | 'right';\n width?: string;\n};\n\nexport type TTableSortDirection = 'asc' | 'desc' | 'none';\n\nexport type TTableSortState = {\n key: string;\n direction: TTableSortDirection;\n};\n\nconst props = withDefaults(\n defineProps<{\n columns: TTableColumn[];\n rows: Record<string, unknown>[];\n size?: TSize;\n sortBy?: TTableSortState;\n /**\n * Visible `<caption>` naming the table. For a name without visible text,\n * pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.\n */\n caption?: string;\n }>(),\n {\n size: 'md',\n sortBy: undefined,\n caption: undefined,\n },\n);\n\nconst emit = defineEmits<{\n (e: 'sort', state: TTableSortState): void;\n}>();\n\ndefineSlots<{\n [key: `cell-${string}`]: (props: { row: Record<string, unknown>; value: unknown }) => void;\n [key: `header-${string}`]: (props: { column: TTableColumn }) => void;\n empty: () => void;\n}>();\n\nconst internalSort = ref<TTableSortState | undefined>(undefined);\n\nconst currentSort = computed(() => props.sortBy ?? internalSort.value);\n\nconst classes = computed(() => [\n 't-table',\n `t-table--${props.size}`,\n]);\n\nconst sortedRows = computed(() => {\n const sort = currentSort.value;\n if (!sort || sort.direction === 'none') return props.rows;\n\n return [...props.rows].sort((a, b) => {\n const aVal = a[sort.key];\n const bVal = b[sort.key];\n\n if (aVal == null && bVal == null) return 0;\n if (aVal == null) return 1;\n if (bVal == null) return -1;\n\n const cmp =\n typeof aVal === 'number' && typeof bVal === 'number'\n ? aVal - bVal\n : String(aVal).localeCompare(String(bVal));\n\n return sort.direction === 'desc' ? -cmp : cmp;\n });\n});\n\nfunction handleSort(column: TTableColumn) {\n if (!column.sortable) return;\n\n const cur = currentSort.value;\n let direction: TTableSortDirection = 'asc';\n\n if (cur?.key === column.key) {\n if (cur.direction === 'asc') direction = 'desc';\n else if (cur.direction === 'desc') direction = 'none';\n else direction = 'asc';\n }\n\n const state: TTableSortState = { key: column.key, direction };\n internalSort.value = state;\n emit('sort', state);\n}\n\nfunction sortAriaSort(column: TTableColumn): 'none' | 'ascending' | 'descending' | undefined {\n if (!column.sortable) return undefined;\n const cur = currentSort.value;\n if (cur?.key !== column.key || cur.direction === 'none') return 'none';\n return cur.direction === 'asc' ? 'ascending' : 'descending';\n}\n\nfunction handleHeaderKeydown(event: KeyboardEvent, column: TTableColumn) {\n if (column.sortable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n handleSort(column);\n }\n}\n\nfunction isSortedBy(column: TTableColumn): boolean {\n const cur = currentSort.value;\n return cur?.key === column.key && cur.direction !== 'none';\n}\n\nfunction sortIconName(column: TTableColumn): TIconName {\n const cur = currentSort.value;\n if (!isSortedBy(column)) return 'chevrons-up-down';\n return cur?.direction === 'asc' ? 'chevron-up' : 'chevron-down';\n}\n\nconst attrs = useAttrs();\n\n// class/style stay on the scroll wrapper (the root); everything else —\n// aria-label, aria-labelledby, id, data-* — is forwarded to the <table>.\nconst tableAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <div\n class=\"t-table-wrapper\"\n :class=\"attrs.class\"\n :style=\"attrs.style\"\n >\n <table\n v-bind=\"tableAttrs\"\n :class=\"classes\"\n >\n <caption\n v-if=\"caption\"\n class=\"t-table__caption\"\n >\n {{ caption }}\n </caption>\n <thead class=\"t-table__head\">\n <tr class=\"t-table__row\">\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__header\"\n :class=\"[\n column.sortable ? 't-table__header--sortable' : '',\n column.align ? `t-table__header--${column.align}` : '',\n ]\"\n :style=\"column.width ? { width: column.width } : undefined\"\n :aria-sort=\"sortAriaSort(column)\"\n :tabindex=\"column.sortable ? 0 : undefined\"\n scope=\"col\"\n @click=\"handleSort(column)\"\n @keydown=\"handleHeaderKeydown($event, column)\"\n >\n <slot\n :name=\"`header-${column.key}`\"\n :column=\"column\"\n >\n <span class=\"t-table__header-content\">\n {{ column.label }}\n <span\n v-if=\"column.sortable\"\n class=\"t-table__sort-icon\"\n :class=\"{ 'is-inactive': !isSortedBy(column) }\"\n aria-hidden=\"true\"\n >\n <TIcon\n :name=\"sortIconName(column)\"\n :size=\"14\"\n />\n </span>\n </span>\n </slot>\n </th>\n </tr>\n </thead>\n <tbody class=\"t-table__body\">\n <tr\n v-if=\"sortedRows.length === 0\"\n class=\"t-table__row t-table__row--empty\"\n >\n <td\n :colspan=\"columns.length\"\n class=\"t-table__cell t-table__cell--empty\"\n >\n <slot name=\"empty\">\n No data available.\n </slot>\n </td>\n </tr>\n <tr\n v-for=\"(row, index) in sortedRows\"\n :key=\"index\"\n class=\"t-table__row\"\n >\n <td\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__cell\"\n :class=\"column.align ? `t-table__cell--${column.align}` : ''\"\n >\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"row\"\n :value=\"row[column.key]\"\n >\n {{ row[column.key] ?? '' }}\n </slot>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n"],"mappings":"wfA4BA,IAAM,EAAQ,EAmBR,EAAO,EAUP,GAAA,EAAA,EAAA,IAAA,CAAgD,IAAA,EAAS,EAEzD,GAAA,EAAA,EAAA,SAAA,KAA6B,EAAM,QAAU,EAAa,KAAK,EAE/D,GAAA,EAAA,EAAA,SAAA,KAAyB,CAC7B,UACA,YAAY,EAAM,MACpB,CAAC,EAEK,GAAA,EAAA,EAAA,SAAA,KAA4B,CAChC,IAAM,EAAO,EAAY,MAGzB,MAFI,CAAC,GAAQ,EAAK,YAAc,OAAe,EAAM,KAE9C,CAAC,GAAG,EAAM,IAAI,CAAC,CAAC,MAA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,EAAI,EAAO,MAAG,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"TTable.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/components/TTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue';\nimport type { TIconName } from '@treeui/icons';\nimport type { TSize } from '../types/contracts';\nimport TIcon from './TIcon.vue';\n\n// The scroll container is the root element, but the accessible name and any\n// aria-*/id belong on the <table> itself, so attrs are split rather than\n// inherited onto the wrapper.\ndefineOptions({\n inheritAttrs: false,\n});\n\nexport type TTableColumn = {\n key: string;\n label: string;\n sortable?: boolean;\n align?: 'left' | 'center' | 'right';\n width?: string;\n};\n\nexport type TTableSortDirection = 'asc' | 'desc' | 'none';\n\nexport type TTableSortState = {\n key: string;\n direction: TTableSortDirection;\n};\n\nexport type TTableRowState = 'default' | 'muted';\n\nconst props = withDefaults(\n defineProps<{\n columns: TTableColumn[];\n rows: Record<string, unknown>[];\n size?: TSize;\n sortBy?: TTableSortState;\n /**\n * Visible `<caption>` naming the table. For a name without visible text,\n * pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.\n */\n caption?: string;\n /**\n * Stable identity per row. A key (or a function of the row) so rows keep\n * their identity across sorting — otherwise Vue keys by array index and\n * `rowState` styling follows the position, not the data.\n */\n rowKey?: string | ((row: Record<string, unknown>, index: number) => string | number);\n /**\n * Semantic per-row state. `muted` recesses a row (e.g. a resource that no\n * longer exists). It is applied by data, not position, so it survives\n * sorting. Dimming is not an accessible signal on its own — pair it with a\n * status cell or visually hidden text conveying the same meaning.\n */\n rowState?: (row: Record<string, unknown>, index: number) => TTableRowState;\n }>(),\n {\n size: 'md',\n sortBy: undefined,\n caption: undefined,\n rowKey: undefined,\n rowState: undefined,\n },\n);\n\nconst emit = defineEmits<{\n (e: 'sort', state: TTableSortState): void;\n}>();\n\ndefineSlots<{\n [key: `cell-${string}`]: (props: { row: Record<string, unknown>; value: unknown }) => void;\n [key: `header-${string}`]: (props: { column: TTableColumn }) => void;\n empty: () => void;\n}>();\n\nconst internalSort = ref<TTableSortState | undefined>(undefined);\n\nconst currentSort = computed(() => props.sortBy ?? internalSort.value);\n\nconst classes = computed(() => [\n 't-table',\n `t-table--${props.size}`,\n]);\n\nconst sortedRows = computed(() => {\n const sort = currentSort.value;\n if (!sort || sort.direction === 'none') return props.rows;\n\n return [...props.rows].sort((a, b) => {\n const aVal = a[sort.key];\n const bVal = b[sort.key];\n\n if (aVal == null && bVal == null) return 0;\n if (aVal == null) return 1;\n if (bVal == null) return -1;\n\n const cmp =\n typeof aVal === 'number' && typeof bVal === 'number'\n ? aVal - bVal\n : String(aVal).localeCompare(String(bVal));\n\n return sort.direction === 'desc' ? -cmp : cmp;\n });\n});\n\nfunction handleSort(column: TTableColumn) {\n if (!column.sortable) return;\n\n const cur = currentSort.value;\n let direction: TTableSortDirection = 'asc';\n\n if (cur?.key === column.key) {\n if (cur.direction === 'asc') direction = 'desc';\n else if (cur.direction === 'desc') direction = 'none';\n else direction = 'asc';\n }\n\n const state: TTableSortState = { key: column.key, direction };\n internalSort.value = state;\n emit('sort', state);\n}\n\nfunction sortAriaSort(column: TTableColumn): 'none' | 'ascending' | 'descending' | undefined {\n if (!column.sortable) return undefined;\n const cur = currentSort.value;\n if (cur?.key !== column.key || cur.direction === 'none') return 'none';\n return cur.direction === 'asc' ? 'ascending' : 'descending';\n}\n\nfunction handleHeaderKeydown(event: KeyboardEvent, column: TTableColumn) {\n if (column.sortable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n handleSort(column);\n }\n}\n\nfunction isSortedBy(column: TTableColumn): boolean {\n const cur = currentSort.value;\n return cur?.key === column.key && cur.direction !== 'none';\n}\n\nfunction sortIconName(column: TTableColumn): TIconName {\n const cur = currentSort.value;\n if (!isSortedBy(column)) return 'chevrons-up-down';\n return cur?.direction === 'asc' ? 'chevron-up' : 'chevron-down';\n}\n\nfunction resolveRowKey(row: Record<string, unknown>, index: number): string | number {\n if (typeof props.rowKey === 'function') return props.rowKey(row, index);\n if (typeof props.rowKey === 'string') {\n const value = row[props.rowKey];\n if (typeof value === 'string' || typeof value === 'number') return value;\n }\n return index;\n}\n\nfunction rowStateClass(row: Record<string, unknown>, index: number): string | null {\n const state = props.rowState?.(row, index);\n return state && state !== 'default' ? `t-table__row--${state}` : null;\n}\n\nconst attrs = useAttrs();\n\n// class/style stay on the scroll wrapper (the root); everything else —\n// aria-label, aria-labelledby, id, data-* — is forwarded to the <table>.\nconst tableAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <div\n class=\"t-table-wrapper\"\n :class=\"attrs.class\"\n :style=\"attrs.style\"\n >\n <table\n v-bind=\"tableAttrs\"\n :class=\"classes\"\n >\n <caption\n v-if=\"caption\"\n class=\"t-table__caption\"\n >\n {{ caption }}\n </caption>\n <thead class=\"t-table__head\">\n <tr class=\"t-table__row\">\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__header\"\n :class=\"[\n column.sortable ? 't-table__header--sortable' : '',\n column.align ? `t-table__header--${column.align}` : '',\n ]\"\n :style=\"column.width ? { width: column.width } : undefined\"\n :aria-sort=\"sortAriaSort(column)\"\n :tabindex=\"column.sortable ? 0 : undefined\"\n scope=\"col\"\n @click=\"handleSort(column)\"\n @keydown=\"handleHeaderKeydown($event, column)\"\n >\n <slot\n :name=\"`header-${column.key}`\"\n :column=\"column\"\n >\n <span class=\"t-table__header-content\">\n {{ column.label }}\n <span\n v-if=\"column.sortable\"\n class=\"t-table__sort-icon\"\n :class=\"{ 'is-inactive': !isSortedBy(column) }\"\n aria-hidden=\"true\"\n >\n <TIcon\n :name=\"sortIconName(column)\"\n :size=\"14\"\n />\n </span>\n </span>\n </slot>\n </th>\n </tr>\n </thead>\n <tbody class=\"t-table__body\">\n <tr\n v-if=\"sortedRows.length === 0\"\n class=\"t-table__row t-table__row--empty\"\n >\n <td\n :colspan=\"columns.length\"\n class=\"t-table__cell t-table__cell--empty\"\n >\n <slot name=\"empty\">\n No data available.\n </slot>\n </td>\n </tr>\n <tr\n v-for=\"(row, index) in sortedRows\"\n :key=\"resolveRowKey(row, index)\"\n class=\"t-table__row\"\n :class=\"rowStateClass(row, index)\"\n >\n <td\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__cell\"\n :class=\"column.align ? `t-table__cell--${column.align}` : ''\"\n >\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"row\"\n :value=\"row[column.key]\"\n >\n {{ row[column.key] ?? '' }}\n </slot>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n"],"mappings":"+kBA8BA,IAAM,EAAQ,EAkCR,EAAO,EAUP,GAAA,EAAA,EAAA,IAAA,CAAgD,IAAA,EAAS,EAEzD,GAAA,EAAA,EAAA,SAAA,KAA6B,EAAM,QAAU,EAAa,KAAK,EAE/D,GAAA,EAAA,EAAA,SAAA,KAAyB,CAC7B,UACA,YAAY,EAAM,MACpB,CAAC,EAEK,GAAA,EAAA,EAAA,SAAA,KAA4B,CAChC,IAAM,EAAO,EAAY,MAGzB,MAFI,CAAC,GAAQ,EAAK,YAAc,OAAe,EAAM,KAE9C,CAAC,GAAG,EAAM,IAAI,CAAC,CAAC,MAAM,EAAG,IAAM,CACpC,IAAM,EAAO,EAAE,EAAK,KACd,EAAO,EAAE,EAAK,KAEpB,GAAI,GAAQ,MAAQ,GAAQ,KAAM,MAAO,GACzC,GAAI,GAAQ,KAAM,MAAO,GACzB,GAAI,GAAQ,KAAM,MAAO,GAEzB,IAAM,EACJ,OAAO,GAAS,UAAY,OAAO,GAAS,SACxC,EAAO,EACP,OAAO,CAAI,CAAC,CAAC,cAAc,OAAO,CAAI,CAAC,EAE7C,OAAO,EAAK,YAAc,OAAS,CAAC,EAAM,CAC5C,CAAC,CACH,CAAC,EAED,SAAS,EAAW,EAAsB,CACxC,GAAI,CAAC,EAAO,SAAU,OA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,gBAAA,EAAA,EAAA,EAAA,gBAAA,CADF,EAAI,EAAO,MAAG,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA"}
|
|
@@ -20,7 +20,15 @@ var y = {
|
|
|
20
20
|
rows: {},
|
|
21
21
|
size: { default: "md" },
|
|
22
22
|
sortBy: { default: void 0 },
|
|
23
|
-
caption: { default: void 0 }
|
|
23
|
+
caption: { default: void 0 },
|
|
24
|
+
rowKey: {
|
|
25
|
+
type: [String, Function],
|
|
26
|
+
default: void 0
|
|
27
|
+
},
|
|
28
|
+
rowState: {
|
|
29
|
+
type: Function,
|
|
30
|
+
default: void 0
|
|
31
|
+
}
|
|
24
32
|
},
|
|
25
33
|
emits: ["sort"],
|
|
26
34
|
setup(c, { emit: D }) {
|
|
@@ -61,14 +69,26 @@ var y = {
|
|
|
61
69
|
let t = j.value;
|
|
62
70
|
return L(e) ? t?.direction === "asc" ? "chevron-up" : "chevron-down" : "chevrons-up-down";
|
|
63
71
|
}
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
function z(e, t) {
|
|
73
|
+
if (typeof O.rowKey == "function") return O.rowKey(e, t);
|
|
74
|
+
if (typeof O.rowKey == "string") {
|
|
75
|
+
let t = e[O.rowKey];
|
|
76
|
+
if (typeof t == "string" || typeof t == "number") return t;
|
|
77
|
+
}
|
|
78
|
+
return t;
|
|
79
|
+
}
|
|
80
|
+
function B(e, t) {
|
|
81
|
+
let n = O.rowState?.(e, t);
|
|
82
|
+
return n && n !== "default" ? `t-table__row--${n}` : null;
|
|
83
|
+
}
|
|
84
|
+
let V = v(), H = n(() => {
|
|
85
|
+
let { class: e, style: t, ...n } = V;
|
|
66
86
|
return n;
|
|
67
87
|
});
|
|
68
88
|
return (n, p) => (f(), i("div", {
|
|
69
|
-
class: u(["t-table-wrapper", _(
|
|
70
|
-
style: d(_(
|
|
71
|
-
}, [a("table", l(
|
|
89
|
+
class: u(["t-table-wrapper", _(V).class]),
|
|
90
|
+
style: d(_(V).style)
|
|
91
|
+
}, [a("table", l(H.value, { class: M.value }), [
|
|
72
92
|
c.caption ? (f(), i("caption", y, g(c.caption), 1)) : r("", !0),
|
|
73
93
|
a("thead", b, [a("tr", x, [(f(!0), i(t, null, m(c.columns, (t) => (f(), i("th", {
|
|
74
94
|
key: t.key,
|
|
@@ -91,15 +111,15 @@ var y = {
|
|
|
91
111
|
colspan: c.columns.length,
|
|
92
112
|
class: "t-table__cell t-table__cell--empty"
|
|
93
113
|
}, [h(n.$slots, "empty", {}, () => [p[0] ||= o(" No data available. ", -1)])], 8, E)])) : r("", !0), (f(!0), i(t, null, m(N.value, (e, r) => (f(), i("tr", {
|
|
94
|
-
key: r,
|
|
95
|
-
class: "t-table__row"
|
|
114
|
+
key: z(e, r),
|
|
115
|
+
class: u(["t-table__row", B(e, r)])
|
|
96
116
|
}, [(f(!0), i(t, null, m(c.columns, (t) => (f(), i("td", {
|
|
97
117
|
key: t.key,
|
|
98
118
|
class: u(["t-table__cell", t.align ? `t-table__cell--${t.align}` : ""])
|
|
99
119
|
}, [h(n.$slots, `cell-${t.key}`, {
|
|
100
120
|
row: e,
|
|
101
121
|
value: e[t.key]
|
|
102
|
-
}, () => [o(g(e[t.key] ?? ""), 1)])], 2))), 128))]))), 128))])
|
|
122
|
+
}, () => [o(g(e[t.key] ?? ""), 1)])], 2))), 128))], 2))), 128))])
|
|
103
123
|
], 16)], 6));
|
|
104
124
|
}
|
|
105
125
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TTable.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/TTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue';\nimport type { TIconName } from '@treeui/icons';\nimport type { TSize } from '../types/contracts';\nimport TIcon from './TIcon.vue';\n\n// The scroll container is the root element, but the accessible name and any\n// aria-*/id belong on the <table> itself, so attrs are split rather than\n// inherited onto the wrapper.\ndefineOptions({\n inheritAttrs: false,\n});\n\nexport type TTableColumn = {\n key: string;\n label: string;\n sortable?: boolean;\n align?: 'left' | 'center' | 'right';\n width?: string;\n};\n\nexport type TTableSortDirection = 'asc' | 'desc' | 'none';\n\nexport type TTableSortState = {\n key: string;\n direction: TTableSortDirection;\n};\n\nconst props = withDefaults(\n defineProps<{\n columns: TTableColumn[];\n rows: Record<string, unknown>[];\n size?: TSize;\n sortBy?: TTableSortState;\n /**\n * Visible `<caption>` naming the table. For a name without visible text,\n * pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.\n */\n caption?: string;\n }>(),\n {\n size: 'md',\n sortBy: undefined,\n caption: undefined,\n },\n);\n\nconst emit = defineEmits<{\n (e: 'sort', state: TTableSortState): void;\n}>();\n\ndefineSlots<{\n [key: `cell-${string}`]: (props: { row: Record<string, unknown>; value: unknown }) => void;\n [key: `header-${string}`]: (props: { column: TTableColumn }) => void;\n empty: () => void;\n}>();\n\nconst internalSort = ref<TTableSortState | undefined>(undefined);\n\nconst currentSort = computed(() => props.sortBy ?? internalSort.value);\n\nconst classes = computed(() => [\n 't-table',\n `t-table--${props.size}`,\n]);\n\nconst sortedRows = computed(() => {\n const sort = currentSort.value;\n if (!sort || sort.direction === 'none') return props.rows;\n\n return [...props.rows].sort((a, b) => {\n const aVal = a[sort.key];\n const bVal = b[sort.key];\n\n if (aVal == null && bVal == null) return 0;\n if (aVal == null) return 1;\n if (bVal == null) return -1;\n\n const cmp =\n typeof aVal === 'number' && typeof bVal === 'number'\n ? aVal - bVal\n : String(aVal).localeCompare(String(bVal));\n\n return sort.direction === 'desc' ? -cmp : cmp;\n });\n});\n\nfunction handleSort(column: TTableColumn) {\n if (!column.sortable) return;\n\n const cur = currentSort.value;\n let direction: TTableSortDirection = 'asc';\n\n if (cur?.key === column.key) {\n if (cur.direction === 'asc') direction = 'desc';\n else if (cur.direction === 'desc') direction = 'none';\n else direction = 'asc';\n }\n\n const state: TTableSortState = { key: column.key, direction };\n internalSort.value = state;\n emit('sort', state);\n}\n\nfunction sortAriaSort(column: TTableColumn): 'none' | 'ascending' | 'descending' | undefined {\n if (!column.sortable) return undefined;\n const cur = currentSort.value;\n if (cur?.key !== column.key || cur.direction === 'none') return 'none';\n return cur.direction === 'asc' ? 'ascending' : 'descending';\n}\n\nfunction handleHeaderKeydown(event: KeyboardEvent, column: TTableColumn) {\n if (column.sortable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n handleSort(column);\n }\n}\n\nfunction isSortedBy(column: TTableColumn): boolean {\n const cur = currentSort.value;\n return cur?.key === column.key && cur.direction !== 'none';\n}\n\nfunction sortIconName(column: TTableColumn): TIconName {\n const cur = currentSort.value;\n if (!isSortedBy(column)) return 'chevrons-up-down';\n return cur?.direction === 'asc' ? 'chevron-up' : 'chevron-down';\n}\n\nconst attrs = useAttrs();\n\n// class/style stay on the scroll wrapper (the root); everything else —\n// aria-label, aria-labelledby, id, data-* — is forwarded to the <table>.\nconst tableAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <div\n class=\"t-table-wrapper\"\n :class=\"attrs.class\"\n :style=\"attrs.style\"\n >\n <table\n v-bind=\"tableAttrs\"\n :class=\"classes\"\n >\n <caption\n v-if=\"caption\"\n class=\"t-table__caption\"\n >\n {{ caption }}\n </caption>\n <thead class=\"t-table__head\">\n <tr class=\"t-table__row\">\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__header\"\n :class=\"[\n column.sortable ? 't-table__header--sortable' : '',\n column.align ? `t-table__header--${column.align}` : '',\n ]\"\n :style=\"column.width ? { width: column.width } : undefined\"\n :aria-sort=\"sortAriaSort(column)\"\n :tabindex=\"column.sortable ? 0 : undefined\"\n scope=\"col\"\n @click=\"handleSort(column)\"\n @keydown=\"handleHeaderKeydown($event, column)\"\n >\n <slot\n :name=\"`header-${column.key}`\"\n :column=\"column\"\n >\n <span class=\"t-table__header-content\">\n {{ column.label }}\n <span\n v-if=\"column.sortable\"\n class=\"t-table__sort-icon\"\n :class=\"{ 'is-inactive': !isSortedBy(column) }\"\n aria-hidden=\"true\"\n >\n <TIcon\n :name=\"sortIconName(column)\"\n :size=\"14\"\n />\n </span>\n </span>\n </slot>\n </th>\n </tr>\n </thead>\n <tbody class=\"t-table__body\">\n <tr\n v-if=\"sortedRows.length === 0\"\n class=\"t-table__row t-table__row--empty\"\n >\n <td\n :colspan=\"columns.length\"\n class=\"t-table__cell t-table__cell--empty\"\n >\n <slot name=\"empty\">\n No data available.\n </slot>\n </td>\n </tr>\n <tr\n v-for=\"(row, index) in sortedRows\"\n :key=\"index\"\n class=\"t-table__row\"\n >\n <td\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__cell\"\n :class=\"column.align ? `t-table__cell--${column.align}` : ''\"\n >\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"row\"\n :value=\"row[column.key]\"\n >\n {{ row[column.key] ?? '' }}\n </slot>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EA4BA,IAAM,IAAQ,GAmBR,IAAO,GAUP,IAAe,EAAiC,KAAA,CAAS,GAEzD,IAAc,QAAe,EAAM,UAAU,EAAa,KAAK,GAE/D,IAAU,QAAe,CAC7B,WACA,YAAY,EAAM,MACpB,CAAC,GAEK,IAAa,QAAe;GAChC,IAAM,IAAO,EAAY;GAGzB,OAFI,CAAC,KAAQ,EAAK,cAAc,SAAe,EAAM,OAE9C,CAAC,GAAG,EAAM,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM;IACpC,IAAM,IAAO,EAAE,EAAK,MACd,IAAO,EAAE,EAAK;IAEpB,IAAI,KAAQ,QAAQ,KAAQ,MAAM,OAAO;IACzC,IAAI,KAAQ,MAAM,OAAO;IACzB,IAAI,KAAQ,MAAM,OAAO;IAEzB,IAAM,IACJ,OAAO,KAAS,YAAY,OAAO,KAAS,WACxC,IAAO,IACP,OAAO,CAAI,CAAC,CAAC,cAAc,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AAA,IAAA,EAAA,EAAA,GAGJ,EAmBK,GAAA,MAAA,EAlBoB,EAAA,QAAf,GAAK,YADf,EAmBK,MAAA;IAjBF,KAAK;IACN,OAAM;eAEN,EAaK,GAAA,MAAA,EAZc,EAAA,UAAV,YADT,EAaK,MAAA;IAXF,KAAK,EAAO;IACb,OAAK,EAAA,CAAC,iBACE,EAAO,QAAK,kBAAqB,EAAO,UAAK,EAAA,CAAA;OAErD,EAMO,EAAA,QAAA,QALU,EAAO,OAAG;IACnB;IACL,OAAO,EAAI,EAAO;YAGd,CAAA,EAAA,EADF,EAAI,EAAO,QAAG,EAAA,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"TTable.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/TTable.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue';\nimport type { TIconName } from '@treeui/icons';\nimport type { TSize } from '../types/contracts';\nimport TIcon from './TIcon.vue';\n\n// The scroll container is the root element, but the accessible name and any\n// aria-*/id belong on the <table> itself, so attrs are split rather than\n// inherited onto the wrapper.\ndefineOptions({\n inheritAttrs: false,\n});\n\nexport type TTableColumn = {\n key: string;\n label: string;\n sortable?: boolean;\n align?: 'left' | 'center' | 'right';\n width?: string;\n};\n\nexport type TTableSortDirection = 'asc' | 'desc' | 'none';\n\nexport type TTableSortState = {\n key: string;\n direction: TTableSortDirection;\n};\n\nexport type TTableRowState = 'default' | 'muted';\n\nconst props = withDefaults(\n defineProps<{\n columns: TTableColumn[];\n rows: Record<string, unknown>[];\n size?: TSize;\n sortBy?: TTableSortState;\n /**\n * Visible `<caption>` naming the table. For a name without visible text,\n * pass `aria-label` / `aria-labelledby` instead — both land on the `<table>`.\n */\n caption?: string;\n /**\n * Stable identity per row. A key (or a function of the row) so rows keep\n * their identity across sorting — otherwise Vue keys by array index and\n * `rowState` styling follows the position, not the data.\n */\n rowKey?: string | ((row: Record<string, unknown>, index: number) => string | number);\n /**\n * Semantic per-row state. `muted` recesses a row (e.g. a resource that no\n * longer exists). It is applied by data, not position, so it survives\n * sorting. Dimming is not an accessible signal on its own — pair it with a\n * status cell or visually hidden text conveying the same meaning.\n */\n rowState?: (row: Record<string, unknown>, index: number) => TTableRowState;\n }>(),\n {\n size: 'md',\n sortBy: undefined,\n caption: undefined,\n rowKey: undefined,\n rowState: undefined,\n },\n);\n\nconst emit = defineEmits<{\n (e: 'sort', state: TTableSortState): void;\n}>();\n\ndefineSlots<{\n [key: `cell-${string}`]: (props: { row: Record<string, unknown>; value: unknown }) => void;\n [key: `header-${string}`]: (props: { column: TTableColumn }) => void;\n empty: () => void;\n}>();\n\nconst internalSort = ref<TTableSortState | undefined>(undefined);\n\nconst currentSort = computed(() => props.sortBy ?? internalSort.value);\n\nconst classes = computed(() => [\n 't-table',\n `t-table--${props.size}`,\n]);\n\nconst sortedRows = computed(() => {\n const sort = currentSort.value;\n if (!sort || sort.direction === 'none') return props.rows;\n\n return [...props.rows].sort((a, b) => {\n const aVal = a[sort.key];\n const bVal = b[sort.key];\n\n if (aVal == null && bVal == null) return 0;\n if (aVal == null) return 1;\n if (bVal == null) return -1;\n\n const cmp =\n typeof aVal === 'number' && typeof bVal === 'number'\n ? aVal - bVal\n : String(aVal).localeCompare(String(bVal));\n\n return sort.direction === 'desc' ? -cmp : cmp;\n });\n});\n\nfunction handleSort(column: TTableColumn) {\n if (!column.sortable) return;\n\n const cur = currentSort.value;\n let direction: TTableSortDirection = 'asc';\n\n if (cur?.key === column.key) {\n if (cur.direction === 'asc') direction = 'desc';\n else if (cur.direction === 'desc') direction = 'none';\n else direction = 'asc';\n }\n\n const state: TTableSortState = { key: column.key, direction };\n internalSort.value = state;\n emit('sort', state);\n}\n\nfunction sortAriaSort(column: TTableColumn): 'none' | 'ascending' | 'descending' | undefined {\n if (!column.sortable) return undefined;\n const cur = currentSort.value;\n if (cur?.key !== column.key || cur.direction === 'none') return 'none';\n return cur.direction === 'asc' ? 'ascending' : 'descending';\n}\n\nfunction handleHeaderKeydown(event: KeyboardEvent, column: TTableColumn) {\n if (column.sortable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n handleSort(column);\n }\n}\n\nfunction isSortedBy(column: TTableColumn): boolean {\n const cur = currentSort.value;\n return cur?.key === column.key && cur.direction !== 'none';\n}\n\nfunction sortIconName(column: TTableColumn): TIconName {\n const cur = currentSort.value;\n if (!isSortedBy(column)) return 'chevrons-up-down';\n return cur?.direction === 'asc' ? 'chevron-up' : 'chevron-down';\n}\n\nfunction resolveRowKey(row: Record<string, unknown>, index: number): string | number {\n if (typeof props.rowKey === 'function') return props.rowKey(row, index);\n if (typeof props.rowKey === 'string') {\n const value = row[props.rowKey];\n if (typeof value === 'string' || typeof value === 'number') return value;\n }\n return index;\n}\n\nfunction rowStateClass(row: Record<string, unknown>, index: number): string | null {\n const state = props.rowState?.(row, index);\n return state && state !== 'default' ? `t-table__row--${state}` : null;\n}\n\nconst attrs = useAttrs();\n\n// class/style stay on the scroll wrapper (the root); everything else —\n// aria-label, aria-labelledby, id, data-* — is forwarded to the <table>.\nconst tableAttrs = computed(() => {\n const { class: _class, style: _style, ...rest } = attrs;\n return rest;\n});\n</script>\n\n<template>\n <div\n class=\"t-table-wrapper\"\n :class=\"attrs.class\"\n :style=\"attrs.style\"\n >\n <table\n v-bind=\"tableAttrs\"\n :class=\"classes\"\n >\n <caption\n v-if=\"caption\"\n class=\"t-table__caption\"\n >\n {{ caption }}\n </caption>\n <thead class=\"t-table__head\">\n <tr class=\"t-table__row\">\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__header\"\n :class=\"[\n column.sortable ? 't-table__header--sortable' : '',\n column.align ? `t-table__header--${column.align}` : '',\n ]\"\n :style=\"column.width ? { width: column.width } : undefined\"\n :aria-sort=\"sortAriaSort(column)\"\n :tabindex=\"column.sortable ? 0 : undefined\"\n scope=\"col\"\n @click=\"handleSort(column)\"\n @keydown=\"handleHeaderKeydown($event, column)\"\n >\n <slot\n :name=\"`header-${column.key}`\"\n :column=\"column\"\n >\n <span class=\"t-table__header-content\">\n {{ column.label }}\n <span\n v-if=\"column.sortable\"\n class=\"t-table__sort-icon\"\n :class=\"{ 'is-inactive': !isSortedBy(column) }\"\n aria-hidden=\"true\"\n >\n <TIcon\n :name=\"sortIconName(column)\"\n :size=\"14\"\n />\n </span>\n </span>\n </slot>\n </th>\n </tr>\n </thead>\n <tbody class=\"t-table__body\">\n <tr\n v-if=\"sortedRows.length === 0\"\n class=\"t-table__row t-table__row--empty\"\n >\n <td\n :colspan=\"columns.length\"\n class=\"t-table__cell t-table__cell--empty\"\n >\n <slot name=\"empty\">\n No data available.\n </slot>\n </td>\n </tr>\n <tr\n v-for=\"(row, index) in sortedRows\"\n :key=\"resolveRowKey(row, index)\"\n class=\"t-table__row\"\n :class=\"rowStateClass(row, index)\"\n >\n <td\n v-for=\"column in columns\"\n :key=\"column.key\"\n class=\"t-table__cell\"\n :class=\"column.align ? `t-table__cell--${column.align}` : ''\"\n >\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"row\"\n :value=\"row[column.key]\"\n >\n {{ row[column.key] ?? '' }}\n </slot>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BA,IAAM,IAAQ,GAkCR,IAAO,GAUP,IAAe,EAAiC,KAAA,CAAS,GAEzD,IAAc,QAAe,EAAM,UAAU,EAAa,KAAK,GAE/D,IAAU,QAAe,CAC7B,WACA,YAAY,EAAM,MACpB,CAAC,GAEK,IAAa,QAAe;GAChC,IAAM,IAAO,EAAY;GAGzB,OAFI,CAAC,KAAQ,EAAK,cAAc,SAAe,EAAM,OAE9C,CAAC,GAAG,EAAM,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM;IACpC,IAAM,IAAO,EAAE,EAAK,MACd,IAAO,EAAE,EAAK;IAEpB,IAAI,KAAQ,QAAQ,K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GAaO,CAAA,EAAA,EAZF,EAAO,KAAK,IAAG,KAClB,CAAA,GACQ,EAAO,YAAA,EAAA,GADf,EAUO,QAAA;;IARL,OAAK,EAAA,CAAC,sBAAoB,EAAA,eAAA,CACA,EAAW,CAAM,EAAA,CAAA,CAAA;IAC3C,eAAY;OAEZ,EAGE,GAAA;IAFC,MAAM,EAAa,CAAM;IACzB,MAAM;;GAQrB,EAmCQ,SAnCR,GAmCQ,CAjCE,EAAA,MAAW,WAAM,KAAA,EAAA,GADzB,EAYK,MAZL,GAYK,CARH,EAOK,MAAA;IANF,SAAS,EAAA,QAAQ;IAClB,OAAM;OAEN,EAEO,EAAA,QAAA,SAAA,CAAA,SAAA,CAAA,AAAA,EAAA,OAAA,EAFY,wBAEnB,EAAA,CAAA,CAAA,CAAA,GAAA,GAAA,CAAA,CAAA,CAAA,KAAA,EAAA,IAAA,EAAA,IAAA,EAAA,EAAA,GAGJ,EAoBK,GAAA,MAAA,EAnBoB,EAAA,QAAf,GAAK,YADf,EAoBK,MAAA;IAlBF,KAAK,EAAc,GAAK,CAAK;IAC9B,OAAK,EAAA,CAAC,gBACE,EAAc,GAAK,CAAK,CAAA,CAAA;eAEhC,EAaK,GAAA,MAAA,EAZc,EAAA,UAAV,YADT,EAaK,MAAA;IAXF,KAAK,EAAO;IACb,OAAK,EAAA,CAAC,iBACE,EAAO,QAAK,kBAAqB,EAAO,UAAK,EAAA,CAAA;OAErD,EAMO,EAAA,QAAA,QALU,EAAO,OAAG;IACnB;IACL,OAAO,EAAI,EAAO;YAGd,CAAA,EAAA,EADF,EAAI,EAAO,QAAG,EAAA,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TText.cjs","names":[],"sources":["../../src/components/TText.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\n\nconst _treeTextSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;\nconst _treeTextTones = ['default', 'muted', 'inverse', 'brand'] as const;\nconst _treeTextWeights = ['regular', 'medium', 'semibold', 'bold'] as const;\n\nexport type TTextSize = (typeof _treeTextSizes)[number];\nexport type TTextTone = (typeof _treeTextTones)[number];\nexport type TTextWeight = (typeof _treeTextWeights)[number];\n\nconst props = withDefaults(\n defineProps<{\n /** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */\n as?: string;\n size?: TTextSize;\n tone?: TTextTone;\n weight?: TTextWeight;\n /** Truncate to a single line with an ellipsis. */\n truncate?: boolean;\n /**\n * Preserve authored line breaks and paragraph spacing (`white-space: pre-wrap`)\n * while still wrapping long lines. Use for plain-text output such as AI\n * responses. Ignored when `truncate` is set, since the two conflict.\n */\n preserveWhitespace?: boolean;\n }>(),\n {\n as: 'span',\n size: undefined,\n tone: 'default',\n weight: undefined,\n truncate: false,\n preserveWhitespace: false,\n },\n);\n\nconst classes = computed(() => [\n 't-text',\n props.size ? `t-text--size-${props.size}` : null,\n props.tone !== 'default' ? `t-text--${props.tone}` : null,\n props.weight ? `t-text--weight-${props.weight}` : null,\n {\n 'is-truncated': props.truncate,\n 'is-pre-wrap': props.preserveWhitespace && !props.truncate,\n },\n]);\n</script>\n\n<template>\n <component\n :is=\"as\"\n :class=\"classes\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"TText.cjs","names":[],"sources":["../../src/components/TText.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\n\nconst _treeTextSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;\nconst _treeTextTones = ['default', 'muted', 'inverse', 'brand'] as const;\nconst _treeTextWeights = ['regular', 'medium', 'semibold', 'bold'] as const;\nconst _treeTextFamilies = ['sans', 'mono'] as const;\n\nexport type TTextSize = (typeof _treeTextSizes)[number];\nexport type TTextTone = (typeof _treeTextTones)[number];\nexport type TTextWeight = (typeof _treeTextWeights)[number];\nexport type TTextFamily = (typeof _treeTextFamilies)[number];\n\nconst props = withDefaults(\n defineProps<{\n /** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */\n as?: string;\n size?: TTextSize;\n tone?: TTextTone;\n weight?: TTextWeight;\n /**\n * Font family. Omitted = inherit. `mono` maps to `--tree-font-family-mono`\n * for inline code, IDs, ARNs and other machine text, so consumers never\n * hardcode a monospace stack.\n */\n family?: TTextFamily;\n /** Truncate to a single line with an ellipsis. */\n truncate?: boolean;\n /**\n * Preserve authored line breaks and paragraph spacing (`white-space: pre-wrap`)\n * while still wrapping long lines. Use for plain-text output such as AI\n * responses. Ignored when `truncate` is set, since the two conflict.\n */\n preserveWhitespace?: boolean;\n }>(),\n {\n as: 'span',\n size: undefined,\n tone: 'default',\n weight: undefined,\n family: undefined,\n truncate: false,\n preserveWhitespace: false,\n },\n);\n\nconst classes = computed(() => [\n 't-text',\n props.size ? `t-text--size-${props.size}` : null,\n props.tone !== 'default' ? `t-text--${props.tone}` : null,\n props.weight ? `t-text--weight-${props.weight}` : null,\n props.family ? `t-text--family-${props.family}` : null,\n {\n 'is-truncated': props.truncate,\n 'is-pre-wrap': props.preserveWhitespace && !props.truncate,\n },\n]);\n</script>\n\n<template>\n <component\n :is=\"as\"\n :class=\"classes\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TText.js","names":[],"sources":["../../src/components/TText.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\n\nconst _treeTextSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;\nconst _treeTextTones = ['default', 'muted', 'inverse', 'brand'] as const;\nconst _treeTextWeights = ['regular', 'medium', 'semibold', 'bold'] as const;\n\nexport type TTextSize = (typeof _treeTextSizes)[number];\nexport type TTextTone = (typeof _treeTextTones)[number];\nexport type TTextWeight = (typeof _treeTextWeights)[number];\n\nconst props = withDefaults(\n defineProps<{\n /** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */\n as?: string;\n size?: TTextSize;\n tone?: TTextTone;\n weight?: TTextWeight;\n /** Truncate to a single line with an ellipsis. */\n truncate?: boolean;\n /**\n * Preserve authored line breaks and paragraph spacing (`white-space: pre-wrap`)\n * while still wrapping long lines. Use for plain-text output such as AI\n * responses. Ignored when `truncate` is set, since the two conflict.\n */\n preserveWhitespace?: boolean;\n }>(),\n {\n as: 'span',\n size: undefined,\n tone: 'default',\n weight: undefined,\n truncate: false,\n preserveWhitespace: false,\n },\n);\n\nconst classes = computed(() => [\n 't-text',\n props.size ? `t-text--size-${props.size}` : null,\n props.tone !== 'default' ? `t-text--${props.tone}` : null,\n props.weight ? `t-text--weight-${props.weight}` : null,\n {\n 'is-truncated': props.truncate,\n 'is-pre-wrap': props.preserveWhitespace && !props.truncate,\n },\n]);\n</script>\n\n<template>\n <component\n :is=\"as\"\n :class=\"classes\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"TText.js","names":[],"sources":["../../src/components/TText.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\n\nconst _treeTextSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;\nconst _treeTextTones = ['default', 'muted', 'inverse', 'brand'] as const;\nconst _treeTextWeights = ['regular', 'medium', 'semibold', 'bold'] as const;\nconst _treeTextFamilies = ['sans', 'mono'] as const;\n\nexport type TTextSize = (typeof _treeTextSizes)[number];\nexport type TTextTone = (typeof _treeTextTones)[number];\nexport type TTextWeight = (typeof _treeTextWeights)[number];\nexport type TTextFamily = (typeof _treeTextFamilies)[number];\n\nconst props = withDefaults(\n defineProps<{\n /** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */\n as?: string;\n size?: TTextSize;\n tone?: TTextTone;\n weight?: TTextWeight;\n /**\n * Font family. Omitted = inherit. `mono` maps to `--tree-font-family-mono`\n * for inline code, IDs, ARNs and other machine text, so consumers never\n * hardcode a monospace stack.\n */\n family?: TTextFamily;\n /** Truncate to a single line with an ellipsis. */\n truncate?: boolean;\n /**\n * Preserve authored line breaks and paragraph spacing (`white-space: pre-wrap`)\n * while still wrapping long lines. Use for plain-text output such as AI\n * responses. Ignored when `truncate` is set, since the two conflict.\n */\n preserveWhitespace?: boolean;\n }>(),\n {\n as: 'span',\n size: undefined,\n tone: 'default',\n weight: undefined,\n family: undefined,\n truncate: false,\n preserveWhitespace: false,\n },\n);\n\nconst classes = computed(() => [\n 't-text',\n props.size ? `t-text--size-${props.size}` : null,\n props.tone !== 'default' ? `t-text--${props.tone}` : null,\n props.weight ? `t-text--weight-${props.weight}` : null,\n props.family ? `t-text--family-${props.family}` : null,\n {\n 'is-truncated': props.truncate,\n 'is-pre-wrap': props.preserveWhitespace && !props.truncate,\n },\n]);\n</script>\n\n<template>\n <component\n :is=\"as\"\n :class=\"classes\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":""}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
declare const _treeTextSizes: readonly ["xs", "sm", "md", "lg", "xl", "2xl", "3xl"];
|
|
2
2
|
declare const _treeTextTones: readonly ["default", "muted", "inverse", "brand"];
|
|
3
3
|
declare const _treeTextWeights: readonly ["regular", "medium", "semibold", "bold"];
|
|
4
|
+
declare const _treeTextFamilies: readonly ["sans", "mono"];
|
|
4
5
|
export type TTextSize = (typeof _treeTextSizes)[number];
|
|
5
6
|
export type TTextTone = (typeof _treeTextTones)[number];
|
|
6
7
|
export type TTextWeight = (typeof _treeTextWeights)[number];
|
|
8
|
+
export type TTextFamily = (typeof _treeTextFamilies)[number];
|
|
7
9
|
type __VLS_Props = {
|
|
8
10
|
/** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */
|
|
9
11
|
as?: string;
|
|
10
12
|
size?: TTextSize;
|
|
11
13
|
tone?: TTextTone;
|
|
12
14
|
weight?: TTextWeight;
|
|
15
|
+
/**
|
|
16
|
+
* Font family. Omitted = inherit. `mono` maps to `--tree-font-family-mono`
|
|
17
|
+
* for inline code, IDs, ARNs and other machine text, so consumers never
|
|
18
|
+
* hardcode a monospace stack.
|
|
19
|
+
*/
|
|
20
|
+
family?: TTextFamily;
|
|
13
21
|
/** Truncate to a single line with an ellipsis. */
|
|
14
22
|
truncate?: boolean;
|
|
15
23
|
/**
|
|
@@ -33,6 +41,7 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
|
|
|
33
41
|
tone: TTextTone;
|
|
34
42
|
as: string;
|
|
35
43
|
weight: TTextWeight;
|
|
44
|
+
family: TTextFamily;
|
|
36
45
|
truncate: boolean;
|
|
37
46
|
preserveWhitespace: boolean;
|
|
38
47
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TText.vue.d.ts","sourceRoot":"","sources":["../../src/components/TText.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TText.vue.d.ts","sourceRoot":"","sources":["../../src/components/TText.vue"],"names":[],"mappings":"AAuEA,QAAA,MAAM,cAAc,uDAAwD,CAAC;AAC7E,QAAA,MAAM,cAAc,mDAAoD,CAAC;AACzE,QAAA,MAAM,gBAAgB,oDAAqD,CAAC;AAC5E,QAAA,MAAM,iBAAiB,2BAA4B,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,KAAK,WAAW,GAAG;IACf,4EAA4E;IAC5E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAqCJ,iBAAS,cAAc;WA+BT,OAAO,IAA6B;;yBAVrB,GAAG;;;;EAe/B;AAUD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;UArGV,SAAS;UACT,SAAS;QAFX,MAAM;YAGF,WAAW;YAMX,WAAW;cAET,OAAO;wBAMG,OAAO;6EA6F9B,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("vue");var t=(0,e.defineComponent)({__name:`TText`,props:{as:{default:`span`},size:{default:void 0},tone:{default:`default`},weight:{default:void 0},truncate:{type:Boolean,default:!1},preserveWhitespace:{type:Boolean,default:!1}},setup(t){let n=t,r=(0,e.computed)(()=>[`t-text`,n.size?`t-text--size-${n.size}`:null,n.tone==="default"?null:`t-text--${n.tone}`,n.weight?`t-text--weight-${n.weight}`:null,{"is-truncated":n.truncate,"is-pre-wrap":n.preserveWhitespace&&!n.truncate}]);return(n,i)=>((0,e.openBlock)(),(0,e.createBlock)((0,e.resolveDynamicComponent)(t.as),{class:(0,e.normalizeClass)(r.value)},{default:(0,e.withCtx)(()=>[(0,e.renderSlot)(n.$slots,`default`)]),_:3},8,[`class`]))}});exports.default=t;
|
|
1
|
+
let e=require("vue");var t=(0,e.defineComponent)({__name:`TText`,props:{as:{default:`span`},size:{default:void 0},tone:{default:`default`},weight:{default:void 0},family:{default:void 0},truncate:{type:Boolean,default:!1},preserveWhitespace:{type:Boolean,default:!1}},setup(t){let n=t,r=(0,e.computed)(()=>[`t-text`,n.size?`t-text--size-${n.size}`:null,n.tone==="default"?null:`t-text--${n.tone}`,n.weight?`t-text--weight-${n.weight}`:null,n.family?`t-text--family-${n.family}`:null,{"is-truncated":n.truncate,"is-pre-wrap":n.preserveWhitespace&&!n.truncate}]);return(n,i)=>((0,e.openBlock)(),(0,e.createBlock)((0,e.resolveDynamicComponent)(t.as),{class:(0,e.normalizeClass)(r.value)},{default:(0,e.withCtx)(()=>[(0,e.renderSlot)(n.$slots,`default`)]),_:3},8,[`class`]))}});exports.default=t;
|
|
2
2
|
//# sourceMappingURL=TText.vue_vue_type_script_setup_true_lang.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TText.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/components/TText.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\n\nconst _treeTextSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;\nconst _treeTextTones = ['default', 'muted', 'inverse', 'brand'] as const;\nconst _treeTextWeights = ['regular', 'medium', 'semibold', 'bold'] as const;\n\nexport type TTextSize = (typeof _treeTextSizes)[number];\nexport type TTextTone = (typeof _treeTextTones)[number];\nexport type TTextWeight = (typeof _treeTextWeights)[number];\n\nconst props = withDefaults(\n defineProps<{\n /** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */\n as?: string;\n size?: TTextSize;\n tone?: TTextTone;\n weight?: TTextWeight;\n /** Truncate to a single line with an ellipsis. */\n truncate?: boolean;\n /**\n * Preserve authored line breaks and paragraph spacing (`white-space: pre-wrap`)\n * while still wrapping long lines. Use for plain-text output such as AI\n * responses. Ignored when `truncate` is set, since the two conflict.\n */\n preserveWhitespace?: boolean;\n }>(),\n {\n as: 'span',\n size: undefined,\n tone: 'default',\n weight: undefined,\n truncate: false,\n preserveWhitespace: false,\n },\n);\n\nconst classes = computed(() => [\n 't-text',\n props.size ? `t-text--size-${props.size}` : null,\n props.tone !== 'default' ? `t-text--${props.tone}` : null,\n props.weight ? `t-text--weight-${props.weight}` : null,\n {\n 'is-truncated': props.truncate,\n 'is-pre-wrap': props.preserveWhitespace && !props.truncate,\n },\n]);\n</script>\n\n<template>\n <component\n :is=\"as\"\n :class=\"classes\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TText.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/components/TText.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\n\nconst _treeTextSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;\nconst _treeTextTones = ['default', 'muted', 'inverse', 'brand'] as const;\nconst _treeTextWeights = ['regular', 'medium', 'semibold', 'bold'] as const;\nconst _treeTextFamilies = ['sans', 'mono'] as const;\n\nexport type TTextSize = (typeof _treeTextSizes)[number];\nexport type TTextTone = (typeof _treeTextTones)[number];\nexport type TTextWeight = (typeof _treeTextWeights)[number];\nexport type TTextFamily = (typeof _treeTextFamilies)[number];\n\nconst props = withDefaults(\n defineProps<{\n /** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */\n as?: string;\n size?: TTextSize;\n tone?: TTextTone;\n weight?: TTextWeight;\n /**\n * Font family. Omitted = inherit. `mono` maps to `--tree-font-family-mono`\n * for inline code, IDs, ARNs and other machine text, so consumers never\n * hardcode a monospace stack.\n */\n family?: TTextFamily;\n /** Truncate to a single line with an ellipsis. */\n truncate?: boolean;\n /**\n * Preserve authored line breaks and paragraph spacing (`white-space: pre-wrap`)\n * while still wrapping long lines. Use for plain-text output such as AI\n * responses. Ignored when `truncate` is set, since the two conflict.\n */\n preserveWhitespace?: boolean;\n }>(),\n {\n as: 'span',\n size: undefined,\n tone: 'default',\n weight: undefined,\n family: undefined,\n truncate: false,\n preserveWhitespace: false,\n },\n);\n\nconst classes = computed(() => [\n 't-text',\n props.size ? `t-text--size-${props.size}` : null,\n props.tone !== 'default' ? `t-text--${props.tone}` : null,\n props.weight ? `t-text--weight-${props.weight}` : null,\n props.family ? `t-text--family-${props.family}` : null,\n {\n 'is-truncated': props.truncate,\n 'is-pre-wrap': props.preserveWhitespace && !props.truncate,\n },\n]);\n</script>\n\n<template>\n <component\n :is=\"as\"\n :class=\"classes\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":"qRAaA,IAAM,EAAQ,EAiCR,GAAA,EAAA,EAAA,SAAA,KAAyB,CAC7B,SACA,EAAM,KAAO,gBAAgB,EAAM,OAAS,KAC5C,EAAM,OAAS,UAAsC,KAA1B,WAAW,EAAM,OAC5C,EAAM,OAAS,kBAAkB,EAAM,SAAW,KAClD,EAAM,OAAS,kBAAkB,EAAM,SAAW,KAClD,CACE,eAAgB,EAAM,SACtB,cAAe,EAAM,oBAAsB,CAAC,EAAM,QACpD,CACF,CAAC,kFAKQ,EAAA,EAAE,EAAA,CACN,OAAA,EAAA,EAAA,eAAA,CAAO,EAAA,KAAO,CAAA,EAAA,2BAEP,EAAA,EAAA,EAAA,WAAA,CAAA,EAAA,OAAA,SAAA,CAAA,CAAA"}
|
|
@@ -7,6 +7,7 @@ var c = /*@__PURE__*/ n({
|
|
|
7
7
|
size: { default: void 0 },
|
|
8
8
|
tone: { default: "default" },
|
|
9
9
|
weight: { default: void 0 },
|
|
10
|
+
family: { default: void 0 },
|
|
10
11
|
truncate: {
|
|
11
12
|
type: Boolean,
|
|
12
13
|
default: !1
|
|
@@ -22,6 +23,7 @@ var c = /*@__PURE__*/ n({
|
|
|
22
23
|
c.size ? `t-text--size-${c.size}` : null,
|
|
23
24
|
c.tone === "default" ? null : `t-text--${c.tone}`,
|
|
24
25
|
c.weight ? `t-text--weight-${c.weight}` : null,
|
|
26
|
+
c.family ? `t-text--family-${c.family}` : null,
|
|
25
27
|
{
|
|
26
28
|
"is-truncated": c.truncate,
|
|
27
29
|
"is-pre-wrap": c.preserveWhitespace && !c.truncate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TText.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/TText.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\n\nconst _treeTextSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;\nconst _treeTextTones = ['default', 'muted', 'inverse', 'brand'] as const;\nconst _treeTextWeights = ['regular', 'medium', 'semibold', 'bold'] as const;\n\nexport type TTextSize = (typeof _treeTextSizes)[number];\nexport type TTextTone = (typeof _treeTextTones)[number];\nexport type TTextWeight = (typeof _treeTextWeights)[number];\n\nconst props = withDefaults(\n defineProps<{\n /** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */\n as?: string;\n size?: TTextSize;\n tone?: TTextTone;\n weight?: TTextWeight;\n /** Truncate to a single line with an ellipsis. */\n truncate?: boolean;\n /**\n * Preserve authored line breaks and paragraph spacing (`white-space: pre-wrap`)\n * while still wrapping long lines. Use for plain-text output such as AI\n * responses. Ignored when `truncate` is set, since the two conflict.\n */\n preserveWhitespace?: boolean;\n }>(),\n {\n as: 'span',\n size: undefined,\n tone: 'default',\n weight: undefined,\n truncate: false,\n preserveWhitespace: false,\n },\n);\n\nconst classes = computed(() => [\n 't-text',\n props.size ? `t-text--size-${props.size}` : null,\n props.tone !== 'default' ? `t-text--${props.tone}` : null,\n props.weight ? `t-text--weight-${props.weight}` : null,\n {\n 'is-truncated': props.truncate,\n 'is-pre-wrap': props.preserveWhitespace && !props.truncate,\n },\n]);\n</script>\n\n<template>\n <component\n :is=\"as\"\n :class=\"classes\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TText.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/TText.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue';\n\nconst _treeTextSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;\nconst _treeTextTones = ['default', 'muted', 'inverse', 'brand'] as const;\nconst _treeTextWeights = ['regular', 'medium', 'semibold', 'bold'] as const;\nconst _treeTextFamilies = ['sans', 'mono'] as const;\n\nexport type TTextSize = (typeof _treeTextSizes)[number];\nexport type TTextTone = (typeof _treeTextTones)[number];\nexport type TTextWeight = (typeof _treeTextWeights)[number];\nexport type TTextFamily = (typeof _treeTextFamilies)[number];\n\nconst props = withDefaults(\n defineProps<{\n /** Element to render. Defaults to `span`; use `p`, `h1`–`h6`, `label`, … */\n as?: string;\n size?: TTextSize;\n tone?: TTextTone;\n weight?: TTextWeight;\n /**\n * Font family. Omitted = inherit. `mono` maps to `--tree-font-family-mono`\n * for inline code, IDs, ARNs and other machine text, so consumers never\n * hardcode a monospace stack.\n */\n family?: TTextFamily;\n /** Truncate to a single line with an ellipsis. */\n truncate?: boolean;\n /**\n * Preserve authored line breaks and paragraph spacing (`white-space: pre-wrap`)\n * while still wrapping long lines. Use for plain-text output such as AI\n * responses. Ignored when `truncate` is set, since the two conflict.\n */\n preserveWhitespace?: boolean;\n }>(),\n {\n as: 'span',\n size: undefined,\n tone: 'default',\n weight: undefined,\n family: undefined,\n truncate: false,\n preserveWhitespace: false,\n },\n);\n\nconst classes = computed(() => [\n 't-text',\n props.size ? `t-text--size-${props.size}` : null,\n props.tone !== 'default' ? `t-text--${props.tone}` : null,\n props.weight ? `t-text--weight-${props.weight}` : null,\n props.family ? `t-text--family-${props.family}` : null,\n {\n 'is-truncated': props.truncate,\n 'is-pre-wrap': props.preserveWhitespace && !props.truncate,\n },\n]);\n</script>\n\n<template>\n <component\n :is=\"as\"\n :class=\"classes\"\n >\n <slot />\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAaA,IAAM,IAAQ,GAiCR,IAAU,QAAe;GAC7B;GACA,EAAM,OAAO,gBAAgB,EAAM,SAAS;GAC5C,EAAM,SAAS,YAAsC,OAA1B,WAAW,EAAM;GAC5C,EAAM,SAAS,kBAAkB,EAAM,WAAW;GAClD,EAAM,SAAS,kBAAkB,EAAM,WAAW;GAClD;IACE,gBAAgB,EAAM;IACtB,eAAe,EAAM,sBAAsB,CAAC,EAAM;GACpD;EACF,CAAC;yBAIC,EAKY,EAJL,EAAA,EAAE,GAAA,EACN,OAAK,EAAE,EAAA,KAAO,EAAA,GAAA;oBAEP,CAAR,EAAQ,EAAA,QAAA,SAAA,CAAA,CAAA"}
|
|
@@ -31,7 +31,7 @@ export type { TFileUploadCancelPayload, TFileUploadFileSlotProps, TFileUploadRej
|
|
|
31
31
|
export { default as TNavbar } from './TNavbar.vue';
|
|
32
32
|
export { default as TAppBar } from './TNavbar.vue';
|
|
33
33
|
export { default as TLink } from './TLink.vue';
|
|
34
|
-
export type { TLinkVariant } from './TLink.vue';
|
|
34
|
+
export type { TLinkVariant, TLinkUnderline, TLinkWeight } from './TLink.vue';
|
|
35
35
|
export { default as TNavMenu } from './TNavMenu.vue';
|
|
36
36
|
export type { TNavMenuItem } from './TNavMenu.vue';
|
|
37
37
|
export { default as TRadio } from './TRadio.vue';
|
|
@@ -51,13 +51,13 @@ export type { TSelectableListItem } from './TSelectableList.vue';
|
|
|
51
51
|
export { default as TColorSwatch } from './TColorSwatch.vue';
|
|
52
52
|
export type { TColorSwatchOption } from './TColorSwatch.vue';
|
|
53
53
|
export { default as TStack } from './TStack.vue';
|
|
54
|
-
export type { TStackDirection } from './TStack.vue';
|
|
54
|
+
export type { TStackDirection, TStackFill } from './TStack.vue';
|
|
55
55
|
export { default as TStackItem } from './TStackItem.vue';
|
|
56
56
|
export { default as TSplit } from './TSplit.vue';
|
|
57
57
|
export { default as TSpacer } from './TSpacer.vue';
|
|
58
58
|
export { default as TKbd } from './TKbd.vue';
|
|
59
59
|
export { default as TText } from './TText.vue';
|
|
60
|
-
export type { TTextSize, TTextTone, TTextWeight } from './TText.vue';
|
|
60
|
+
export type { TTextSize, TTextTone, TTextWeight, TTextFamily } from './TText.vue';
|
|
61
61
|
export { default as TTreeView } from './TTreeView.vue';
|
|
62
62
|
export type { TTreeViewNode, TTreeViewSelectionMode } from './tree-view';
|
|
63
63
|
export { default as TSteps } from './TSteps.vue';
|
|
@@ -92,7 +92,7 @@ export type { TAvatarStatus } from './TAvatar.vue';
|
|
|
92
92
|
export { default as TFlag } from './TFlag.vue';
|
|
93
93
|
export { default as TDivider } from './TDivider.vue';
|
|
94
94
|
export { default as TTable } from './TTable.vue';
|
|
95
|
-
export type { TTableColumn, TTableSortDirection, TTableSortState } from './TTable.vue';
|
|
95
|
+
export type { TTableColumn, TTableSortDirection, TTableSortState, TTableRowState } from './TTable.vue';
|
|
96
96
|
export { default as TTag } from './TTag.vue';
|
|
97
97
|
export type { TTagVariant } from './TTag.vue';
|
|
98
98
|
export { default as TTimeline } from './TTimeline.vue';
|