@plexui/vue 0.9.0 → 0.11.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 +6 -2
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/Avatar/Avatar.js +3 -1
- package/dist/es/components/Avatar/Avatar.js.map +1 -1
- package/dist/es/components/ButtonGroup/ButtonGroup.js +7 -0
- package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist/es/components/ButtonGroup/index.js.map +1 -1
- package/dist/es/components/Checkbox/Checkbox.js +5 -6
- package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorPicker.js +476 -0
- package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/es/components/ColorPicker/ColorWell.js +186 -0
- package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
- package/dist/es/components/ColorPicker/index.js +3 -0
- package/dist/es/components/ColorPicker/index.js.map +1 -0
- package/dist/es/components/ColorPicker/shared.js +132 -0
- package/dist/es/components/ColorPicker/shared.js.map +1 -0
- package/dist/es/components/ContextMenu/ContextMenu.js +223 -0
- package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
- package/dist/es/components/ContextMenu/index.js +2 -0
- package/dist/es/components/ContextMenu/index.js.map +1 -0
- package/dist/es/components/ContextMenu/shared.js +58 -0
- package/dist/es/components/ContextMenu/shared.js.map +1 -0
- package/dist/es/components/DatePicker/DatePicker.js +19 -3
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +245 -25
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/dialogSteps.js +85 -0
- package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
- package/dist/es/components/Dialog/dialogViewport.js +74 -0
- package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
- package/dist/es/components/Dialog/index.js +1 -1
- package/dist/es/components/Dialog/index.js.map +1 -1
- package/dist/es/components/Dialog/sheetDrag.js +2 -1
- package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
- package/dist/es/components/Field/Field.js +11 -3
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/FieldGroup/FieldGroup.js +12 -1
- package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +2 -2
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
- package/dist/es/components/Icon/index.js +1 -0
- package/dist/es/components/Icon/index.js.map +1 -1
- package/dist/es/components/Icon/svg/Eyedropper.js +10 -0
- package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
- package/dist/es/components/IndexBar/IndexBar.js +215 -0
- package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
- package/dist/es/components/IndexBar/index.js +2 -0
- package/dist/es/components/IndexBar/index.js.map +1 -0
- package/dist/es/components/Indicator/LoadingIndicator.js +1 -1
- package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
- package/dist/es/components/Input/Input.js +3 -2
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +149 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +206 -33
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Menu/index.js +1 -1
- package/dist/es/components/Menu/index.js.map +1 -1
- package/dist/es/components/Page/Page.js +43 -11
- package/dist/es/components/Page/Page.js.map +1 -1
- package/dist/es/components/PageControl/PageControl.js +210 -0
- package/dist/es/components/PageControl/PageControl.js.map +1 -0
- package/dist/es/components/PageControl/index.js +2 -0
- package/dist/es/components/PageControl/index.js.map +1 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.js +50 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
- package/dist/es/components/PhoneLayout/index.js +2 -0
- package/dist/es/components/PhoneLayout/index.js.map +1 -0
- package/dist/es/components/Popover/Popover.js +5 -1
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/Popover/deferredPointerDownOutside.js +59 -4
- package/dist/es/components/Popover/deferredPointerDownOutside.js.map +1 -1
- package/dist/es/components/Select/Select.js +18 -11
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +1 -0
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +21 -6
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +44 -9
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Stepper/Stepper.js +195 -0
- package/dist/es/components/Stepper/Stepper.js.map +1 -0
- package/dist/es/components/Stepper/index.js +2 -0
- package/dist/es/components/Stepper/index.js.map +1 -0
- package/dist/es/components/SwipeActions/SwipeActions.js +374 -0
- package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
- package/dist/es/components/SwipeActions/index.js +2 -0
- package/dist/es/components/SwipeActions/index.js.map +1 -0
- package/dist/es/components/Switch/Switch.js +3 -1
- package/dist/es/components/Switch/Switch.js.map +1 -1
- package/dist/es/components/TabBar/TabBar.js +205 -0
- package/dist/es/components/TabBar/TabBar.js.map +1 -0
- package/dist/es/components/TabBar/index.js +2 -0
- package/dist/es/components/TabBar/index.js.map +1 -0
- package/dist/es/components/Tabs/Tabs.js +10 -2
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/TagInput/TagInput.js +3 -46
- package/dist/es/components/TagInput/TagInput.js.map +1 -1
- package/dist/es/components/Textarea/Textarea.js +2 -0
- package/dist/es/components/Textarea/Textarea.js.map +1 -1
- package/dist/es/components/Tip/Tip.js +276 -0
- package/dist/es/components/Tip/Tip.js.map +1 -0
- package/dist/es/components/Tip/index.js +2 -0
- package/dist/es/components/Tip/index.js.map +1 -0
- package/dist/es/components/Toast/ToastRenderer.js +30 -13
- package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
- package/dist/es/components/Toast/Toaster.js +17 -6
- package/dist/es/components/Toast/Toaster.js.map +1 -1
- package/dist/es/components/Toast/toastLifecycle.js +113 -1
- package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js +37 -6
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/components/Toolbar/index.js.map +1 -1
- package/dist/es/components/Tooltip/slot.js +3 -3
- package/dist/es/components/Tooltip/slot.js.map +1 -1
- package/dist/es/composables/useEscCloseStack.js +8 -4
- package/dist/es/composables/useEscCloseStack.js.map +1 -1
- package/dist/es/lib/fieldRow.js +15 -2
- package/dist/es/lib/fieldRow.js.map +1 -1
- package/dist/es/lib/floatingBoundary.js +3 -1
- package/dist/es/lib/floatingBoundary.js.map +1 -1
- package/dist/es/lib/helpers.js +21 -0
- package/dist/es/lib/helpers.js.map +1 -1
- package/dist/es/lib/menuSubmenuPlacement.js +51 -6
- package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
- package/dist/es/lib/menuTriggerCover.js +70 -0
- package/dist/es/lib/menuTriggerCover.js.map +1 -0
- package/dist/es/lib/phoneLayout.js +16 -0
- package/dist/es/lib/phoneLayout.js.map +1 -0
- package/dist/es/lib/scrollEdges.js +34 -0
- package/dist/es/lib/scrollEdges.js.map +1 -0
- package/dist/es/lib/toastRegion.js +6 -0
- package/dist/es/lib/toastRegion.js.map +1 -0
- package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +13 -0
- package/dist/types/components/ButtonGroup/index.d.ts +1 -1
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +244 -0
- package/dist/types/components/ColorPicker/ColorWell.d.ts +334 -0
- package/dist/types/components/ColorPicker/index.d.ts +3 -0
- package/dist/types/components/ColorPicker/shared.d.ts +69 -0
- package/dist/types/components/ContextMenu/ContextMenu.d.ts +128 -0
- package/dist/types/components/ContextMenu/index.d.ts +1 -0
- package/dist/types/components/ContextMenu/shared.d.ts +51 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +24 -4
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +4 -4
- package/dist/types/components/Dialog/Dialog.d.ts +100 -4
- package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
- package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/Field/Field.d.ts +21 -2
- package/dist/types/components/FieldGroup/FieldGroup.d.ts +18 -1
- package/dist/types/components/Icon/index.d.ts +1 -0
- package/dist/types/components/Icon/svg/Eyedropper.d.ts +3 -0
- package/dist/types/components/IndexBar/IndexBar.d.ts +112 -0
- package/dist/types/components/IndexBar/index.d.ts +1 -0
- package/dist/types/components/Indicator/LoadingIndicator.d.ts +2 -2
- package/dist/types/components/Menu/Menu.d.ts +153 -40
- package/dist/types/components/Menu/index.d.ts +1 -1
- package/dist/types/components/Page/Page.d.ts +13 -5
- package/dist/types/components/PageControl/PageControl.d.ts +216 -0
- package/dist/types/components/PageControl/index.d.ts +1 -0
- package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +21 -0
- package/dist/types/components/PhoneLayout/index.d.ts +1 -0
- package/dist/types/components/Popover/deferredPointerDownOutside.d.ts +1 -1
- package/dist/types/components/Select/Select.d.ts +6 -6
- package/dist/types/components/Stepper/Stepper.d.ts +338 -0
- package/dist/types/components/Stepper/index.d.ts +1 -0
- package/dist/types/components/SwipeActions/SwipeActions.d.ts +135 -0
- package/dist/types/components/SwipeActions/index.d.ts +1 -0
- package/dist/types/components/TabBar/TabBar.d.ts +405 -0
- package/dist/types/components/TabBar/index.d.ts +1 -0
- package/dist/types/components/Tip/Tip.d.ts +146 -0
- package/dist/types/components/Tip/index.d.ts +1 -0
- package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +26 -9
- package/dist/types/components/Toolbar/index.d.ts +1 -1
- package/dist/types/components/Tooltip/CopyTooltip.d.ts +1 -1
- package/dist/types/composables/useEscCloseStack.d.ts +2 -2
- package/dist/types/lib/fieldRow.d.ts +5 -0
- package/dist/types/lib/helpers.d.ts +6 -0
- package/dist/types/lib/menuSubmenuPlacement.d.ts +14 -1
- package/dist/types/lib/menuTriggerCover.d.ts +23 -0
- package/dist/types/lib/phoneLayout.d.ts +11 -0
- package/dist/types/lib/scrollEdges.d.ts +16 -0
- package/dist/types/lib/toastRegion.d.ts +5 -0
- package/package.json +2 -2
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { computed, defineComponent, h, inject, onBeforeUnmount, onMounted, provide, ref, watch, } from "vue";
|
|
2
|
+
import s from "@plexui/styles/components/TabBar/TabBar.module.css";
|
|
3
|
+
import { Search as SearchIcon } from "../Icon/index.js";
|
|
4
|
+
import { TOOLBAR_HOST } from "../Toolbar/Toolbar.js";
|
|
5
|
+
// Vue port of packages/ui/src/components/TabBar/TabBar.tsx. Exports are flat (`TabBarItem` for `TabBar.Item`);
|
|
6
|
+
// the symbol of an item is its `icon` slot. React's `value` + `onValueChange` become `value` + `update:value`
|
|
7
|
+
// (`v-model:value`), `minimized` + `onMinimizedChange` become `minimized` + `update:minimized`.
|
|
8
|
+
/** A scroll of at least this many pixels in one direction minimizes or expands the bar. */
|
|
9
|
+
const MINIMIZE_AFTER = 8;
|
|
10
|
+
const TAB_BAR = Symbol("TabBar");
|
|
11
|
+
const TabBarItemComponent = defineComponent({
|
|
12
|
+
name: "TabBarItem",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: {
|
|
15
|
+
/** The value of the tab. */
|
|
16
|
+
value: { type: String, required: true },
|
|
17
|
+
/** The label under the symbol, and the accessible name of the tab. */
|
|
18
|
+
label: { type: String, required: true },
|
|
19
|
+
/** Makes the tab a link to this URL. */
|
|
20
|
+
href: String,
|
|
21
|
+
/** When `true`, the tab cannot be selected. */
|
|
22
|
+
disabled: { type: Boolean, default: false },
|
|
23
|
+
/** @internal The search and the prominent tab show their symbol only. */
|
|
24
|
+
hideLabel: { type: Boolean, default: false },
|
|
25
|
+
},
|
|
26
|
+
emits: {
|
|
27
|
+
/** The tab was pressed, before it is selected */
|
|
28
|
+
click: (event) => event instanceof MouseEvent,
|
|
29
|
+
},
|
|
30
|
+
setup(props, { attrs, emit, slots }) {
|
|
31
|
+
const context = inject(TAB_BAR, null);
|
|
32
|
+
if (!context)
|
|
33
|
+
throw new Error("TabBarItem must be used within TabBar");
|
|
34
|
+
const selected = computed(() => context.value.value === props.value);
|
|
35
|
+
// A minimized bar shows the selected tab only; pressing it brings the other tabs back.
|
|
36
|
+
const collapsed = computed(() => context.minimized.value && selected.value && !props.hideLabel);
|
|
37
|
+
const handleClick = (event) => {
|
|
38
|
+
emit("click", event);
|
|
39
|
+
if (event.defaultPrevented || props.disabled)
|
|
40
|
+
return;
|
|
41
|
+
if (collapsed.value) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
return context.expand();
|
|
44
|
+
}
|
|
45
|
+
context.select(props.value);
|
|
46
|
+
};
|
|
47
|
+
return () => {
|
|
48
|
+
const content = [
|
|
49
|
+
h("span", { "class": s.Icon, "aria-hidden": "true" }, slots.icon?.()),
|
|
50
|
+
props.hideLabel ? null : h("span", { class: s.Label }, props.label),
|
|
51
|
+
];
|
|
52
|
+
const shared = {
|
|
53
|
+
"class": [s.Item, attrs.class],
|
|
54
|
+
"aria-current": selected.value ? "page" : undefined,
|
|
55
|
+
"aria-label": props.hideLabel ? props.label : undefined,
|
|
56
|
+
"aria-expanded": collapsed.value ? false : undefined,
|
|
57
|
+
"data-selected": selected.value ? "" : undefined,
|
|
58
|
+
"data-disabled": props.disabled ? "" : undefined,
|
|
59
|
+
"data-value": props.value,
|
|
60
|
+
"onClick": handleClick,
|
|
61
|
+
};
|
|
62
|
+
if (props.href !== undefined && !props.disabled)
|
|
63
|
+
return h("a", { href: props.href, ...shared }, content);
|
|
64
|
+
return h("button", { type: "button", disabled: props.disabled, ...shared }, content);
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
/** One tab of a `TabBar` (React `TabBar.Item`): its `icon` slot holds the symbol, a PlexUI icon. */
|
|
69
|
+
export const TabBarItem = TabBarItemComponent;
|
|
70
|
+
const TabBarComponent = defineComponent({
|
|
71
|
+
name: "TabBar",
|
|
72
|
+
inheritAttrs: false,
|
|
73
|
+
props: {
|
|
74
|
+
/** The controlled value of the selected tab. Bind with `v-model:value`. */
|
|
75
|
+
value: { type: String, default: undefined },
|
|
76
|
+
/** The selected tab when it is initially rendered. */
|
|
77
|
+
defaultValue: { type: String, default: undefined },
|
|
78
|
+
/** A search tab in a glass circle of its own at the trailing end, as the iOS 26 separate search tab. */
|
|
79
|
+
search: { type: Object, default: undefined },
|
|
80
|
+
/**
|
|
81
|
+
* The one destination the app lifts out of the capsule, a cart or a library, in a glass circle of its own at
|
|
82
|
+
* the trailing end, as the iOS 27 prominent tab role; its symbol is the `prominent-icon` slot. It takes the
|
|
83
|
+
* circle of the search tab: with both, search is the last tab of the capsule, as iOS gives search that place
|
|
84
|
+
* only when no other tab is prominent.
|
|
85
|
+
*/
|
|
86
|
+
prominent: { type: Object, default: undefined },
|
|
87
|
+
/**
|
|
88
|
+
* `onScrollDown` minimizes the bar to the selected tab while the content of the `Page` scrolls down and
|
|
89
|
+
* expands it when the content scrolls back up; a tap on the minimized tab expands it too. @default "never"
|
|
90
|
+
*/
|
|
91
|
+
minimizeBehavior: { type: String, default: "never" },
|
|
92
|
+
/** Controlled minimized state. Bind with `v-model:minimized`. */
|
|
93
|
+
minimized: { type: Boolean, default: undefined },
|
|
94
|
+
/** The minimized state when it is initially rendered. @default false */
|
|
95
|
+
defaultMinimized: { type: Boolean, default: false },
|
|
96
|
+
/** How the bar meets the content scrolled under it; see `BarBackground`. @default "soft" */
|
|
97
|
+
background: { type: String, default: "soft" },
|
|
98
|
+
/** Accessible name of the navigation. @default "Tabs" */
|
|
99
|
+
ariaLabel: { type: String, default: "Tabs" },
|
|
100
|
+
},
|
|
101
|
+
emits: {
|
|
102
|
+
/** A tab was selected */
|
|
103
|
+
"update:value": (value) => typeof value === "string",
|
|
104
|
+
/** A tab was selected (React `onValueChange`) */
|
|
105
|
+
"valueChange": (value) => typeof value === "string",
|
|
106
|
+
/** The bar minimized or expanded */
|
|
107
|
+
"update:minimized": (minimized) => typeof minimized === "boolean",
|
|
108
|
+
},
|
|
109
|
+
setup(props, { attrs, emit, slots }) {
|
|
110
|
+
const host = inject(TOOLBAR_HOST, null);
|
|
111
|
+
const internalValue = ref(props.defaultValue);
|
|
112
|
+
const value = computed(() => props.value ?? internalValue.value);
|
|
113
|
+
const internalMinimized = ref(props.defaultMinimized);
|
|
114
|
+
const minimized = computed(() => props.minimized ?? internalMinimized.value);
|
|
115
|
+
const select = (next) => {
|
|
116
|
+
if (props.value === undefined)
|
|
117
|
+
internalValue.value = next;
|
|
118
|
+
emit("update:value", next);
|
|
119
|
+
emit("valueChange", next);
|
|
120
|
+
};
|
|
121
|
+
const setMinimized = (next) => {
|
|
122
|
+
if (next === minimized.value)
|
|
123
|
+
return;
|
|
124
|
+
if (props.minimized === undefined)
|
|
125
|
+
internalMinimized.value = next;
|
|
126
|
+
emit("update:minimized", next);
|
|
127
|
+
};
|
|
128
|
+
provide(TAB_BAR, { value, minimized, select, expand: () => setMinimized(false) });
|
|
129
|
+
// The bar follows the Page content: down by MINIMIZE_AFTER minimizes it, up by as much (or the top) expands it.
|
|
130
|
+
let unsubscribe;
|
|
131
|
+
const follow = () => {
|
|
132
|
+
unsubscribe?.();
|
|
133
|
+
unsubscribe = undefined;
|
|
134
|
+
if (props.minimizeBehavior !== "onScrollDown" || !host?.subscribeScroll)
|
|
135
|
+
return;
|
|
136
|
+
let anchor = 0;
|
|
137
|
+
unsubscribe = host.subscribeScroll((scrollTop) => {
|
|
138
|
+
if (scrollTop <= 0) {
|
|
139
|
+
anchor = 0;
|
|
140
|
+
return setMinimized(false);
|
|
141
|
+
}
|
|
142
|
+
const delta = scrollTop - anchor;
|
|
143
|
+
if (minimized.value ? delta < 0 : delta > 0) {
|
|
144
|
+
if (Math.abs(delta) >= MINIMIZE_AFTER) {
|
|
145
|
+
anchor = scrollTop;
|
|
146
|
+
setMinimized(!minimized.value);
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
anchor = scrollTop;
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
watch(() => props.minimizeBehavior, follow, { immediate: true });
|
|
154
|
+
// Like a bottom Toolbar, the bar reserves its height on the Page; a desktop layout hides it.
|
|
155
|
+
const element = ref(null);
|
|
156
|
+
let observer;
|
|
157
|
+
onMounted(() => {
|
|
158
|
+
const bar = element.value;
|
|
159
|
+
const setHeight = host?.setHeight;
|
|
160
|
+
if (!bar || !setHeight)
|
|
161
|
+
return;
|
|
162
|
+
const update = () => setHeight("bottom", bar.offsetHeight || undefined);
|
|
163
|
+
update();
|
|
164
|
+
observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : undefined;
|
|
165
|
+
observer?.observe(bar, { box: "border-box" });
|
|
166
|
+
});
|
|
167
|
+
onBeforeUnmount(() => {
|
|
168
|
+
unsubscribe?.();
|
|
169
|
+
observer?.disconnect();
|
|
170
|
+
host?.setHeight?.("bottom", undefined);
|
|
171
|
+
});
|
|
172
|
+
return () => h("nav", {
|
|
173
|
+
...attrs,
|
|
174
|
+
"ref": element,
|
|
175
|
+
"aria-label": props.ariaLabel,
|
|
176
|
+
"class": [s.TabBar, attrs.class],
|
|
177
|
+
"data-host": host?.kind,
|
|
178
|
+
"data-background": props.background,
|
|
179
|
+
"data-content-below": host?.contentBelow?.value ? "" : undefined,
|
|
180
|
+
"data-minimized": minimized.value ? "" : undefined,
|
|
181
|
+
"data-search": props.search && !props.prominent ? "" : undefined,
|
|
182
|
+
"data-prominent": props.prominent ? "" : undefined,
|
|
183
|
+
}, [
|
|
184
|
+
h("div", { class: s.Tabs }, [
|
|
185
|
+
slots.default?.(),
|
|
186
|
+
props.search && props.prominent
|
|
187
|
+
? h(TabBarItem, { value: props.search.value, label: props.search.label ?? "Search" }, { icon: () => h(SearchIcon) })
|
|
188
|
+
: null,
|
|
189
|
+
]),
|
|
190
|
+
props.prominent
|
|
191
|
+
? h(TabBarItem, { class: s.Prominent, value: props.prominent.value, label: props.prominent.label, hideLabel: true }, { icon: () => slots["prominent-icon"]?.() })
|
|
192
|
+
: props.search
|
|
193
|
+
? h(TabBarItem, { class: s.Search, value: props.search.value, label: props.search.label ?? "Search", hideLabel: true }, { icon: () => h(SearchIcon) })
|
|
194
|
+
: null,
|
|
195
|
+
]);
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
/**
|
|
199
|
+
* The tab bar of a phone screen after the iOS 26 kit Tab Bar - iPhone (507:24689): two to five tabs, each a
|
|
200
|
+
* symbol over a label, in a floating glass capsule at the bottom, the selected tab on a pill, and an optional
|
|
201
|
+
* search or prominent tab in a circle of its own. It minimizes to the selected tab while the content scrolls
|
|
202
|
+
* down. A desktop layout navigates with a Sidebar or Tabs, so the bar never renders from 768px up.
|
|
203
|
+
*/
|
|
204
|
+
export const TabBar = TabBarComponent;
|
|
205
|
+
//# sourceMappingURL=TabBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../../../src/components/TabBar/TabBar.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,MAAM,EACN,eAAe,EACf,SAAS,EACT,OAAO,EACP,GAAG,EACH,KAAK,GAIN,MAAM,KAAK,CAAA;AACZ,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAClE,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;A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AK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,EAAE,EAAE,CAAC;gBACjK,CAAC,CAAC,KAAK,CAAC,MAAM;oBACZ,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC;oBACtJ,CAAC,CAAC,IAAI;SACX,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA;AAKF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CAAA","sourcesContent":["import {\n computed,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n watch,\n type ComputedRef,\n type InjectionKey,\n type PropType,\n} from \"vue\"\nimport s from \"@plexui/styles/components/TabBar/TabBar.module.css\"\nimport { Search as SearchIcon } from \"../Icon/index.js\"\nimport { TOOLBAR_HOST, type BarBackground } from \"../Toolbar/Toolbar.js\"\n\n// Vue port of packages/ui/src/components/TabBar/TabBar.tsx. Exports are flat (`TabBarItem` for `TabBar.Item`);\n// the symbol of an item is its `icon` slot. React's `value` + `onValueChange` become `value` + `update:value`\n// (`v-model:value`), `minimized` + `onMinimizedChange` become `minimized` + `update:minimized`.\n\n/** A scroll of at least this many pixels in one direction minimizes or expands the bar. */\nconst MINIMIZE_AFTER = 8\n\ntype TabBarContext = {\n value: ComputedRef<string | undefined>\n minimized: ComputedRef<boolean>\n select: (value: string) => void\n expand: () => void\n}\n\nconst TAB_BAR: InjectionKey<TabBarContext> = Symbol(\"TabBar\")\n\nexport type TabBarSearch = {\n /** The value of the search tab. */\n value: string\n /** Accessible name of the search tab. @default \"Search\" */\n label?: string\n}\n\n/** The prominent tab of a `TabBar`; its symbol is the `prominent-icon` slot of the bar (React `prominent.icon`). */\nexport type TabBarProminent = {\n /** The value of the prominent tab. */\n value: string\n /** Accessible name of the prominent tab: its circle shows the symbol only. */\n label: string\n}\n\nconst TabBarItemComponent = defineComponent({\n name: \"TabBarItem\",\n inheritAttrs: false,\n props: {\n /** The value of the tab. */\n value: { type: String, required: true },\n /** The label under the symbol, and the accessible name of the tab. */\n label: { type: String, required: true },\n /** Makes the tab a link to this URL. */\n href: String,\n /** When `true`, the tab cannot be selected. */\n disabled: { type: Boolean, default: false },\n /** @internal The search and the prominent tab show their symbol only. */\n hideLabel: { type: Boolean, default: false },\n },\n emits: {\n /** The tab was pressed, before it is selected */\n click: (event: MouseEvent) => event instanceof MouseEvent,\n },\n setup(props, { attrs, emit, slots }) {\n const context = inject(TAB_BAR, null)\n if (!context) throw new Error(\"TabBarItem must be used within TabBar\")\n const selected = computed(() => context.value.value === props.value)\n // A minimized bar shows the selected tab only; pressing it brings the other tabs back.\n const collapsed = computed(() => context.minimized.value && selected.value && !props.hideLabel)\n const handleClick = (event: MouseEvent) => {\n emit(\"click\", event)\n if (event.defaultPrevented || props.disabled) return\n if (collapsed.value) {\n event.preventDefault()\n return context.expand()\n }\n context.select(props.value)\n }\n return () => {\n const content = [\n h(\"span\", { \"class\": s.Icon, \"aria-hidden\": \"true\" }, slots.icon?.()),\n props.hideLabel ? null : h(\"span\", { class: s.Label }, props.label),\n ]\n const shared = {\n \"class\": [s.Item, attrs.class],\n \"aria-current\": selected.value ? \"page\" : undefined,\n \"aria-label\": props.hideLabel ? props.label : undefined,\n \"aria-expanded\": collapsed.value ? false : undefined,\n \"data-selected\": selected.value ? \"\" : undefined,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-value\": props.value,\n \"onClick\": handleClick,\n }\n if (props.href !== undefined && !props.disabled) return h(\"a\", { href: props.href, ...shared }, content)\n return h(\"button\", { type: \"button\", disabled: props.disabled, ...shared }, content)\n }\n },\n})\n\n/** Props of `TabBarItem`. */\nexport type TabBarItemProps = InstanceType<typeof TabBarItemComponent>[\"$props\"]\n\n/** One tab of a `TabBar` (React `TabBar.Item`): its `icon` slot holds the symbol, a PlexUI icon. */\nexport const TabBarItem = TabBarItemComponent\n\nconst TabBarComponent = defineComponent({\n name: \"TabBar\",\n inheritAttrs: false,\n props: {\n /** The controlled value of the selected tab. Bind with `v-model:value`. */\n value: { type: String, default: undefined },\n /** The selected tab when it is initially rendered. */\n defaultValue: { type: String, default: undefined },\n /** A search tab in a glass circle of its own at the trailing end, as the iOS 26 separate search tab. */\n search: { type: Object as PropType<TabBarSearch>, default: undefined },\n /**\n * The one destination the app lifts out of the capsule, a cart or a library, in a glass circle of its own at\n * the trailing end, as the iOS 27 prominent tab role; its symbol is the `prominent-icon` slot. It takes the\n * circle of the search tab: with both, search is the last tab of the capsule, as iOS gives search that place\n * only when no other tab is prominent.\n */\n prominent: { type: Object as PropType<TabBarProminent>, default: undefined },\n /**\n * `onScrollDown` minimizes the bar to the selected tab while the content of the `Page` scrolls down and\n * expands it when the content scrolls back up; a tap on the minimized tab expands it too. @default \"never\"\n */\n minimizeBehavior: { type: String as PropType<\"never\" | \"onScrollDown\">, default: \"never\" },\n /** Controlled minimized state. Bind with `v-model:minimized`. */\n minimized: { type: Boolean, default: undefined },\n /** The minimized state when it is initially rendered. @default false */\n defaultMinimized: { type: Boolean, default: false },\n /** How the bar meets the content scrolled under it; see `BarBackground`. @default \"soft\" */\n background: { type: String as PropType<BarBackground>, default: \"soft\" },\n /** Accessible name of the navigation. @default \"Tabs\" */\n ariaLabel: { type: String, default: \"Tabs\" },\n },\n emits: {\n /** A tab was selected */\n \"update:value\": (value: string) => typeof value === \"string\",\n /** A tab was selected (React `onValueChange`) */\n \"valueChange\": (value: string) => typeof value === \"string\",\n /** The bar minimized or expanded */\n \"update:minimized\": (minimized: boolean) => typeof minimized === \"boolean\",\n },\n setup(props, { attrs, emit, slots }) {\n const host = inject(TOOLBAR_HOST, null)\n const internalValue = ref(props.defaultValue)\n const value = computed(() => props.value ?? internalValue.value)\n const internalMinimized = ref(props.defaultMinimized)\n const minimized = computed(() => props.minimized ?? internalMinimized.value)\n\n const select = (next: string) => {\n if (props.value === undefined) internalValue.value = next\n emit(\"update:value\", next)\n emit(\"valueChange\", next)\n }\n const setMinimized = (next: boolean) => {\n if (next === minimized.value) return\n if (props.minimized === undefined) internalMinimized.value = next\n emit(\"update:minimized\", next)\n }\n provide(TAB_BAR, { value, minimized, select, expand: () => setMinimized(false) })\n\n // The bar follows the Page content: down by MINIMIZE_AFTER minimizes it, up by as much (or the top) expands it.\n let unsubscribe: (() => void) | undefined\n const follow = () => {\n unsubscribe?.()\n unsubscribe = undefined\n if (props.minimizeBehavior !== \"onScrollDown\" || !host?.subscribeScroll) return\n let anchor = 0\n unsubscribe = host.subscribeScroll((scrollTop) => {\n if (scrollTop <= 0) {\n anchor = 0\n return setMinimized(false)\n }\n const delta = scrollTop - anchor\n if (minimized.value ? delta < 0 : delta > 0) {\n if (Math.abs(delta) >= MINIMIZE_AFTER) {\n anchor = scrollTop\n setMinimized(!minimized.value)\n }\n return\n }\n anchor = scrollTop\n })\n }\n watch(() => props.minimizeBehavior, follow, { immediate: true })\n\n // Like a bottom Toolbar, the bar reserves its height on the Page; a desktop layout hides it.\n const element = ref<HTMLElement | null>(null)\n let observer: ResizeObserver | undefined\n onMounted(() => {\n const bar = element.value\n const setHeight = host?.setHeight\n if (!bar || !setHeight) return\n const update = () => setHeight(\"bottom\", bar.offsetHeight || undefined)\n update()\n observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : undefined\n observer?.observe(bar, { box: \"border-box\" })\n })\n onBeforeUnmount(() => {\n unsubscribe?.()\n observer?.disconnect()\n host?.setHeight?.(\"bottom\", undefined)\n })\n\n return () => h(\"nav\", {\n ...attrs,\n \"ref\": element,\n \"aria-label\": props.ariaLabel,\n \"class\": [s.TabBar, attrs.class],\n \"data-host\": host?.kind,\n \"data-background\": props.background,\n \"data-content-below\": host?.contentBelow?.value ? \"\" : undefined,\n \"data-minimized\": minimized.value ? \"\" : undefined,\n \"data-search\": props.search && !props.prominent ? \"\" : undefined,\n \"data-prominent\": props.prominent ? \"\" : undefined,\n }, [\n h(\"div\", { class: s.Tabs }, [\n slots.default?.(),\n props.search && props.prominent\n ? h(TabBarItem, { value: props.search.value, label: props.search.label ?? \"Search\" }, { icon: () => h(SearchIcon) })\n : null,\n ]),\n props.prominent\n ? h(TabBarItem, { class: s.Prominent, value: props.prominent.value, label: props.prominent.label, hideLabel: true }, { icon: () => slots[\"prominent-icon\"]?.() })\n : props.search\n ? h(TabBarItem, { class: s.Search, value: props.search.value, label: props.search.label ?? \"Search\", hideLabel: true }, { icon: () => h(SearchIcon) })\n : null,\n ])\n },\n})\n\n/** Props of `TabBar`. */\nexport type TabBarProps = InstanceType<typeof TabBarComponent>[\"$props\"]\n\n/**\n * The tab bar of a phone screen after the iOS 26 kit Tab Bar - iPhone (507:24689): two to five tabs, each a\n * symbol over a label, in a floating glass capsule at the bottom, the selected tab on a pill, and an optional\n * search or prominent tab in a circle of its own. It minimizes to the selected tab while the content scrolls\n * down. A desktop layout navigates with a Sidebar or Tabs, so the bar never renders from 768px up.\n */\nexport const TabBar = TabBarComponent\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/TabBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAmF,MAAM,aAAa,CAAA","sourcesContent":["export { TabBar, TabBarItem, type TabBarItemProps, type TabBarProminent, type TabBarProps, type TabBarSearch } from \"./TabBar.js\"\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Comment, Fragment, Text, computed, defineComponent, h, inject, isVNode, onBeforeUnmount, onMounted, onUpdated, provide, ref, shallowRef, watch, } from "vue";
|
|
2
2
|
import { RovingFocusGroup, RovingFocusItem } from "reka-ui";
|
|
3
3
|
import { handlePressableMouseEnter, prefersReducedMotion, waitForAnimationFrame } from "../../lib/helpers.js";
|
|
4
|
+
import CheckMd from "../Icon/svg/CheckMd.js";
|
|
4
5
|
import ChevronDownMd from "../Icon/svg/ChevronDownMd.js";
|
|
5
6
|
import { LoadingIndicator } from "../Indicator/index.js";
|
|
6
7
|
import { Menu, MenuContent, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "../Menu/index.js";
|
|
@@ -180,6 +181,7 @@ const TabsComponent = defineComponent({
|
|
|
180
181
|
provide(TabsContextKey, {
|
|
181
182
|
value: currentValue,
|
|
182
183
|
disabled: computed(() => props.disabled),
|
|
184
|
+
vertical: computed(() => props.orientation === "vertical"),
|
|
183
185
|
setValue,
|
|
184
186
|
});
|
|
185
187
|
const applyThumbSizing = (isVertical, attemptScroll) => {
|
|
@@ -213,7 +215,9 @@ const TabsComponent = defineComponent({
|
|
|
213
215
|
const bottom = top + targetHeight;
|
|
214
216
|
if (top < scrollTop + buffer || bottom > scrollTop + rootHeight - buffer) {
|
|
215
217
|
if (attemptScroll) {
|
|
216
|
-
|
|
218
|
+
// Scroll the control only: scrollIntoView also scrolls the page to it (a switch to Phone
|
|
219
|
+
// re-rendered a control far down the page and slid the page to it, owner 08.11)
|
|
220
|
+
root.scrollTo({ top: top - (rootHeight - targetHeight) / 2, behavior: prefersReducedMotion() ? "auto" : "smooth" });
|
|
217
221
|
}
|
|
218
222
|
}
|
|
219
223
|
}
|
|
@@ -240,7 +244,9 @@ const TabsComponent = defineComponent({
|
|
|
240
244
|
if (left < scrollLeft + buffer || right > scrollLeft + rootWidth - buffer) {
|
|
241
245
|
// Cheap trick to avoid unintentional scroll on mount - transition is set after mounting
|
|
242
246
|
if (attemptScroll) {
|
|
243
|
-
|
|
247
|
+
// Scroll the control only: scrollIntoView also scrolls the page to it (a switch to Phone
|
|
248
|
+
// re-rendered a control far down the page and slid the page to it, owner 08.11)
|
|
249
|
+
root.scrollTo({ left: left - (rootWidth - targetWidth) / 2, behavior: prefersReducedMotion() ? "auto" : "smooth" });
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
252
|
}
|
|
@@ -386,6 +392,7 @@ const TabsComponent = defineComponent({
|
|
|
386
392
|
"data-flush": isFlush ? "" : undefined,
|
|
387
393
|
"data-size": props.size,
|
|
388
394
|
"data-gutter-size": props.gutterSize,
|
|
395
|
+
"data-disabled": props.disabled ? "" : undefined,
|
|
389
396
|
...restAttrs,
|
|
390
397
|
}, { default: () => [h("div", { class: s.TabsThumb, ref: thumbRef }), slots.default?.()] }),
|
|
391
398
|
});
|
|
@@ -494,6 +501,7 @@ const TabComponent = defineComponent({
|
|
|
494
501
|
}, badgeProps.loading ? [h(LoadingIndicator)] : [badgeProps.content])
|
|
495
502
|
: null,
|
|
496
503
|
]),
|
|
504
|
+
context.vertical.value ? h(CheckMd, { "class": s.TabCheckmark, "aria-hidden": "true" }) : null,
|
|
497
505
|
],
|
|
498
506
|
}),
|
|
499
507
|
});
|