@plexui/vue 0.21.0 → 0.23.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/es/components/Alert/Alert.js +16 -4
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorPicker.js +13 -9
- package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorWell.js +5 -3
- package/dist/es/components/ColorPicker/ColorWell.js.map +1 -1
- package/dist/es/components/ColorPicker/shared.js +5 -4
- package/dist/es/components/ColorPicker/shared.js.map +1 -1
- package/dist/es/components/ContextMenu/ContextMenu.js +9 -9
- package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/es/components/ContextMenu/shared.js +25 -5
- package/dist/es/components/ContextMenu/shared.js.map +1 -1
- package/dist/es/components/DataTable/columnHelpers.js +88 -6
- package/dist/es/components/DataTable/columnHelpers.js.map +1 -1
- package/dist/es/components/DatePicker/DatePicker.js +3 -3
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DatePicker/useCalendarCollisionPadding.js +25 -0
- package/dist/es/components/DatePicker/useCalendarCollisionPadding.js.map +1 -0
- package/dist/es/components/DateRangePicker/DateRangePicker.js +3 -3
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +2 -2
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Input/Input.js +3 -0
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +10 -1
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/PhoneLayout/PhoneLayout.js +9 -1
- package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -1
- package/dist/es/components/Popover/Popover.js +2 -2
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/ProgressSteps/ProgressSteps.js +7 -3
- package/dist/es/components/ProgressSteps/ProgressSteps.js.map +1 -1
- package/dist/es/components/ProgressSteps/index.js.map +1 -1
- package/dist/es/components/Select/Select.js +178 -32
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +3 -1
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +24 -11
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Slider/sliderPrimitive.js +5 -2
- package/dist/es/components/Slider/sliderPrimitive.js.map +1 -1
- package/dist/es/components/Sortable/Sortable.js +1 -1
- package/dist/es/components/Sortable/Sortable.js.map +1 -1
- package/dist/es/components/StatCard/index.js +4 -1
- package/dist/es/components/StatCard/index.js.map +1 -1
- package/dist/es/components/{StatCard/StatCard.js → StatsCard/StatsCard.js} +32 -27
- package/dist/es/components/StatsCard/StatsCard.js.map +1 -0
- package/dist/es/components/StatsCard/index.js +2 -0
- package/dist/es/components/StatsCard/index.js.map +1 -0
- package/dist/es/components/SwipeActions/SwipeActions.js +32 -5
- package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -1
- package/dist/es/components/TabBar/TabBar.js +52 -21
- package/dist/es/components/TabBar/TabBar.js.map +1 -1
- package/dist/es/components/Tabs/Tabs.js +229 -6
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/lib/menuTriggerCover.js +40 -3
- package/dist/es/lib/menuTriggerCover.js.map +1 -1
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +3 -2
- package/dist/types/components/ColorPicker/shared.d.ts +5 -4
- package/dist/types/components/ContextMenu/shared.d.ts +28 -6
- package/dist/types/components/DatePicker/useCalendarCollisionPadding.d.ts +9 -0
- package/dist/types/components/Dialog/Dialog.d.ts +2 -2
- package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +5 -0
- package/dist/types/components/Popover/Popover.d.ts +5 -5
- package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +17 -3
- package/dist/types/components/ProgressSteps/index.d.ts +1 -1
- package/dist/types/components/Select/Select.d.ts +19 -8
- package/dist/types/components/StatCard/index.d.ts +9 -1
- package/dist/types/components/{StatCard/StatCard.d.ts → StatsCard/StatsCard.d.ts} +19 -19
- package/dist/types/components/StatsCard/index.d.ts +1 -0
- package/dist/types/components/SwipeActions/SwipeActions.d.ts +4 -4
- package/dist/types/components/TabBar/TabBar.d.ts +34 -0
- package/dist/types/components/Tabs/Tabs.d.ts +33 -2
- package/dist/types/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/lib/menuTriggerCover.d.ts +16 -2
- package/package.json +2 -2
- package/dist/es/components/DatePicker/useCalendarGutter.js +0 -14
- package/dist/es/components/DatePicker/useCalendarGutter.js.map +0 -1
- package/dist/es/components/StatCard/StatCard.js.map +0 -1
- package/dist/types/components/DatePicker/useCalendarGutter.d.ts +0 -2
|
@@ -32,7 +32,11 @@ const tabsProps = {
|
|
|
32
32
|
variant: { type: String, default: "segmented" },
|
|
33
33
|
/** Orientation of the tab layout. @default "horizontal" */
|
|
34
34
|
orientation: { type: String, default: "horizontal" },
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Controls the size of the tabs, `3xs` (22px) to `3xl` (48px). On a phone horizontal tabs take the two sizes of
|
|
37
|
+
* the iOS 27 segmented control: `sm` and smaller the small 32px one, `md` and larger the large 48px one (49px with
|
|
38
|
+
* `mobileMaterial="flat"`). @default "md"
|
|
39
|
+
*/
|
|
36
40
|
size: { type: String, default: "md" },
|
|
37
41
|
/** Controls gutter on the edges of the tabs, defaults to value from `size`. */
|
|
38
42
|
gutterSize: String,
|
|
@@ -48,6 +52,14 @@ const tabsProps = {
|
|
|
48
52
|
* @default false
|
|
49
53
|
*/
|
|
50
54
|
flush: { type: Boolean, default: false },
|
|
55
|
+
/**
|
|
56
|
+
* Phone surface of horizontal tabs. On a phone the large control (`md` and larger) is the glass capsule of iOS 27
|
|
57
|
+
* apps and the small one (`sm` and smaller) the plain capsule of SwiftUI's segmented Picker; `flat` gives the large
|
|
58
|
+
* one the plain look of SwiftUI's `.controlSize(.large)`, and `glass` gives the small one `.glassEffect()`, like the
|
|
59
|
+
* Button prop of the same name. Inside a phone Toolbar the control is the large glass one anyway. Desktop keeps the
|
|
60
|
+
* chosen variant. @default "glass" at md and larger, "flat" at sm and smaller
|
|
61
|
+
*/
|
|
62
|
+
mobileMaterial: { type: String, default: undefined },
|
|
51
63
|
};
|
|
52
64
|
const tabsEmits = {
|
|
53
65
|
/** A new value was selected (`v-model:value`) */
|
|
@@ -59,6 +71,175 @@ const tabsEmits = {
|
|
|
59
71
|
};
|
|
60
72
|
// The group itself. `Tabs` renders it as it is, or measures and splits it
|
|
61
73
|
// for `overflow="menu"`
|
|
74
|
+
/** On a phone the large control's selection travels as a lens of glass, as iOS 27.2 draws it. Recorded frame by frame
|
|
75
|
+
* 11.11 (ref-app segmented-bar-text4, a toolbar Picker of Day, Week, Month and Year switched Day to Year and back,
|
|
76
|
+
* after the owner's «анимация не правильная и стиль» and «day<->year пробуй переключать»; segmented-bar-symbols, a
|
|
77
|
+
* segment away, before it): the gray selection clears into a lens within 45ms, taller than the capsule (11pt) and
|
|
78
|
+
* wider the faster it goes (36pt at 200ms), and carries across; it lands as the gray selection again by 300ms,
|
|
79
|
+
* pressed against its segment's far side (7pt narrower, 6pt taller and its centre 2.5% of the way past at 430ms), and
|
|
80
|
+
* springs back by 750ms while the label under it dims to 76% and comes back. The centre's path is a share of the
|
|
81
|
+
* distance and the growth is in points, as both recordings show: as much growth a segment away as three. touch.css
|
|
82
|
+
* names the lens's growth on the large control only, so everywhere else the selection just slides with its
|
|
83
|
+
* transition. CSS has no refraction, so the lens is its rim, its tint and the capsule's edge seen through it. */
|
|
84
|
+
let lensRun = 0;
|
|
85
|
+
const LENS_ID = "segmented-control-lens";
|
|
86
|
+
const LENS_DURATION = 750;
|
|
87
|
+
// At each measured frame: [ms, the centre's share of the distance, share of the growth's width, share of its height]
|
|
88
|
+
const LENS_PATH = [
|
|
89
|
+
[0, 0, 0, 0],
|
|
90
|
+
[10, 0.014, 0.036, 0.065],
|
|
91
|
+
[32, 0.077, 0.13, 0.19],
|
|
92
|
+
[47, 0.169, 0.22, 0.44],
|
|
93
|
+
[70, 0.378, 0.44, 0.87],
|
|
94
|
+
[92, 0.478, 0.52, 1],
|
|
95
|
+
[125, 0.647, 0.7, 0.93],
|
|
96
|
+
[150, 0.773, 0.85, 0.87],
|
|
97
|
+
[182, 0.856, 0.96, 0.93],
|
|
98
|
+
[205, 0.9, 1, 1],
|
|
99
|
+
[227, 0.932, 0.96, 0.93],
|
|
100
|
+
[245, 0.951, 0.8, 0.44],
|
|
101
|
+
[262, 0.964, 0.67, 0.31],
|
|
102
|
+
[295, 0.989, 0.37, 0.31],
|
|
103
|
+
[330, 1.005, 0.13, 0.31],
|
|
104
|
+
[363, 1.016, -0.02, 0.37],
|
|
105
|
+
[395, 1.023, -0.13, 0.5],
|
|
106
|
+
[430, 1.025, -0.19, 0.56],
|
|
107
|
+
[497, 1.022, -0.19, 0.56],
|
|
108
|
+
[545, 1.018, -0.17, 0.37],
|
|
109
|
+
[597, 1.014, -0.11, 0.25],
|
|
110
|
+
[647, 1.007, -0.075, 0.12],
|
|
111
|
+
[697, 1.004, -0.036, 0],
|
|
112
|
+
[750, 1, 0, 0],
|
|
113
|
+
];
|
|
114
|
+
// The selected label's opacity as the lens lands: [ms, opacity]
|
|
115
|
+
const LENS_LABEL = [
|
|
116
|
+
[0, 1],
|
|
117
|
+
[380, 1],
|
|
118
|
+
[428, 0.77],
|
|
119
|
+
[460, 0.76],
|
|
120
|
+
[515, 0.85],
|
|
121
|
+
[580, 0.93],
|
|
122
|
+
[650, 0.98],
|
|
123
|
+
[713, 1],
|
|
124
|
+
[750, 1],
|
|
125
|
+
];
|
|
126
|
+
const lensRuns = new WeakMap();
|
|
127
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
128
|
+
// The box the lens draws at a time of its run
|
|
129
|
+
const lensBox = ({ from, to }, ms, growth) => {
|
|
130
|
+
const next = LENS_PATH.findIndex(([time]) => time >= ms);
|
|
131
|
+
const at = next < 0 ? LENS_PATH.length - 1 : Math.max(1, next);
|
|
132
|
+
const [t0, share0, wide0] = LENS_PATH[at - 1];
|
|
133
|
+
const [t1, share1, wide1] = LENS_PATH[Math.min(at, LENS_PATH.length - 1)];
|
|
134
|
+
const k = t1 > t0 ? Math.min(1, Math.max(0, (ms - t0) / (t1 - t0))) : 1;
|
|
135
|
+
const share = share0 + (share1 - share0) * k;
|
|
136
|
+
const width = from.width + (to.width - from.width) * Math.min(share, 1) + growth * (wide0 + (wide1 - wide0) * k);
|
|
137
|
+
return { x: from.x + from.width / 2 + (to.x + to.width / 2 - from.x - from.width / 2) * share - width / 2, width };
|
|
138
|
+
};
|
|
139
|
+
/** Where a horizontal thumb is drawn, from its control's left edge: where the script set it, or where a lens still
|
|
140
|
+
* on its way has it, so a switch mid-flight sets off from there */
|
|
141
|
+
const thumbBox = (thumb) => {
|
|
142
|
+
const offset = /^translateX\((-?[\d.]+)px\)$/.exec(thumb.style.transform);
|
|
143
|
+
const width = parseFloat(thumb.style.width);
|
|
144
|
+
if (!offset || !(width > 0))
|
|
145
|
+
return null;
|
|
146
|
+
const run = lensRuns.get(thumb);
|
|
147
|
+
const ms = Number(run?.move.currentTime);
|
|
148
|
+
if (run && (run.move.playState === "running" || run.move.playState === "paused") && ms >= 0) {
|
|
149
|
+
const growth = lensGrowth(getComputedStyle(thumb));
|
|
150
|
+
if (growth)
|
|
151
|
+
return lensBox(run, ms, growth[0]);
|
|
152
|
+
}
|
|
153
|
+
return { x: parseFloat(offset[1]), width };
|
|
154
|
+
};
|
|
155
|
+
// The lens's growth at its widest and tallest, which touch.css names on the large control only
|
|
156
|
+
const lensGrowth = (style) => {
|
|
157
|
+
const [wide = Number.NaN, tall = wide] = style.getPropertyValue("--segmented-control-thumb-lens-outset").trim().split(/\s+/).map(parseFloat);
|
|
158
|
+
return wide >= 0 && tall >= 0 ? [wide, tall] : null;
|
|
159
|
+
};
|
|
160
|
+
const playThumbLens = (thumb, from) => {
|
|
161
|
+
if (typeof thumb.animate !== "function")
|
|
162
|
+
return;
|
|
163
|
+
// A lens still on its way ends first, so the thumb's own fill and edge are read below (and none outlives a switch
|
|
164
|
+
// to reduced motion)
|
|
165
|
+
thumb.getAnimations().forEach((animation) => {
|
|
166
|
+
if (animation.id === LENS_ID)
|
|
167
|
+
animation.cancel();
|
|
168
|
+
});
|
|
169
|
+
lensRuns.get(thumb)?.label?.cancel();
|
|
170
|
+
lensRuns.delete(thumb);
|
|
171
|
+
if (!from || prefersReducedMotion())
|
|
172
|
+
return;
|
|
173
|
+
const style = getComputedStyle(thumb);
|
|
174
|
+
const growth = lensGrowth(style);
|
|
175
|
+
const to = thumbBox(thumb);
|
|
176
|
+
const top = parseFloat(style.top);
|
|
177
|
+
const bottom = parseFloat(style.bottom);
|
|
178
|
+
if (!growth || !to || !Number.isFinite(top) || !Number.isFinite(bottom))
|
|
179
|
+
return;
|
|
180
|
+
const [wide, tall] = growth;
|
|
181
|
+
const timing = { id: LENS_ID, duration: LENS_DURATION };
|
|
182
|
+
const run = { from, to, move: undefined };
|
|
183
|
+
// The thumb's box at each frame replaces its own while the lens runs (its transition is overridden); the height
|
|
184
|
+
// grows about the middle
|
|
185
|
+
run.move = thumb.animate(LENS_PATH.map(([ms, , , high]) => {
|
|
186
|
+
const box = lensBox(run, ms, wide);
|
|
187
|
+
const grown = (tall * high) / 2;
|
|
188
|
+
return {
|
|
189
|
+
offset: ms / LENS_DURATION,
|
|
190
|
+
transform: `translateX(${round(box.x)}px)`,
|
|
191
|
+
width: `${round(Math.max(1, box.width))}px`,
|
|
192
|
+
top: `${round(top - grown)}px`,
|
|
193
|
+
bottom: `${round(bottom - grown)}px`,
|
|
194
|
+
};
|
|
195
|
+
}), timing);
|
|
196
|
+
const lens = {
|
|
197
|
+
backgroundColor: style.getPropertyValue("--segmented-control-thumb-lens-background").trim(),
|
|
198
|
+
boxShadow: style.getPropertyValue("--segmented-control-thumb-lens-shadow").trim(),
|
|
199
|
+
};
|
|
200
|
+
const rest = { backgroundColor: style.backgroundColor, boxShadow: style.boxShadow };
|
|
201
|
+
// The gray clears as the lens lifts (45ms) and comes back as it lands (250 to 300ms)
|
|
202
|
+
const fill = thumb.animate([
|
|
203
|
+
{ offset: 0, ...rest },
|
|
204
|
+
{ offset: 45 / LENS_DURATION, ...lens },
|
|
205
|
+
{ offset: 250 / LENS_DURATION, ...lens },
|
|
206
|
+
{ offset: 300 / LENS_DURATION, ...rest },
|
|
207
|
+
{ offset: 1, ...rest },
|
|
208
|
+
], timing);
|
|
209
|
+
const root = thumb.parentElement;
|
|
210
|
+
const selected = root?.querySelector('[data-state="on"]');
|
|
211
|
+
if (selected && typeof selected.animate === "function") {
|
|
212
|
+
run.label = selected.animate(LENS_LABEL.map(([ms, opacity]) => ({ offset: ms / LENS_DURATION, opacity })), timing);
|
|
213
|
+
}
|
|
214
|
+
lensRuns.set(thumb, run);
|
|
215
|
+
// The frame a switch is drawn in also lays out whatever the switch changes around the control, which can take a
|
|
216
|
+
// few frames' time; the lens holds its first frame until then and sets off from the next, so none of its way is
|
|
217
|
+
// skipped (a tap's first 45ms were, recorded in Safari 11.11)
|
|
218
|
+
if (typeof requestAnimationFrame === "function") {
|
|
219
|
+
const held = [run.move, fill, run.label].filter((animation) => typeof animation?.pause === "function");
|
|
220
|
+
held.forEach((animation) => animation.pause());
|
|
221
|
+
requestAnimationFrame(() => {
|
|
222
|
+
held.forEach((animation) => {
|
|
223
|
+
if (animation.playState === "paused")
|
|
224
|
+
animation.play();
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
// The lens reaches past the capsule, which clips what scrolls in it: a control whose segments all fit lets it out
|
|
229
|
+
// for the switch
|
|
230
|
+
if (!root || root.scrollWidth > root.clientWidth + 1)
|
|
231
|
+
return;
|
|
232
|
+
const id = String(++lensRun);
|
|
233
|
+
root.setAttribute("data-lens", id);
|
|
234
|
+
const done = () => {
|
|
235
|
+
if (root.getAttribute("data-lens") === id)
|
|
236
|
+
root.removeAttribute("data-lens");
|
|
237
|
+
};
|
|
238
|
+
if (run.move?.finished)
|
|
239
|
+
run.move.finished.then(done, done);
|
|
240
|
+
else
|
|
241
|
+
done();
|
|
242
|
+
};
|
|
62
243
|
const TabsComponent = defineComponent({
|
|
63
244
|
name: "TabsRoot",
|
|
64
245
|
inheritAttrs: false,
|
|
@@ -69,6 +250,7 @@ const TabsComponent = defineComponent({
|
|
|
69
250
|
const thumbRef = ref(null);
|
|
70
251
|
const groupRef = ref(null);
|
|
71
252
|
let prevSize = props.size;
|
|
253
|
+
let prevValue = props.value;
|
|
72
254
|
// Radix useControllableState: `value` undefined means uncontrolled, starting empty
|
|
73
255
|
const uncontrolledValue = ref("");
|
|
74
256
|
const currentValue = computed(() => (props.value !== undefined ? props.value : uncontrolledValue.value));
|
|
@@ -177,10 +359,12 @@ const TabsComponent = defineComponent({
|
|
|
177
359
|
}
|
|
178
360
|
const isVertical = props.orientation === "vertical";
|
|
179
361
|
const transitionProperty = isVertical
|
|
180
|
-
? "height var(--tabs-thumb-transition-duration, 200ms) var(--cubic-enter), transform var(--tabs-thumb-transition-duration, 200ms) var(--cubic-enter)"
|
|
181
|
-
: "width var(--tabs-thumb-transition-duration, 200ms) var(--cubic-enter), transform var(--tabs-thumb-transition-duration, 200ms) var(--cubic-enter)";
|
|
362
|
+
? "height var(--tabs-thumb-transition-duration, 200ms) var(--tabs-thumb-transition-easing, var(--cubic-enter)), transform var(--tabs-thumb-transition-duration, 200ms) var(--tabs-thumb-transition-easing, var(--cubic-enter))"
|
|
363
|
+
: "width var(--tabs-thumb-transition-duration, 200ms) var(--tabs-thumb-transition-easing, var(--cubic-enter)), transform var(--tabs-thumb-transition-duration, 200ms) var(--tabs-thumb-transition-easing, var(--cubic-enter))";
|
|
182
364
|
const sizeChanged = prevSize !== props.size;
|
|
183
365
|
prevSize = props.size;
|
|
366
|
+
const valueChanged = prevValue !== props.value;
|
|
367
|
+
prevValue = props.value;
|
|
184
368
|
if (sizeChanged) {
|
|
185
369
|
// Size changed - disable transition, wait for CSS, then apply sizing
|
|
186
370
|
const currentTransition = thumb.style.transition;
|
|
@@ -194,7 +378,10 @@ const TabsComponent = defineComponent({
|
|
|
194
378
|
}
|
|
195
379
|
else if (thumb.style.transition) {
|
|
196
380
|
// Normal update (value change, etc.): the thumb leaves with the label's colour
|
|
381
|
+
const from = valueChanged ? thumbBox(thumb) : null;
|
|
197
382
|
applyThumbSizing(isVertical, true);
|
|
383
|
+
if (valueChanged)
|
|
384
|
+
playThumbLens(thumb, from);
|
|
198
385
|
}
|
|
199
386
|
else {
|
|
200
387
|
// First measure: apply transition after initial calculation is set
|
|
@@ -306,6 +493,7 @@ const TabsComponent = defineComponent({
|
|
|
306
493
|
"data-flush": isFlush ? "" : undefined,
|
|
307
494
|
"data-size": props.size,
|
|
308
495
|
"data-gutter-size": props.gutterSize,
|
|
496
|
+
"data-mobile-material": props.mobileMaterial,
|
|
309
497
|
"data-disabled": props.disabled ? "" : undefined,
|
|
310
498
|
...restAttrs,
|
|
311
499
|
}, { default: () => [h("div", { class: s.TabsThumb, ref: thumbRef }), slots.default?.()] }),
|
|
@@ -332,11 +520,46 @@ const hasContent = (nodes) => !!nodes?.some((node) => {
|
|
|
332
520
|
return true;
|
|
333
521
|
});
|
|
334
522
|
const isBadgeObject = (badge) => badge != null && typeof badge === "object" && "content" in badge;
|
|
523
|
+
// A text icon ("☀") stands in an element, as an icon component does, so a phone can hide it beside a label
|
|
335
524
|
const renderIcon = (icon) => {
|
|
336
|
-
if (icon == null
|
|
525
|
+
if (icon == null)
|
|
337
526
|
return icon;
|
|
527
|
+
if (isVNode(icon))
|
|
528
|
+
return wrapTextIcon([icon]);
|
|
529
|
+
if (typeof icon === "string")
|
|
530
|
+
return icon === "" ? null : h("span", icon);
|
|
338
531
|
return h(icon);
|
|
339
532
|
};
|
|
533
|
+
/** True when the slot draws text of its own, also inside a fragment (`<template v-if>`) */
|
|
534
|
+
const hasTextIcon = (nodes) => nodes.some((node) => {
|
|
535
|
+
if (typeof node === "string")
|
|
536
|
+
return node.trim() !== "";
|
|
537
|
+
if (typeof node === "number")
|
|
538
|
+
return true;
|
|
539
|
+
if (Array.isArray(node))
|
|
540
|
+
return hasTextIcon(node);
|
|
541
|
+
if (!isVNode(node))
|
|
542
|
+
return false;
|
|
543
|
+
if (node.type === Text)
|
|
544
|
+
return String(node.children).trim() !== "";
|
|
545
|
+
return node.type === Fragment && Array.isArray(node.children) && hasTextIcon(node.children);
|
|
546
|
+
});
|
|
547
|
+
/** The slot's text stands in a span, as the React icon's does; a fragment holding text keeps its key, and every
|
|
548
|
+
* other node, a fragment of icons too, stays as it is. */
|
|
549
|
+
const wrapTextIcon = (nodes) => nodes.map((node) => {
|
|
550
|
+
if (typeof node === "string" || typeof node === "number")
|
|
551
|
+
return hasTextIcon([node]) ? h("span", String(node)) : node;
|
|
552
|
+
if (Array.isArray(node))
|
|
553
|
+
return hasTextIcon(node) ? wrapTextIcon(node) : node;
|
|
554
|
+
if (!isVNode(node))
|
|
555
|
+
return node;
|
|
556
|
+
if (node.type === Text)
|
|
557
|
+
return hasTextIcon([node]) ? h("span", String(node.children)) : node;
|
|
558
|
+
if (node.type === Fragment && Array.isArray(node.children) && hasTextIcon(node.children)) {
|
|
559
|
+
return h(Fragment, { key: node.key ?? undefined }, wrapTextIcon(node.children));
|
|
560
|
+
}
|
|
561
|
+
return node;
|
|
562
|
+
});
|
|
340
563
|
const TabComponent = defineComponent({
|
|
341
564
|
name: "TabsTab",
|
|
342
565
|
inheritAttrs: false,
|
|
@@ -411,7 +634,7 @@ const TabComponent = defineComponent({
|
|
|
411
634
|
}, {
|
|
412
635
|
default: () => [
|
|
413
636
|
h("span", { class: s.TabContent }, [
|
|
414
|
-
hasContent(iconSlot) ? iconSlot : renderIcon(props.icon),
|
|
637
|
+
hasContent(iconSlot) ? wrapTextIcon(iconSlot) : renderIcon(props.icon),
|
|
415
638
|
hasContent(children) ? h("span", { class: s.TabLabel }, children) : null,
|
|
416
639
|
badgeProps
|
|
417
640
|
? h("span", {
|
|
@@ -624,7 +847,7 @@ const TabsPublic = defineComponent({
|
|
|
624
847
|
}
|
|
625
848
|
const items = tabVNodes(slots.default?.());
|
|
626
849
|
// The strip's own props size the tabs and the menu button too
|
|
627
|
-
const signature = [overflowLabel, props.size, props.variant, props.gutterSize, props.pill, props.flush, tabsSignature(items)].join("\u0002");
|
|
850
|
+
const signature = [overflowLabel, props.size, props.variant, props.gutterSize, props.pill, props.flush, props.mobileMaterial, tabsSignature(items)].join("\u0002");
|
|
628
851
|
const activeIndex = items.findIndex((item) => tabProps(item).value === current.value);
|
|
629
852
|
const { count } = measured.value;
|
|
630
853
|
// New tabs measure again; so does an active tab that moves under the
|