@expcat/tigercat-vue 0.4.0 → 0.4.2
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/{chunk-ZTJTIQZY.mjs → chunk-DEFEAEYE.mjs} +126 -6
- package/dist/{chunk-KUJ75OHX.js → chunk-ESALMEHU.js} +10 -9
- package/dist/{chunk-KVZLGW45.js → chunk-ETTYERGO.js} +14 -5
- package/dist/chunk-HK2TAPQX.js +334 -0
- package/dist/{chunk-YZK2HXRT.js → chunk-LGRUMMOG.js} +2 -2
- package/dist/chunk-LW3LFCRZ.mjs +331 -0
- package/dist/{chunk-ND4XDRYR.mjs → chunk-TCJBN2DA.mjs} +1 -1
- package/dist/{chunk-7FCHU5KV.mjs → chunk-TTDBR2B4.mjs} +11 -10
- package/dist/{chunk-RKPYLBPU.mjs → chunk-WM4ESIHG.mjs} +15 -6
- package/dist/{chunk-3PQIZBT5.js → chunk-WV3Y45YK.js} +125 -5
- package/dist/components/ActivityFeed.d.mts +1 -1
- package/dist/components/ActivityFeed.d.ts +1 -1
- package/dist/components/ActivityFeed.js +4 -4
- package/dist/components/ActivityFeed.mjs +2 -2
- package/dist/components/Alert.d.mts +1 -1
- package/dist/components/Alert.d.ts +1 -1
- package/dist/components/Anchor.d.mts +5 -5
- package/dist/components/Anchor.d.ts +5 -5
- package/dist/components/AnchorLink.d.mts +1 -1
- package/dist/components/AnchorLink.d.ts +1 -1
- package/dist/components/Avatar.d.mts +2 -2
- package/dist/components/Avatar.d.ts +2 -2
- package/dist/components/BackTop.d.mts +1 -1
- package/dist/components/BackTop.d.ts +1 -1
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.d.ts +1 -1
- package/dist/components/Breadcrumb.d.mts +1 -1
- package/dist/components/Breadcrumb.d.ts +1 -1
- package/dist/components/BreadcrumbItem.d.mts +1 -1
- package/dist/components/BreadcrumbItem.d.ts +1 -1
- package/dist/components/Button.d.mts +2 -2
- package/dist/components/Button.d.ts +2 -2
- package/dist/components/Card.d.mts +1 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Carousel.d.mts +2 -2
- package/dist/components/Carousel.d.ts +2 -2
- package/dist/components/ChartAxis.d.mts +1 -1
- package/dist/components/ChartAxis.d.ts +1 -1
- package/dist/components/ChartGrid.d.mts +2 -2
- package/dist/components/ChartGrid.d.ts +2 -2
- package/dist/components/ChartTooltip.d.mts +1 -1
- package/dist/components/ChartTooltip.d.ts +1 -1
- package/dist/components/ChatWindow.d.mts +1 -1
- package/dist/components/ChatWindow.d.ts +1 -1
- package/dist/components/Code.d.mts +1 -1
- package/dist/components/Code.d.ts +1 -1
- package/dist/components/Collapse.d.mts +3 -3
- package/dist/components/Collapse.d.ts +3 -3
- package/dist/components/CollapsePanel.d.mts +2 -2
- package/dist/components/CollapsePanel.d.ts +2 -2
- package/dist/components/CommentThread.d.mts +1 -1
- package/dist/components/CommentThread.d.ts +1 -1
- package/dist/components/Content.d.mts +1 -1
- package/dist/components/Content.d.ts +1 -1
- package/dist/components/CropUpload.d.mts +1 -1
- package/dist/components/CropUpload.d.ts +1 -1
- package/dist/components/DataTableWithToolbar.d.mts +3 -3
- package/dist/components/DataTableWithToolbar.d.ts +3 -3
- package/dist/components/DataTableWithToolbar.js +4 -4
- package/dist/components/DataTableWithToolbar.mjs +2 -2
- package/dist/components/DatePicker.d.mts +1 -1
- package/dist/components/DatePicker.d.ts +1 -1
- package/dist/components/Descriptions.d.mts +1 -1
- package/dist/components/Descriptions.d.ts +1 -1
- package/dist/components/Drawer.d.mts +3 -3
- package/dist/components/Drawer.d.ts +3 -3
- package/dist/components/Dropdown.d.mts +1 -1
- package/dist/components/Dropdown.d.ts +1 -1
- package/dist/components/DropdownItem.d.mts +1 -1
- package/dist/components/DropdownItem.d.ts +1 -1
- package/dist/components/DropdownMenu.d.mts +1 -1
- package/dist/components/DropdownMenu.d.ts +1 -1
- package/dist/components/Footer.d.mts +1 -1
- package/dist/components/Footer.d.ts +1 -1
- package/dist/components/FormWizard.d.mts +3 -3
- package/dist/components/FormWizard.d.ts +3 -3
- package/dist/components/Header.d.mts +1 -1
- package/dist/components/Header.d.ts +1 -1
- package/dist/components/Image.d.mts +1 -1
- package/dist/components/Image.d.ts +1 -1
- package/dist/components/ImageCropper.d.mts +1 -1
- package/dist/components/ImageCropper.d.ts +1 -1
- package/dist/components/Input.d.mts +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/InputNumber.d.mts +170 -0
- package/dist/components/InputNumber.d.ts +170 -0
- package/dist/components/InputNumber.js +17 -0
- package/dist/components/InputNumber.mjs +2 -0
- package/dist/components/Layout.d.mts +1 -1
- package/dist/components/Layout.d.ts +1 -1
- package/dist/components/List.d.mts +2 -2
- package/dist/components/List.d.ts +2 -2
- package/dist/components/Loading.d.mts +2 -2
- package/dist/components/Loading.d.ts +2 -2
- package/dist/components/Menu.d.mts +1 -1
- package/dist/components/Menu.d.ts +1 -1
- package/dist/components/MenuItem.d.mts +1 -1
- package/dist/components/MenuItem.d.ts +1 -1
- package/dist/components/MenuItemGroup.d.mts +1 -1
- package/dist/components/MenuItemGroup.d.ts +1 -1
- package/dist/components/Modal.d.mts +3 -3
- package/dist/components/Modal.d.ts +3 -3
- package/dist/components/NotificationCenter.d.mts +1 -1
- package/dist/components/NotificationCenter.d.ts +1 -1
- package/dist/components/Pagination.d.mts +2 -2
- package/dist/components/Pagination.d.ts +2 -2
- package/dist/components/Popconfirm.d.mts +1 -1
- package/dist/components/Popconfirm.d.ts +1 -1
- package/dist/components/Popover.d.mts +3 -3
- package/dist/components/Popover.d.ts +3 -3
- package/dist/components/Progress.d.mts +4 -4
- package/dist/components/Progress.d.ts +4 -4
- package/dist/components/Select.d.mts +1 -1
- package/dist/components/Select.d.ts +1 -1
- package/dist/components/Sidebar.d.mts +21 -1
- package/dist/components/Sidebar.d.ts +21 -1
- package/dist/components/Sidebar.js +3 -3
- package/dist/components/Sidebar.mjs +1 -1
- package/dist/components/Skeleton.d.mts +1 -1
- package/dist/components/Skeleton.d.ts +1 -1
- package/dist/components/Slider.d.mts +1 -1
- package/dist/components/Slider.d.ts +1 -1
- package/dist/components/Space.d.mts +1 -1
- package/dist/components/Space.d.ts +1 -1
- package/dist/components/Steps.d.mts +2 -2
- package/dist/components/Steps.d.ts +2 -2
- package/dist/components/StepsItem.d.mts +1 -1
- package/dist/components/StepsItem.d.ts +1 -1
- package/dist/components/SubMenu.d.mts +1 -1
- package/dist/components/SubMenu.d.ts +1 -1
- package/dist/components/SubMenu.js +3 -3
- package/dist/components/SubMenu.mjs +1 -1
- package/dist/components/TabPane.d.mts +1 -1
- package/dist/components/TabPane.d.ts +1 -1
- package/dist/components/Table.d.mts +16 -2
- package/dist/components/Table.d.ts +16 -2
- package/dist/components/Table.js +3 -3
- package/dist/components/Table.mjs +1 -1
- package/dist/components/Tabs.d.mts +1 -1
- package/dist/components/Tabs.d.ts +1 -1
- package/dist/components/Tag.d.mts +1 -1
- package/dist/components/Tag.d.ts +1 -1
- package/dist/components/TaskBoard.d.mts +2 -2
- package/dist/components/TaskBoard.d.ts +2 -2
- package/dist/components/Textarea.d.mts +1 -1
- package/dist/components/Textarea.d.ts +1 -1
- package/dist/components/TimePicker.d.mts +2 -2
- package/dist/components/TimePicker.d.ts +2 -2
- package/dist/components/Timeline.d.mts +2 -2
- package/dist/components/Timeline.d.ts +2 -2
- package/dist/components/Tooltip.d.mts +1 -1
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/Upload.d.mts +3 -3
- package/dist/components/Upload.d.ts +3 -3
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +45 -40
- package/dist/index.mjs +12 -11
- package/package.json +2 -2
- package/dist/{chunk-NGW5UMAN.js → chunk-EBTLMVDJ.js} +1 -1
- package/dist/{chunk-D7VMY6WX.mjs → chunk-RVEEEDJQ.mjs} +1 -1
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { defineComponent, ref, watch, computed, onMounted, h } from 'vue';
|
|
2
|
+
import { isAtMin, isAtMax, classNames, getInputNumberWrapperClasses, getInputNumberStatusClasses, getInputNumberSizeClasses, getInputNumberFocusRingColor, coerceClassValue, getInputNumberInputClasses, getInputNumberSideButtonClasses, inputNumberMinusIconPathD, inputNumberPlusIconPathD, inputNumberControlsRightClasses, getInputNumberStepButtonClasses, inputNumberUpIconPathD, inputNumberDownIconPathD, stepValue, clampValue, formatPrecision } from '@expcat/tigercat-core';
|
|
3
|
+
|
|
4
|
+
// src/components/InputNumber.ts
|
|
5
|
+
var InputNumber = defineComponent({
|
|
6
|
+
name: "TigerInputNumber",
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
props: {
|
|
9
|
+
modelValue: {
|
|
10
|
+
type: [Number, null]
|
|
11
|
+
},
|
|
12
|
+
size: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: "md"
|
|
15
|
+
},
|
|
16
|
+
status: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "default"
|
|
19
|
+
},
|
|
20
|
+
min: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: -Infinity
|
|
23
|
+
},
|
|
24
|
+
max: {
|
|
25
|
+
type: Number,
|
|
26
|
+
default: Infinity
|
|
27
|
+
},
|
|
28
|
+
step: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 1
|
|
31
|
+
},
|
|
32
|
+
precision: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: void 0
|
|
35
|
+
},
|
|
36
|
+
disabled: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
readonly: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
placeholder: String,
|
|
45
|
+
name: String,
|
|
46
|
+
id: String,
|
|
47
|
+
keyboard: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: true
|
|
50
|
+
},
|
|
51
|
+
controls: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: true
|
|
54
|
+
},
|
|
55
|
+
controlsPosition: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: "right"
|
|
58
|
+
},
|
|
59
|
+
formatter: {
|
|
60
|
+
type: Function
|
|
61
|
+
},
|
|
62
|
+
parser: {
|
|
63
|
+
type: Function
|
|
64
|
+
},
|
|
65
|
+
autoFocus: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
emits: ["update:modelValue", "change", "focus", "blur"],
|
|
71
|
+
setup(props, { emit, attrs }) {
|
|
72
|
+
const inputRef = ref(null);
|
|
73
|
+
const focused = ref(false);
|
|
74
|
+
const displayValue = ref("");
|
|
75
|
+
function toDisplayValue(val) {
|
|
76
|
+
if (val === null || val === void 0) return "";
|
|
77
|
+
if (props.formatter) return props.formatter(val);
|
|
78
|
+
if (props.precision !== void 0) return val.toFixed(props.precision);
|
|
79
|
+
return String(val);
|
|
80
|
+
}
|
|
81
|
+
function parseValue(str) {
|
|
82
|
+
if (str === "" || str === "-") return null;
|
|
83
|
+
if (props.parser) return props.parser(str);
|
|
84
|
+
const num = Number(str);
|
|
85
|
+
return Number.isNaN(num) ? null : num;
|
|
86
|
+
}
|
|
87
|
+
watch(
|
|
88
|
+
() => props.modelValue,
|
|
89
|
+
(val) => {
|
|
90
|
+
if (!focused.value) {
|
|
91
|
+
displayValue.value = toDisplayValue(val);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{ immediate: true }
|
|
95
|
+
);
|
|
96
|
+
const isControlled = computed(() => props.modelValue !== void 0);
|
|
97
|
+
const internalValue = ref(props.modelValue ?? null);
|
|
98
|
+
const currentValue = computed(
|
|
99
|
+
() => isControlled.value ? props.modelValue ?? null : internalValue.value
|
|
100
|
+
);
|
|
101
|
+
function commitValue(val) {
|
|
102
|
+
let finalVal = val;
|
|
103
|
+
if (finalVal !== null) {
|
|
104
|
+
finalVal = clampValue(finalVal, props.min, props.max);
|
|
105
|
+
if (props.precision !== void 0) {
|
|
106
|
+
finalVal = formatPrecision(finalVal, props.precision);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!isControlled.value) {
|
|
110
|
+
internalValue.value = finalVal;
|
|
111
|
+
}
|
|
112
|
+
emit("update:modelValue", finalVal);
|
|
113
|
+
emit("change", finalVal);
|
|
114
|
+
displayValue.value = toDisplayValue(finalVal);
|
|
115
|
+
}
|
|
116
|
+
function handleStep(direction) {
|
|
117
|
+
if (props.disabled || props.readonly) return;
|
|
118
|
+
const next = stepValue(
|
|
119
|
+
currentValue.value,
|
|
120
|
+
props.step,
|
|
121
|
+
direction,
|
|
122
|
+
props.min,
|
|
123
|
+
props.max,
|
|
124
|
+
props.precision
|
|
125
|
+
);
|
|
126
|
+
commitValue(next);
|
|
127
|
+
}
|
|
128
|
+
function handleInput(e) {
|
|
129
|
+
const target = e.target;
|
|
130
|
+
displayValue.value = target.value;
|
|
131
|
+
}
|
|
132
|
+
function handleBlur(e) {
|
|
133
|
+
focused.value = false;
|
|
134
|
+
const parsed = parseValue(displayValue.value);
|
|
135
|
+
commitValue(parsed);
|
|
136
|
+
emit("blur", e);
|
|
137
|
+
}
|
|
138
|
+
function handleFocus(e) {
|
|
139
|
+
focused.value = true;
|
|
140
|
+
if (props.formatter && currentValue.value !== null) {
|
|
141
|
+
displayValue.value = String(currentValue.value);
|
|
142
|
+
}
|
|
143
|
+
emit("focus", e);
|
|
144
|
+
}
|
|
145
|
+
function handleKeyDown(e) {
|
|
146
|
+
if (!props.keyboard || props.disabled || props.readonly) return;
|
|
147
|
+
if (e.key === "ArrowUp") {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
handleStep("up");
|
|
150
|
+
} else if (e.key === "ArrowDown") {
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
handleStep("down");
|
|
153
|
+
} else if (e.key === "Enter") {
|
|
154
|
+
const parsed = parseValue(displayValue.value);
|
|
155
|
+
commitValue(parsed);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const atMin = computed(() => isAtMin(currentValue.value, props.min));
|
|
159
|
+
const atMax = computed(() => isAtMax(currentValue.value, props.max));
|
|
160
|
+
const wrapperClasses = computed(
|
|
161
|
+
() => classNames(
|
|
162
|
+
getInputNumberWrapperClasses(props.disabled),
|
|
163
|
+
getInputNumberStatusClasses(props.status),
|
|
164
|
+
getInputNumberSizeClasses(props.size),
|
|
165
|
+
focused.value && `ring-2 ${getInputNumberFocusRingColor(props.status)}`,
|
|
166
|
+
coerceClassValue(attrs.class)
|
|
167
|
+
)
|
|
168
|
+
);
|
|
169
|
+
const inputClasses = computed(
|
|
170
|
+
() => getInputNumberInputClasses(
|
|
171
|
+
props.size,
|
|
172
|
+
props.controls && props.controlsPosition === "right",
|
|
173
|
+
props.controls && props.controlsPosition === "both"
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
onMounted(() => {
|
|
177
|
+
if (props.autoFocus && inputRef.value) {
|
|
178
|
+
inputRef.value.focus();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return () => {
|
|
182
|
+
const children = [];
|
|
183
|
+
if (props.controls && props.controlsPosition === "both") {
|
|
184
|
+
children.push(
|
|
185
|
+
h(
|
|
186
|
+
"button",
|
|
187
|
+
{
|
|
188
|
+
type: "button",
|
|
189
|
+
tabindex: -1,
|
|
190
|
+
"aria-label": "Decrease",
|
|
191
|
+
class: getInputNumberSideButtonClasses("left", props.disabled || atMin.value),
|
|
192
|
+
disabled: props.disabled || atMin.value,
|
|
193
|
+
onMousedown: (e) => e.preventDefault(),
|
|
194
|
+
onClick: () => handleStep("down")
|
|
195
|
+
},
|
|
196
|
+
[
|
|
197
|
+
h(
|
|
198
|
+
"svg",
|
|
199
|
+
{
|
|
200
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
201
|
+
viewBox: "0 0 24 24",
|
|
202
|
+
fill: "none",
|
|
203
|
+
stroke: "currentColor",
|
|
204
|
+
"stroke-width": "2",
|
|
205
|
+
class: "w-4 h-4"
|
|
206
|
+
},
|
|
207
|
+
[h("path", { d: inputNumberMinusIconPathD })]
|
|
208
|
+
)
|
|
209
|
+
]
|
|
210
|
+
)
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
children.push(
|
|
214
|
+
h("input", {
|
|
215
|
+
ref: inputRef,
|
|
216
|
+
type: "text",
|
|
217
|
+
inputmode: "decimal",
|
|
218
|
+
role: "spinbutton",
|
|
219
|
+
"aria-valuemin": props.min === -Infinity ? void 0 : props.min,
|
|
220
|
+
"aria-valuemax": props.max === Infinity ? void 0 : props.max,
|
|
221
|
+
"aria-valuenow": currentValue.value ?? void 0,
|
|
222
|
+
class: inputClasses.value,
|
|
223
|
+
value: displayValue.value,
|
|
224
|
+
placeholder: props.placeholder,
|
|
225
|
+
disabled: props.disabled,
|
|
226
|
+
readonly: props.readonly,
|
|
227
|
+
name: props.name,
|
|
228
|
+
id: props.id,
|
|
229
|
+
onInput: handleInput,
|
|
230
|
+
onBlur: handleBlur,
|
|
231
|
+
onFocus: handleFocus,
|
|
232
|
+
onKeydown: handleKeyDown
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
if (props.controls && props.controlsPosition === "both") {
|
|
236
|
+
children.push(
|
|
237
|
+
h(
|
|
238
|
+
"button",
|
|
239
|
+
{
|
|
240
|
+
type: "button",
|
|
241
|
+
tabindex: -1,
|
|
242
|
+
"aria-label": "Increase",
|
|
243
|
+
class: getInputNumberSideButtonClasses("right", props.disabled || atMax.value),
|
|
244
|
+
disabled: props.disabled || atMax.value,
|
|
245
|
+
onMousedown: (e) => e.preventDefault(),
|
|
246
|
+
onClick: () => handleStep("up")
|
|
247
|
+
},
|
|
248
|
+
[
|
|
249
|
+
h(
|
|
250
|
+
"svg",
|
|
251
|
+
{
|
|
252
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
253
|
+
viewBox: "0 0 24 24",
|
|
254
|
+
fill: "none",
|
|
255
|
+
stroke: "currentColor",
|
|
256
|
+
"stroke-width": "2",
|
|
257
|
+
class: "w-4 h-4"
|
|
258
|
+
},
|
|
259
|
+
[h("path", { d: inputNumberPlusIconPathD })]
|
|
260
|
+
)
|
|
261
|
+
]
|
|
262
|
+
)
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
if (props.controls && props.controlsPosition === "right") {
|
|
266
|
+
children.push(
|
|
267
|
+
h("div", { class: inputNumberControlsRightClasses }, [
|
|
268
|
+
h(
|
|
269
|
+
"button",
|
|
270
|
+
{
|
|
271
|
+
type: "button",
|
|
272
|
+
tabindex: -1,
|
|
273
|
+
"aria-label": "Increase",
|
|
274
|
+
class: getInputNumberStepButtonClasses("up", props.disabled || atMax.value),
|
|
275
|
+
disabled: props.disabled || atMax.value,
|
|
276
|
+
onMousedown: (e) => e.preventDefault(),
|
|
277
|
+
onClick: () => handleStep("up")
|
|
278
|
+
},
|
|
279
|
+
[
|
|
280
|
+
h(
|
|
281
|
+
"svg",
|
|
282
|
+
{
|
|
283
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
284
|
+
viewBox: "0 0 24 24",
|
|
285
|
+
fill: "currentColor",
|
|
286
|
+
class: "w-3 h-3"
|
|
287
|
+
},
|
|
288
|
+
[h("path", { d: inputNumberUpIconPathD })]
|
|
289
|
+
)
|
|
290
|
+
]
|
|
291
|
+
),
|
|
292
|
+
h(
|
|
293
|
+
"button",
|
|
294
|
+
{
|
|
295
|
+
type: "button",
|
|
296
|
+
tabindex: -1,
|
|
297
|
+
"aria-label": "Decrease",
|
|
298
|
+
class: getInputNumberStepButtonClasses("down", props.disabled || atMin.value),
|
|
299
|
+
disabled: props.disabled || atMin.value,
|
|
300
|
+
onMousedown: (e) => e.preventDefault(),
|
|
301
|
+
onClick: () => handleStep("down")
|
|
302
|
+
},
|
|
303
|
+
[
|
|
304
|
+
h(
|
|
305
|
+
"svg",
|
|
306
|
+
{
|
|
307
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
308
|
+
viewBox: "0 0 24 24",
|
|
309
|
+
fill: "currentColor",
|
|
310
|
+
class: "w-3 h-3"
|
|
311
|
+
},
|
|
312
|
+
[h("path", { d: inputNumberDownIconPathD })]
|
|
313
|
+
)
|
|
314
|
+
]
|
|
315
|
+
)
|
|
316
|
+
])
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
return h(
|
|
320
|
+
"div",
|
|
321
|
+
{
|
|
322
|
+
class: wrapperClasses.value
|
|
323
|
+
},
|
|
324
|
+
children
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
var InputNumber_default = InputNumber;
|
|
330
|
+
|
|
331
|
+
export { InputNumber, InputNumber_default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MenuContextKey } from './chunk-3AM6WEUE.mjs';
|
|
2
2
|
import { defineComponent, inject, computed, ref, h, Transition, isVNode, cloneVNode, nextTick } from 'vue';
|
|
3
|
-
import { isKeyOpen, classNames, getSubMenuTitleClasses, coerceClassValue, mergeStyleValues, submenuContentHorizontalClasses, submenuContentPopupClasses, submenuContentInlineClasses, submenuContentVerticalClasses, getMenuItemIndent, menuItemIconClasses, getSubMenuExpandIconClasses, moveFocusInMenu, focusMenuEdge, focusFirstChildItem } from '@expcat/tigercat-core';
|
|
3
|
+
import { isKeyOpen, classNames, getSubMenuTitleClasses, coerceClassValue, mergeStyleValues, submenuContentHorizontalClasses, submenuContentHorizontalNestedClasses, submenuContentPopupClasses, submenuContentInlineClasses, submenuContentVerticalClasses, getSubmenuPopupZIndex, getMenuItemIndent, menuItemIconClasses, getSubMenuExpandIconClasses, moveFocusInMenu, focusMenuEdge, focusFirstChildItem } from '@expcat/tigercat-core';
|
|
4
4
|
|
|
5
5
|
var ExpandIcon = (expanded) => {
|
|
6
6
|
return h(
|
|
@@ -85,7 +85,9 @@ var SubMenu = defineComponent({
|
|
|
85
85
|
return props.collapsed ?? (menuContext ? menuContext.collapsed.value : false);
|
|
86
86
|
});
|
|
87
87
|
const isPopup = computed(() => {
|
|
88
|
-
|
|
88
|
+
if (!menuContext) return false;
|
|
89
|
+
if (menuContext.mode.value === "horizontal") return true;
|
|
90
|
+
return menuContext.mode.value === "vertical" && effectiveCollapsed.value;
|
|
89
91
|
});
|
|
90
92
|
const isExpanded = computed(() => {
|
|
91
93
|
if (menuContext?.mode.value === "horizontal" || isPopup.value) {
|
|
@@ -109,12 +111,13 @@ var SubMenu = defineComponent({
|
|
|
109
111
|
const contentClasses = computed(() => {
|
|
110
112
|
if (!menuContext) return "";
|
|
111
113
|
if (menuContext.mode.value === "horizontal") {
|
|
112
|
-
return submenuContentHorizontalClasses;
|
|
114
|
+
return props.level === 0 ? submenuContentHorizontalClasses : submenuContentHorizontalNestedClasses;
|
|
113
115
|
}
|
|
114
116
|
if (isPopup.value) return submenuContentPopupClasses;
|
|
115
117
|
if (menuContext.mode.value === "inline") return submenuContentInlineClasses;
|
|
116
118
|
return submenuContentVerticalClasses;
|
|
117
119
|
});
|
|
120
|
+
const popupZIndex = computed(() => isPopup.value ? getSubmenuPopupZIndex(props.level) : {});
|
|
118
121
|
const handleTitleClick = () => {
|
|
119
122
|
if (!menuContext || props.disabled) return;
|
|
120
123
|
if (menuContext.mode.value === "horizontal") return;
|
|
@@ -206,7 +209,7 @@ var SubMenu = defineComponent({
|
|
|
206
209
|
}
|
|
207
210
|
};
|
|
208
211
|
const indentStyle = computed(() => {
|
|
209
|
-
if (!menuContext || menuContext.mode.value
|
|
212
|
+
if (!menuContext || menuContext.mode.value === "horizontal" || props.level === 0) {
|
|
210
213
|
return {};
|
|
211
214
|
}
|
|
212
215
|
return getMenuItemIndent(props.level, menuContext.inlineIndent.value);
|
|
@@ -224,9 +227,6 @@ var SubMenu = defineComponent({
|
|
|
224
227
|
const nextProps = {
|
|
225
228
|
level: existingProps.level ?? nextLevel
|
|
226
229
|
};
|
|
227
|
-
if (isPopup.value) {
|
|
228
|
-
nextProps.collapsed = false;
|
|
229
|
-
}
|
|
230
230
|
return cloneVNode(node, nextProps);
|
|
231
231
|
});
|
|
232
232
|
};
|
|
@@ -274,12 +274,13 @@ var SubMenu = defineComponent({
|
|
|
274
274
|
},
|
|
275
275
|
titleChildren
|
|
276
276
|
);
|
|
277
|
-
const contentNode =
|
|
277
|
+
const contentNode = isPopup.value ? h(
|
|
278
278
|
"ul",
|
|
279
279
|
{
|
|
280
280
|
class: contentClasses.value,
|
|
281
281
|
style: {
|
|
282
|
-
display: isExpanded.value ? "block" : "none"
|
|
282
|
+
display: isExpanded.value ? "block" : "none",
|
|
283
|
+
...popupZIndex.value
|
|
283
284
|
},
|
|
284
285
|
role: "menu",
|
|
285
286
|
"aria-hidden": isExpanded.value ? void 0 : "true"
|
|
@@ -324,7 +325,7 @@ var SubMenu = defineComponent({
|
|
|
324
325
|
return h(
|
|
325
326
|
"li",
|
|
326
327
|
{
|
|
327
|
-
class:
|
|
328
|
+
class: isPopup.value ? "relative" : "",
|
|
328
329
|
onMouseenter: handleMouseEnter,
|
|
329
330
|
onMouseleave: handleMouseLeave,
|
|
330
331
|
role: "none"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, computed, h } from 'vue';
|
|
2
|
-
import { classNames, layoutSidebarClasses, coerceClassValue, mergeStyleValues } from '@expcat/tigercat-core';
|
|
2
|
+
import { classNames, layoutSidebarClasses, layoutSidebarCollapsedClasses, coerceClassValue, getSidebarStyle, mergeStyleValues } from '@expcat/tigercat-core';
|
|
3
3
|
|
|
4
4
|
// src/components/Sidebar.ts
|
|
5
5
|
var Sidebar = defineComponent({
|
|
@@ -21,6 +21,15 @@ var Sidebar = defineComponent({
|
|
|
21
21
|
type: String,
|
|
22
22
|
default: "256px"
|
|
23
23
|
},
|
|
24
|
+
/**
|
|
25
|
+
* Width when collapsed (mini mode).
|
|
26
|
+
* Set to '0px' to fully hide the sidebar when collapsed.
|
|
27
|
+
* @default '64px'
|
|
28
|
+
*/
|
|
29
|
+
collapsedWidth: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "64px"
|
|
32
|
+
},
|
|
24
33
|
/**
|
|
25
34
|
* Whether the sidebar is collapsed
|
|
26
35
|
* @default false
|
|
@@ -41,14 +50,14 @@ var Sidebar = defineComponent({
|
|
|
41
50
|
const sidebarClasses = computed(
|
|
42
51
|
() => classNames(
|
|
43
52
|
layoutSidebarClasses,
|
|
53
|
+
props.collapsed && layoutSidebarCollapsedClasses,
|
|
44
54
|
props.className,
|
|
45
55
|
coerceClassValue(attrs.class)
|
|
46
56
|
)
|
|
47
57
|
);
|
|
48
|
-
const sidebarStyle = computed(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}));
|
|
58
|
+
const sidebarStyle = computed(
|
|
59
|
+
() => getSidebarStyle(props.collapsed, props.width, props.collapsedWidth)
|
|
60
|
+
);
|
|
52
61
|
return () => h(
|
|
53
62
|
"aside",
|
|
54
63
|
{
|
|
@@ -56,7 +65,7 @@ var Sidebar = defineComponent({
|
|
|
56
65
|
class: sidebarClasses.value,
|
|
57
66
|
style: mergeStyleValues(props.style, sidebarStyle.value)
|
|
58
67
|
},
|
|
59
|
-
|
|
68
|
+
slots.default?.()
|
|
60
69
|
);
|
|
61
70
|
}
|
|
62
71
|
});
|
|
@@ -160,6 +160,12 @@ var Table = vue.defineComponent({
|
|
|
160
160
|
rowSelection: {
|
|
161
161
|
type: Object
|
|
162
162
|
},
|
|
163
|
+
/**
|
|
164
|
+
* Row expansion configuration
|
|
165
|
+
*/
|
|
166
|
+
expandable: {
|
|
167
|
+
type: Object
|
|
168
|
+
},
|
|
163
169
|
/**
|
|
164
170
|
* Function to get row key
|
|
165
171
|
*/
|
|
@@ -194,7 +200,15 @@ var Table = vue.defineComponent({
|
|
|
194
200
|
default: "auto"
|
|
195
201
|
}
|
|
196
202
|
},
|
|
197
|
-
emits: [
|
|
203
|
+
emits: [
|
|
204
|
+
"change",
|
|
205
|
+
"row-click",
|
|
206
|
+
"selection-change",
|
|
207
|
+
"sort-change",
|
|
208
|
+
"filter-change",
|
|
209
|
+
"page-change",
|
|
210
|
+
"expanded-rows-change"
|
|
211
|
+
],
|
|
198
212
|
setup(props, { emit, slots }) {
|
|
199
213
|
const paginationConfig = vue.computed(() => {
|
|
200
214
|
return props.pagination !== false && typeof props.pagination === "object" ? props.pagination : null;
|
|
@@ -204,6 +218,7 @@ var Table = vue.defineComponent({
|
|
|
204
218
|
vue.computed(() => paginationConfig.value?.current !== void 0);
|
|
205
219
|
vue.computed(() => paginationConfig.value?.pageSize !== void 0);
|
|
206
220
|
const isSelectionControlled = vue.computed(() => props.rowSelection?.selectedRowKeys !== void 0);
|
|
221
|
+
const isExpandControlled = vue.computed(() => props.expandable?.expandedRowKeys !== void 0);
|
|
207
222
|
const uncontrolledSortState = vue.ref(props.defaultSort);
|
|
208
223
|
const uncontrolledFilterState = vue.ref(props.defaultFilters);
|
|
209
224
|
const uncontrolledCurrentPage = vue.ref(
|
|
@@ -215,6 +230,9 @@ var Table = vue.defineComponent({
|
|
|
215
230
|
const uncontrolledSelectedRowKeys = vue.ref(
|
|
216
231
|
props.rowSelection?.defaultSelectedRowKeys ?? props.rowSelection?.selectedRowKeys ?? []
|
|
217
232
|
);
|
|
233
|
+
const uncontrolledExpandedRowKeys = vue.ref(
|
|
234
|
+
props.expandable?.defaultExpandedRowKeys ?? props.expandable?.expandedRowKeys ?? []
|
|
235
|
+
);
|
|
218
236
|
const sortState = vue.computed(() => props.sort ?? uncontrolledSortState.value);
|
|
219
237
|
const filterState = vue.computed(() => props.filters ?? uncontrolledFilterState.value);
|
|
220
238
|
const currentPage = vue.computed(() => {
|
|
@@ -226,6 +244,10 @@ var Table = vue.defineComponent({
|
|
|
226
244
|
const selectedRowKeys = vue.computed(() => {
|
|
227
245
|
return props.rowSelection?.selectedRowKeys ?? uncontrolledSelectedRowKeys.value;
|
|
228
246
|
});
|
|
247
|
+
const expandedRowKeys = vue.computed(() => {
|
|
248
|
+
return props.expandable?.expandedRowKeys ?? uncontrolledExpandedRowKeys.value;
|
|
249
|
+
});
|
|
250
|
+
const expandedRowKeySet = vue.computed(() => new Set(expandedRowKeys.value));
|
|
229
251
|
vue.watch(
|
|
230
252
|
() => props.sort,
|
|
231
253
|
(next) => {
|
|
@@ -437,8 +459,25 @@ var Table = vue.defineComponent({
|
|
|
437
459
|
const someSelected = vue.computed(() => {
|
|
438
460
|
return selectedRowKeys.value.length > 0 && !allSelected.value;
|
|
439
461
|
});
|
|
462
|
+
function handleToggleExpand(key) {
|
|
463
|
+
const isExp = expandedRowKeySet.value.has(key);
|
|
464
|
+
const next = isExp ? expandedRowKeys.value.filter((k) => k !== key) : [...expandedRowKeys.value, key];
|
|
465
|
+
if (!isExpandControlled.value) {
|
|
466
|
+
uncontrolledExpandedRowKeys.value = next;
|
|
467
|
+
}
|
|
468
|
+
emit("expanded-rows-change", next);
|
|
469
|
+
}
|
|
470
|
+
const totalColumnCount = vue.computed(() => {
|
|
471
|
+
let count = displayColumns.value.length;
|
|
472
|
+
if (props.rowSelection && props.rowSelection.showCheckbox !== false) count++;
|
|
473
|
+
if (props.expandable) count++;
|
|
474
|
+
return count;
|
|
475
|
+
});
|
|
440
476
|
function renderTableHeader() {
|
|
441
477
|
const headerCells = [];
|
|
478
|
+
if (props.expandable && props.expandable.expandIconPosition !== "end") {
|
|
479
|
+
headerCells.push(vue.h("th", { class: tigercatCore.getExpandCellClasses(props.size) }));
|
|
480
|
+
}
|
|
442
481
|
if (props.rowSelection && props.rowSelection.showCheckbox !== false && props.rowSelection.type !== "radio") {
|
|
443
482
|
headerCells.push(
|
|
444
483
|
vue.h(
|
|
@@ -558,6 +597,9 @@ var Table = vue.defineComponent({
|
|
|
558
597
|
)
|
|
559
598
|
);
|
|
560
599
|
});
|
|
600
|
+
if (props.expandable && props.expandable.expandIconPosition === "end") {
|
|
601
|
+
headerCells.push(vue.h("th", { class: tigercatCore.getExpandCellClasses(props.size) }));
|
|
602
|
+
}
|
|
561
603
|
return vue.h("thead", { class: tigercatCore.getTableHeaderClasses(props.stickyHeader) }, [
|
|
562
604
|
vue.h("tr", headerCells)
|
|
563
605
|
]);
|
|
@@ -572,7 +614,7 @@ var Table = vue.defineComponent({
|
|
|
572
614
|
vue.h(
|
|
573
615
|
"td",
|
|
574
616
|
{
|
|
575
|
-
colspan:
|
|
617
|
+
colspan: totalColumnCount.value,
|
|
576
618
|
class: tigercatCore.tableEmptyStateClasses
|
|
577
619
|
},
|
|
578
620
|
[
|
|
@@ -589,11 +631,45 @@ var Table = vue.defineComponent({
|
|
|
589
631
|
])
|
|
590
632
|
]);
|
|
591
633
|
}
|
|
592
|
-
const rows = paginatedData.value.
|
|
634
|
+
const rows = paginatedData.value.flatMap((record, index) => {
|
|
593
635
|
const key = paginatedRowKeys.value[index];
|
|
594
636
|
const isSelected = selectedRowKeySet.value.has(key);
|
|
637
|
+
const isExpanded = expandedRowKeySet.value.has(key);
|
|
638
|
+
const isExpandable = props.expandable ? props.expandable.rowExpandable?.(record) ?? true : false;
|
|
595
639
|
const rowClass = typeof props.rowClassName === "function" ? props.rowClassName(record, index) : props.rowClassName;
|
|
596
640
|
const cells = [];
|
|
641
|
+
if (props.expandable && props.expandable.expandIconPosition !== "end") {
|
|
642
|
+
cells.push(
|
|
643
|
+
vue.h("td", { class: tigercatCore.getExpandCellClasses(props.size) }, [
|
|
644
|
+
isExpandable ? vue.h(
|
|
645
|
+
"button",
|
|
646
|
+
{
|
|
647
|
+
class: tigercatCore.classNames(
|
|
648
|
+
tigercatCore.expandIconButtonClasses,
|
|
649
|
+
tigercatCore.getExpandIconRotationClasses(isExpanded)
|
|
650
|
+
),
|
|
651
|
+
"aria-label": isExpanded ? "Collapse row" : "Expand row",
|
|
652
|
+
onClick: (e) => {
|
|
653
|
+
e.stopPropagation();
|
|
654
|
+
handleToggleExpand(key);
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
[
|
|
658
|
+
vue.h(
|
|
659
|
+
"svg",
|
|
660
|
+
tigercatCore.normalizeSvgAttrs({
|
|
661
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
662
|
+
viewBox: tigercatCore.icon16ViewBox,
|
|
663
|
+
fill: "currentColor",
|
|
664
|
+
class: "w-4 h-4"
|
|
665
|
+
}),
|
|
666
|
+
[vue.h("path", { d: "M6 3l6 5-6 5V3z" })]
|
|
667
|
+
)
|
|
668
|
+
]
|
|
669
|
+
) : null
|
|
670
|
+
])
|
|
671
|
+
);
|
|
672
|
+
}
|
|
597
673
|
if (props.rowSelection && props.rowSelection.showCheckbox !== false) {
|
|
598
674
|
const checkboxProps = props.rowSelection?.getCheckboxProps?.(record) || {};
|
|
599
675
|
cells.push(
|
|
@@ -608,6 +684,7 @@ var Table = vue.defineComponent({
|
|
|
608
684
|
class: props.rowSelection?.type === "radio" ? "border-gray-300 text-[var(--tiger-primary,#2563eb)] focus:ring-[var(--tiger-primary,#2563eb)]" : "rounded border-gray-300 text-[var(--tiger-primary,#2563eb)] focus:ring-[var(--tiger-primary,#2563eb)]",
|
|
609
685
|
checked: isSelected,
|
|
610
686
|
disabled: checkboxProps.disabled,
|
|
687
|
+
onClick: (e) => e.stopPropagation(),
|
|
611
688
|
onChange: (e) => handleSelectRow(key, e.target.checked)
|
|
612
689
|
})
|
|
613
690
|
]
|
|
@@ -649,12 +726,44 @@ var Table = vue.defineComponent({
|
|
|
649
726
|
style
|
|
650
727
|
},
|
|
651
728
|
[
|
|
652
|
-
|
|
729
|
+
slots[`cell-${column.key}`]?.({ record, index }) ?? (column.render ? column.render(record, index) : cellValue)
|
|
653
730
|
]
|
|
654
731
|
)
|
|
655
732
|
);
|
|
656
733
|
});
|
|
657
|
-
|
|
734
|
+
if (props.expandable && props.expandable.expandIconPosition === "end") {
|
|
735
|
+
cells.push(
|
|
736
|
+
vue.h("td", { class: tigercatCore.getExpandCellClasses(props.size) }, [
|
|
737
|
+
isExpandable ? vue.h(
|
|
738
|
+
"button",
|
|
739
|
+
{
|
|
740
|
+
class: tigercatCore.classNames(
|
|
741
|
+
tigercatCore.expandIconButtonClasses,
|
|
742
|
+
tigercatCore.getExpandIconRotationClasses(isExpanded)
|
|
743
|
+
),
|
|
744
|
+
"aria-label": isExpanded ? "Collapse row" : "Expand row",
|
|
745
|
+
onClick: (e) => {
|
|
746
|
+
e.stopPropagation();
|
|
747
|
+
handleToggleExpand(key);
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
[
|
|
751
|
+
vue.h(
|
|
752
|
+
"svg",
|
|
753
|
+
tigercatCore.normalizeSvgAttrs({
|
|
754
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
755
|
+
viewBox: tigercatCore.icon16ViewBox,
|
|
756
|
+
fill: "currentColor",
|
|
757
|
+
class: "w-4 h-4"
|
|
758
|
+
}),
|
|
759
|
+
[vue.h("path", { d: "M6 3l6 5-6 5V3z" })]
|
|
760
|
+
)
|
|
761
|
+
]
|
|
762
|
+
) : null
|
|
763
|
+
])
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
const row = vue.h(
|
|
658
767
|
"tr",
|
|
659
768
|
{
|
|
660
769
|
key,
|
|
@@ -666,6 +775,17 @@ var Table = vue.defineComponent({
|
|
|
666
775
|
},
|
|
667
776
|
cells
|
|
668
777
|
);
|
|
778
|
+
const result = [row];
|
|
779
|
+
if (props.expandable && isExpanded && isExpandable) {
|
|
780
|
+
result.push(
|
|
781
|
+
vue.h("tr", { key: `${key}-expanded`, class: tigercatCore.expandedRowContentClasses }, [
|
|
782
|
+
vue.h("td", { colspan: totalColumnCount.value }, [
|
|
783
|
+
props.expandable.expandedRowRender(record, index)
|
|
784
|
+
])
|
|
785
|
+
])
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
return result;
|
|
669
789
|
});
|
|
670
790
|
return vue.h("tbody", rows);
|
|
671
791
|
}
|
|
@@ -107,9 +107,9 @@ declare const ActivityFeed: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
107
107
|
default: undefined;
|
|
108
108
|
};
|
|
109
109
|
}>> & Readonly<{}>, {
|
|
110
|
-
className: string;
|
|
111
110
|
style: Record<string, string | number>;
|
|
112
111
|
loading: boolean;
|
|
112
|
+
className: string;
|
|
113
113
|
emptyText: string;
|
|
114
114
|
items: ActivityItem[];
|
|
115
115
|
groups: ActivityGroup[];
|