@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,215 @@
|
|
|
1
|
+
import { computed, defineComponent, h, onBeforeUnmount, ref, watch } from "vue";
|
|
2
|
+
import s from "@plexui/styles/components/IndexBar/IndexBar.module.css";
|
|
3
|
+
// Vue port of packages/ui/src/components/IndexBar/IndexBar.tsx: the same strip and slider, the same dots on a
|
|
4
|
+
// short screen, presses, drags and keys. React's `onSelect` becomes the `select` event.
|
|
5
|
+
/**
|
|
6
|
+
* What the bar shows: the index of each title, or `null` for a dot. Every title shows while they fit in `capacity`
|
|
7
|
+
* lines, or while `capacity` is not known (`undefined`). Otherwise the first and the last title keep their places
|
|
8
|
+
* and titles spread evenly between them, a dot in each line between two, as UIKit's index shortens itself on a
|
|
9
|
+
* short screen; two lines hold the first and the last title, one the first, none nothing.
|
|
10
|
+
*/
|
|
11
|
+
export const indexBarSlots = (count, capacity) => {
|
|
12
|
+
const length = Math.max(0, count);
|
|
13
|
+
if (capacity === undefined || !(capacity >= 0) || length <= capacity)
|
|
14
|
+
return Array.from({ length }, (_, index) => index);
|
|
15
|
+
if (capacity < 3)
|
|
16
|
+
return [0, length - 1].slice(0, Math.floor(capacity));
|
|
17
|
+
const lines = capacity % 2 === 0 ? capacity - 1 : capacity;
|
|
18
|
+
const shown = (lines + 1) / 2;
|
|
19
|
+
const slots = [];
|
|
20
|
+
for (let i = 0; i < shown; i++) {
|
|
21
|
+
if (i > 0)
|
|
22
|
+
slots.push(null);
|
|
23
|
+
slots.push(Math.round((i * (length - 1)) / (shown - 1)));
|
|
24
|
+
}
|
|
25
|
+
return slots;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The title under a pointer. A letter is its own title; a dot stands for the titles hidden between the letters
|
|
29
|
+
* on either side, and the finger moves through them across its line.
|
|
30
|
+
*/
|
|
31
|
+
const indexAt = (rail, clientY, slots) => {
|
|
32
|
+
const rect = rail.getBoundingClientRect();
|
|
33
|
+
if (!(rect.height > 0) || slots.length < 1)
|
|
34
|
+
return undefined;
|
|
35
|
+
const offset = ((clientY - rect.top) / rect.height) * slots.length;
|
|
36
|
+
const line = Math.min(slots.length - 1, Math.max(0, Math.floor(offset)));
|
|
37
|
+
const slot = slots[line];
|
|
38
|
+
if (slot !== null && slot !== undefined)
|
|
39
|
+
return slot;
|
|
40
|
+
const before = slots[line - 1] ?? 0;
|
|
41
|
+
const after = slots[line + 1] ?? before;
|
|
42
|
+
const hidden = after - before - 1;
|
|
43
|
+
const within = Math.min(1, Math.max(0, offset - line));
|
|
44
|
+
if (hidden < 1)
|
|
45
|
+
return within < 0.5 ? before : after;
|
|
46
|
+
return before + 1 + Math.min(hidden - 1, Math.floor(within * hidden));
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* How many lines fit in the strip: its height between the bars of the Page (or the safe areas) over the rail's
|
|
50
|
+
* resolved line height, or `undefined` while the strip is not laid out (hidden from 768px up, or before layout).
|
|
51
|
+
*/
|
|
52
|
+
const capacityOf = (strip, rail) => {
|
|
53
|
+
if (!(strip.clientHeight > 0) || !rail)
|
|
54
|
+
return undefined;
|
|
55
|
+
const styles = getComputedStyle(strip);
|
|
56
|
+
const available = strip.clientHeight - parseFloat(styles.paddingTop || "0") - parseFloat(styles.paddingBottom || "0");
|
|
57
|
+
const line = parseFloat(getComputedStyle(rail).lineHeight);
|
|
58
|
+
return line > 0 ? Math.max(0, Math.floor(available / line)) : undefined;
|
|
59
|
+
};
|
|
60
|
+
const IndexBarComponent = defineComponent({
|
|
61
|
+
name: "IndexBar",
|
|
62
|
+
inheritAttrs: false,
|
|
63
|
+
props: {
|
|
64
|
+
/** The `id` of the index bar. */
|
|
65
|
+
id: String,
|
|
66
|
+
/** The titles of the sections, in order: usually letters, such as `"A"` to `"Z"` and `"#"`. */
|
|
67
|
+
items: { type: Array, required: true },
|
|
68
|
+
/** Accessible name of the index bar. @default "Section index" */
|
|
69
|
+
ariaLabel: { type: String, default: "Section index" },
|
|
70
|
+
/** The `id` of the list the index scrolls. */
|
|
71
|
+
ariaControls: String,
|
|
72
|
+
},
|
|
73
|
+
emits: {
|
|
74
|
+
/** The section to show: on a press, on each new letter while dragging, and from the keys (React `onSelect`) */
|
|
75
|
+
select: (item, index) => typeof item === "string" && typeof index === "number",
|
|
76
|
+
/** The index bar gained focus */
|
|
77
|
+
focus: (event) => event.type === "focus",
|
|
78
|
+
/** The index bar lost focus */
|
|
79
|
+
blur: (event) => event.type === "blur",
|
|
80
|
+
},
|
|
81
|
+
setup(props, { attrs, emit }) {
|
|
82
|
+
const current = ref(0);
|
|
83
|
+
const capacity = ref(undefined);
|
|
84
|
+
const pressed = ref(false);
|
|
85
|
+
const strip = ref(null);
|
|
86
|
+
const rail = ref(null);
|
|
87
|
+
let press = null;
|
|
88
|
+
let observer = null;
|
|
89
|
+
const count = computed(() => props.items.length);
|
|
90
|
+
const index = computed(() => Math.min(current.value, Math.max(0, count.value - 1)));
|
|
91
|
+
const slots = computed(() => indexBarSlots(count.value, capacity.value));
|
|
92
|
+
// The strip changes with the screen, the rail with the line height.
|
|
93
|
+
watch([strip, rail], ([element, railElement]) => {
|
|
94
|
+
observer?.disconnect();
|
|
95
|
+
observer = null;
|
|
96
|
+
if (!element || typeof ResizeObserver === "undefined")
|
|
97
|
+
return;
|
|
98
|
+
const measure = () => { capacity.value = capacityOf(element, railElement); };
|
|
99
|
+
observer = new ResizeObserver(measure);
|
|
100
|
+
observer.observe(element);
|
|
101
|
+
if (railElement)
|
|
102
|
+
observer.observe(railElement);
|
|
103
|
+
measure();
|
|
104
|
+
}, { flush: "post" });
|
|
105
|
+
onBeforeUnmount(() => observer?.disconnect());
|
|
106
|
+
const select = (next) => {
|
|
107
|
+
const item = props.items[next];
|
|
108
|
+
if (item === undefined)
|
|
109
|
+
return;
|
|
110
|
+
current.value = next;
|
|
111
|
+
emit("select", item, next);
|
|
112
|
+
};
|
|
113
|
+
const end = () => {
|
|
114
|
+
press = null;
|
|
115
|
+
pressed.value = false;
|
|
116
|
+
};
|
|
117
|
+
// A gesture ends with its rail: the letters can go away under the finger.
|
|
118
|
+
watch(count, (value) => {
|
|
119
|
+
if (value < 1 && press)
|
|
120
|
+
end();
|
|
121
|
+
});
|
|
122
|
+
const handlePointerDown = (event) => {
|
|
123
|
+
const target = event.currentTarget;
|
|
124
|
+
if (event.button !== 0 || press || !(target instanceof HTMLElement))
|
|
125
|
+
return;
|
|
126
|
+
const next = indexAt(target, event.clientY, slots.value);
|
|
127
|
+
if (next === undefined)
|
|
128
|
+
return;
|
|
129
|
+
target.setPointerCapture?.(event.pointerId);
|
|
130
|
+
press = { pointerId: event.pointerId, index: next };
|
|
131
|
+
pressed.value = true;
|
|
132
|
+
select(next);
|
|
133
|
+
};
|
|
134
|
+
const handlePointerMove = (event) => {
|
|
135
|
+
const state = press;
|
|
136
|
+
const target = event.currentTarget;
|
|
137
|
+
if (!state || state.pointerId !== event.pointerId || !(target instanceof HTMLElement))
|
|
138
|
+
return;
|
|
139
|
+
const next = indexAt(target, event.clientY, slots.value);
|
|
140
|
+
if (next === undefined || next === state.index)
|
|
141
|
+
return;
|
|
142
|
+
state.index = next;
|
|
143
|
+
select(next);
|
|
144
|
+
};
|
|
145
|
+
/** The pointer of the gesture lifted, was cancelled or lost its capture; another pointer ends nothing. */
|
|
146
|
+
const handlePointerEnd = (event) => {
|
|
147
|
+
if (press?.pointerId === event.pointerId)
|
|
148
|
+
end();
|
|
149
|
+
};
|
|
150
|
+
const handleKeyDown = (event) => {
|
|
151
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || slots.value.length < 1)
|
|
152
|
+
return;
|
|
153
|
+
const keys = {
|
|
154
|
+
ArrowDown: index.value + 1,
|
|
155
|
+
ArrowRight: index.value + 1,
|
|
156
|
+
ArrowUp: index.value - 1,
|
|
157
|
+
ArrowLeft: index.value - 1,
|
|
158
|
+
Home: 0,
|
|
159
|
+
End: count.value - 1,
|
|
160
|
+
Enter: index.value,
|
|
161
|
+
" ": index.value,
|
|
162
|
+
};
|
|
163
|
+
const target = keys[event.key];
|
|
164
|
+
if (target === undefined)
|
|
165
|
+
return;
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
const next = Math.min(count.value - 1, Math.max(0, target));
|
|
168
|
+
if (next !== index.value || event.key === "Enter" || event.key === " ")
|
|
169
|
+
select(next);
|
|
170
|
+
};
|
|
171
|
+
return () => {
|
|
172
|
+
if (count.value < 1)
|
|
173
|
+
return null;
|
|
174
|
+
return h("div", { ...attrs, "ref": strip, "class": [s.IndexBar, attrs.class], "data-index-bar": "" }, [
|
|
175
|
+
h("div", {
|
|
176
|
+
"ref": rail,
|
|
177
|
+
"id": props.id,
|
|
178
|
+
"role": "slider",
|
|
179
|
+
"tabindex": 0,
|
|
180
|
+
"aria-orientation": "vertical",
|
|
181
|
+
"aria-valuemin": 1,
|
|
182
|
+
"aria-valuemax": count.value,
|
|
183
|
+
"aria-valuenow": index.value + 1,
|
|
184
|
+
"aria-valuetext": props.items[index.value],
|
|
185
|
+
"aria-label": props.ariaLabel,
|
|
186
|
+
"aria-controls": props.ariaControls,
|
|
187
|
+
// No room for a line between the bars: the bar stays measurable and leaves the focus order.
|
|
188
|
+
"hidden": slots.value.length < 1 ? true : undefined,
|
|
189
|
+
"class": s.Rail,
|
|
190
|
+
"data-pressed": pressed.value ? "" : undefined,
|
|
191
|
+
"onPointerdown": handlePointerDown,
|
|
192
|
+
"onPointermove": handlePointerMove,
|
|
193
|
+
"onPointerup": handlePointerEnd,
|
|
194
|
+
"onPointercancel": handlePointerEnd,
|
|
195
|
+
"onLostpointercapture": handlePointerEnd,
|
|
196
|
+
"onKeydown": handleKeyDown,
|
|
197
|
+
"onFocus": (event) => emit("focus", event),
|
|
198
|
+
"onBlur": (event) => emit("blur", event),
|
|
199
|
+
}, slots.value.map((slot, position) => slot === null
|
|
200
|
+
? h("span", { "key": `dot-${position}`, "class": s.Item, "aria-hidden": "true", "data-dot": "" }, "•")
|
|
201
|
+
: h("span", { "key": slot, "class": s.Item, "aria-hidden": "true", "data-index": slot }, props.items[slot]))),
|
|
202
|
+
]);
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
/**
|
|
207
|
+
* The section index of a phone list, as the iOS section index: a column of letters at the trailing edge of the
|
|
208
|
+
* nearest positioned container (a Page), centred between the bars of the Page. A press shows the section of the letter under the
|
|
209
|
+
* finger, and a drag moves through the sections letter by letter. On a short screen every other letter gives
|
|
210
|
+
* way to a dot. It is one slider for assistive technology: Down and Up (or Right and Left) move one section, Home
|
|
211
|
+
* and End go to the first and the last, and Enter or Space shows the current one again. A desktop list has no
|
|
212
|
+
* index, so the bar renders under 768px only.
|
|
213
|
+
*/
|
|
214
|
+
export const IndexBar = IndexBarComponent;
|
|
215
|
+
//# sourceMappingURL=IndexBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexBar.js","sourceRoot":"","sources":["../../../../src/components/IndexBar/IndexBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAC9F,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAEtE,8GAA8G;AAC9G,wFAAwF;AAExF;;;;;GAKG;AACH,MAAM,CAAC,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CAAC,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;oBACtG,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAChH,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAA","sourcesContent":["import { computed, defineComponent, h, onBeforeUnmount, ref, watch, type PropType } from \"vue\"\nimport s from \"@plexui/styles/components/IndexBar/IndexBar.module.css\"\n\n// Vue port of packages/ui/src/components/IndexBar/IndexBar.tsx: the same strip and slider, the same dots on a\n// short screen, presses, drags and keys. React's `onSelect` becomes the `select` event.\n\n/**\n * What the bar shows: the index of each title, or `null` for a dot. Every title shows while they fit in `capacity`\n * lines, or while `capacity` is not known (`undefined`). Otherwise the first and the last title keep their places\n * and titles spread evenly between them, a dot in each line between two, as UIKit's index shortens itself on a\n * short screen; two lines hold the first and the last title, one the first, none nothing.\n */\nexport const indexBarSlots = (count: number, capacity?: number): Array<number | null> => {\n const length = Math.max(0, count)\n if (capacity === undefined || !(capacity >= 0) || length <= capacity) return Array.from({ length }, (_, index) => index)\n if (capacity < 3) return [0, length - 1].slice(0, Math.floor(capacity))\n const lines = capacity % 2 === 0 ? capacity - 1 : capacity\n const shown = (lines + 1) / 2\n const slots: Array<number | null> = []\n for (let i = 0; i < shown; i++) {\n if (i > 0) slots.push(null)\n slots.push(Math.round((i * (length - 1)) / (shown - 1)))\n }\n return slots\n}\n\n/**\n * The title under a pointer. A letter is its own title; a dot stands for the titles hidden between the letters\n * on either side, and the finger moves through them across its line.\n */\nconst indexAt = (rail: HTMLElement, clientY: number, slots: Array<number | null>) => {\n const rect = rail.getBoundingClientRect()\n if (!(rect.height > 0) || slots.length < 1) return undefined\n const offset = ((clientY - rect.top) / rect.height) * slots.length\n const line = Math.min(slots.length - 1, Math.max(0, Math.floor(offset)))\n const slot = slots[line]\n if (slot !== null && slot !== undefined) return slot\n const before = slots[line - 1] ?? 0\n const after = slots[line + 1] ?? before\n const hidden = after - before - 1\n const within = Math.min(1, Math.max(0, offset - line))\n if (hidden < 1) return within < 0.5 ? before : after\n return before + 1 + Math.min(hidden - 1, Math.floor(within * hidden))\n}\n\n/**\n * How many lines fit in the strip: its height between the bars of the Page (or the safe areas) over the rail's\n * resolved line height, or `undefined` while the strip is not laid out (hidden from 768px up, or before layout).\n */\nconst capacityOf = (strip: HTMLElement, rail: HTMLElement | null) => {\n if (!(strip.clientHeight > 0) || !rail) return undefined\n const styles = getComputedStyle(strip)\n const available = strip.clientHeight - parseFloat(styles.paddingTop || \"0\") - parseFloat(styles.paddingBottom || \"0\")\n const line = parseFloat(getComputedStyle(rail).lineHeight)\n return line > 0 ? Math.max(0, Math.floor(available / line)) : undefined\n}\n\nconst IndexBarComponent = defineComponent({\n name: \"IndexBar\",\n inheritAttrs: false,\n props: {\n /** The `id` of the index bar. */\n id: String,\n /** The titles of the sections, in order: usually letters, such as `\"A\"` to `\"Z\"` and `\"#\"`. */\n items: { type: Array as PropType<string[]>, required: true },\n /** Accessible name of the index bar. @default \"Section index\" */\n ariaLabel: { type: String, default: \"Section index\" },\n /** The `id` of the list the index scrolls. */\n ariaControls: String,\n },\n emits: {\n /** The section to show: on a press, on each new letter while dragging, and from the keys (React `onSelect`) */\n select: (item: string, index: number) => typeof item === \"string\" && typeof index === \"number\",\n /** The index bar gained focus */\n focus: (event: FocusEvent) => event.type === \"focus\",\n /** The index bar lost focus */\n blur: (event: FocusEvent) => event.type === \"blur\",\n },\n setup(props, { attrs, emit }) {\n const current = ref(0)\n const capacity = ref<number | undefined>(undefined)\n const pressed = ref(false)\n const strip = ref<HTMLElement | null>(null)\n const rail = ref<HTMLElement | null>(null)\n let press: { pointerId: number; index: number } | null = null\n let observer: ResizeObserver | null = null\n const count = computed(() => props.items.length)\n const index = computed(() => Math.min(current.value, Math.max(0, count.value - 1)))\n const slots = computed(() => indexBarSlots(count.value, capacity.value))\n\n // The strip changes with the screen, the rail with the line height.\n watch([strip, rail], ([element, railElement]) => {\n observer?.disconnect()\n observer = null\n if (!element || typeof ResizeObserver === \"undefined\") return\n const measure = () => { capacity.value = capacityOf(element, railElement) }\n observer = new ResizeObserver(measure)\n observer.observe(element)\n if (railElement) observer.observe(railElement)\n measure()\n }, { flush: \"post\" })\n onBeforeUnmount(() => observer?.disconnect())\n\n const select = (next: number) => {\n const item = props.items[next]\n if (item === undefined) return\n current.value = next\n emit(\"select\", item, next)\n }\n\n const end = () => {\n press = null\n pressed.value = false\n }\n\n // A gesture ends with its rail: the letters can go away under the finger.\n watch(count, (value) => {\n if (value < 1 && press) end()\n })\n\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.currentTarget\n if (event.button !== 0 || press || !(target instanceof HTMLElement)) return\n const next = indexAt(target, event.clientY, slots.value)\n if (next === undefined) return\n target.setPointerCapture?.(event.pointerId)\n press = { pointerId: event.pointerId, index: next }\n pressed.value = true\n select(next)\n }\n\n const handlePointerMove = (event: PointerEvent) => {\n const state = press\n const target = event.currentTarget\n if (!state || state.pointerId !== event.pointerId || !(target instanceof HTMLElement)) return\n const next = indexAt(target, event.clientY, slots.value)\n if (next === undefined || next === state.index) return\n state.index = next\n select(next)\n }\n\n /** The pointer of the gesture lifted, was cancelled or lost its capture; another pointer ends nothing. */\n const handlePointerEnd = (event: PointerEvent) => {\n if (press?.pointerId === event.pointerId) end()\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || slots.value.length < 1) return\n const keys: Record<string, number> = {\n ArrowDown: index.value + 1,\n ArrowRight: index.value + 1,\n ArrowUp: index.value - 1,\n ArrowLeft: index.value - 1,\n Home: 0,\n End: count.value - 1,\n Enter: index.value,\n \" \": index.value,\n }\n const target = keys[event.key]\n if (target === undefined) return\n event.preventDefault()\n const next = Math.min(count.value - 1, Math.max(0, target))\n if (next !== index.value || event.key === \"Enter\" || event.key === \" \") select(next)\n }\n\n return () => {\n if (count.value < 1) return null\n return h(\"div\", { ...attrs, \"ref\": strip, \"class\": [s.IndexBar, attrs.class], \"data-index-bar\": \"\" }, [\n h(\"div\", {\n \"ref\": rail,\n \"id\": props.id,\n \"role\": \"slider\",\n \"tabindex\": 0,\n \"aria-orientation\": \"vertical\",\n \"aria-valuemin\": 1,\n \"aria-valuemax\": count.value,\n \"aria-valuenow\": index.value + 1,\n \"aria-valuetext\": props.items[index.value],\n \"aria-label\": props.ariaLabel,\n \"aria-controls\": props.ariaControls,\n // No room for a line between the bars: the bar stays measurable and leaves the focus order.\n \"hidden\": slots.value.length < 1 ? true : undefined,\n \"class\": s.Rail,\n \"data-pressed\": pressed.value ? \"\" : undefined,\n \"onPointerdown\": handlePointerDown,\n \"onPointermove\": handlePointerMove,\n \"onPointerup\": handlePointerEnd,\n \"onPointercancel\": handlePointerEnd,\n \"onLostpointercapture\": handlePointerEnd,\n \"onKeydown\": handleKeyDown,\n \"onFocus\": (event: FocusEvent) => emit(\"focus\", event),\n \"onBlur\": (event: FocusEvent) => emit(\"blur\", event),\n }, slots.value.map((slot, position) => slot === null\n ? h(\"span\", { \"key\": `dot-${position}`, \"class\": s.Item, \"aria-hidden\": \"true\", \"data-dot\": \"\" }, \"•\")\n : h(\"span\", { \"key\": slot, \"class\": s.Item, \"aria-hidden\": \"true\", \"data-index\": slot }, props.items[slot]))),\n ])\n }\n },\n})\n\ntype IndexBarOwnProps = InstanceType<typeof IndexBarComponent>[\"$props\"]\n\n/** IndexBar props. */\nexport type IndexBarProps = IndexBarOwnProps\n\n/**\n * The section index of a phone list, as the iOS section index: a column of letters at the trailing edge of the\n * nearest positioned container (a Page), centred between the bars of the Page. A press shows the section of the letter under the\n * finger, and a drag moves through the sections letter by letter. On a short screen every other letter gives\n * way to a dot. It is one slider for assistive technology: Down and Up (or Right and Left) move one section, Home\n * and End go to the first and the last, and Enter or Space shows the current one again. A desktop list has no\n * index, so the bar renders under 768px only.\n */\nexport const IndexBar = IndexBarComponent\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/IndexBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAsB,MAAM,eAAe,CAAA","sourcesContent":["export { IndexBar, indexBarSlots, type IndexBarProps } from \"./IndexBar.js\"\n"]}
|
|
@@ -4,7 +4,7 @@ import s from "@plexui/styles/components/Indicator/LoadingIndicator.module.css";
|
|
|
4
4
|
const LoadingIndicatorComponent = defineComponent({
|
|
5
5
|
name: "LoadingIndicator",
|
|
6
6
|
props: {
|
|
7
|
-
/** Size of the indicator, in pixels. Defaults to 1em, or
|
|
7
|
+
/** Size of the indicator, in pixels. Defaults to 1em, or 20px with the touch stylesheet. */
|
|
8
8
|
size: [Number, String],
|
|
9
9
|
/** Stroke width of the indicator, in pixels. Defaults to 2. */
|
|
10
10
|
strokeWidth: Number,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingIndicator.js","sourceRoot":"","sources":["../../../../src/components/Indicator/LoadingIndicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAE/E,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAChD,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE;QACL,4FAA4F;QAC5F,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA8B;QACnD,+DAA+D;QAC/D,WAAW,EAAE,MAAM;KACpB;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,GAAG,EAAE,CACV,CAAC,CAAC,MAAM,EAAE;YACR,KAAK,EAAE,CAAC,CAAC,gBAAgB;YACzB,wEAAwE;YACxE,KAAK,EAAE,KAAK,CAAC,KAAK;gBAChB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,cAAc,CAAC;oBACb,gBAAgB,EAAE,KAAK,CAAC,IAAI;oBAC5B,kBAAkB,EAAE,KAAK,CAAC,WAAW;iBACtC,CAAC;SACP,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;IACjH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAE/B,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport { toCssVariables } from \"../../lib/helpers.js\"\nimport s from \"@plexui/styles/components/Indicator/LoadingIndicator.module.css\"\n\nconst LoadingIndicatorComponent = defineComponent({\n name: \"LoadingIndicator\",\n props: {\n /** Size of the indicator, in pixels. Defaults to 1em, or
|
|
1
|
+
{"version":3,"file":"LoadingIndicator.js","sourceRoot":"","sources":["../../../../src/components/Indicator/LoadingIndicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAE/E,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAChD,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE;QACL,4FAA4F;QAC5F,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA8B;QACnD,+DAA+D;QAC/D,WAAW,EAAE,MAAM;KACpB;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,GAAG,EAAE,CACV,CAAC,CAAC,MAAM,EAAE;YACR,KAAK,EAAE,CAAC,CAAC,gBAAgB;YACzB,wEAAwE;YACxE,KAAK,EAAE,KAAK,CAAC,KAAK;gBAChB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,cAAc,CAAC;oBACb,gBAAgB,EAAE,KAAK,CAAC,IAAI;oBAC5B,kBAAkB,EAAE,KAAK,CAAC,WAAW;iBACtC,CAAC;SACP,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;IACjH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAE/B,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport { toCssVariables } from \"../../lib/helpers.js\"\nimport s from \"@plexui/styles/components/Indicator/LoadingIndicator.module.css\"\n\nconst LoadingIndicatorComponent = defineComponent({\n name: \"LoadingIndicator\",\n props: {\n /** Size of the indicator, in pixels. Defaults to 1em, or 20px with the touch stylesheet. */\n size: [Number, String] as PropType<number | string>,\n /** Stroke width of the indicator, in pixels. Defaults to 2. */\n strokeWidth: Number,\n },\n setup(props, { attrs }) {\n return () =>\n h(\"span\", {\n class: s.LoadingIndicator,\n // A style passed by the caller replaces the size variables, as in React\n style: attrs.style\n ? undefined\n : toCssVariables({\n \"indicator-size\": props.size,\n \"indicator-stroke\": props.strokeWidth,\n }),\n }, Array.from({ length: 8 }, (_, index) => h(\"span\", { key: index, class: s.Spoke, \"aria-hidden\": \"true\" })))\n },\n})\n\ntype LoadingIndicatorOwnProps = InstanceType<typeof LoadingIndicatorComponent>[\"$props\"]\n\n/** LoadingIndicator props plus the native <span> attributes that fall through to it, as in React. */\nexport type LoadingIndicatorProps = LoadingIndicatorOwnProps & Omit<HTMLAttributes, keyof LoadingIndicatorOwnProps>\n\nexport const LoadingIndicator = LoadingIndicatorComponent as typeof LoadingIndicatorComponent & {\n new (): { $props: LoadingIndicatorProps }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import clsx, {} from "clsx";
|
|
2
2
|
import { defineComponent, h, mergeProps, nextTick, onMounted, ref, useId, watch, withDirectives } from "vue";
|
|
3
|
-
import { X } from "../Icon/index.js";
|
|
3
|
+
import { X, XCircleFilled } from "../Icon/index.js";
|
|
4
4
|
import { vDefaultValue } from "../../lib/defaultValue.js";
|
|
5
5
|
import { useFieldRowPill } from "../../lib/fieldRow.js";
|
|
6
6
|
import { hasContent } from "../../lib/slotContent.js";
|
|
@@ -225,7 +225,8 @@ const InputComponent = defineComponent({
|
|
|
225
225
|
})), [[vDefaultValue, value === undefined ? defaultValue : undefined]]),
|
|
226
226
|
showClearButton
|
|
227
227
|
? h("button", { "type": "button", "aria-label": "Clear input", "class": s.Clear, "onClick": handleClear }, [
|
|
228
|
-
h(X),
|
|
228
|
+
h(X, { class: s.ClearIcon }),
|
|
229
|
+
h(XCircleFilled, { class: s.ClearPhoneIcon }),
|
|
229
230
|
])
|
|
230
231
|
: null,
|
|
231
232
|
hasEndAdornment ? endAdornment : null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/components/Input/Input.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,CAAC,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,IAAI,EAAE,EAAE,IAAI,EAAE,MAAiD,EAAE,OAAO,EAAE,QAAQ,EAAE;QACpF;;;WAGG;QACH,KAAK,EAAE,MAAiC;KACzC;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,GAAG,EAAE,CACV,CAAC,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,eAAe,EAAE,YAAY,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACjH,CAAC;CACF,CAAC,CAAA;AAQF,MAAM,CAAC,MAAM,oBAAoB,GAAG,6BAEnC,CAAA","sourcesContent":["import clsx, { type ClassValue } from \"clsx\"\nimport { defineComponent, h, mergeProps, nextTick, onMounted, ref, useId, watch, withDirectives, type ButtonHTMLAttributes, type InputHTMLAttributes, type PropType } from \"vue\"\nimport type { ControlSize, SemanticColor, Sizes, Variants } from \"@plexui/styles/types\"\nimport { X } from \"../Icon/index.js\"\nimport { vDefaultValue } from \"../../lib/defaultValue.js\"\nimport { useFieldRowPill } from \"../../lib/fieldRow.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/Input/Input.module.css\"\n\n// Vue port of packages/ui/src/components/Input/Input.tsx.\n// - `class` goes to the container; every other attribute and native listener\n// (`@input`, `@change`, `@focus`, `style`, `placeholder`, ...) goes to the\n// <input>, as React spreads its rest props there.\n// - `value` + `update:value` support `v-model:value`; `default-value` sets the\n// initial value of an uncontrolled input through `vDefaultValue` (server\n// markup, hydration and later changes as in React), so re-renders never\n// reset what the user typed.\n// - `startAdornment` / `endAdornment` are slots. `onClear` stays a function\n// prop (`@clear` in templates) because its presence adds the clear button.\n// - `autoComplete` reaches the <input> as `autocomplete`, and `invalid` also\n// sets `aria-invalid` there unless the caller passes its own, as in React.\n\nconst InputComponent = defineComponent({\n name: \"Input\",\n inheritAttrs: false,\n props: {\n /** Visual style of the input. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"outline\" | \"soft\" | \"ghost\">>, default: \"outline\" },\n /** Controls the size of the input: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Controls gutter on the edges of the input, defaults to value from `size`. */\n gutterSize: String as PropType<Sizes<\"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">>,\n /** Disables the input visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Makes the input read-only. @default false */\n readOnly: { type: Boolean, default: false },\n /** Native spelling of `readOnly` (`<Input readonly />`). @default false */\n readonly: { type: Boolean, default: false },\n /** Mark the input as invalid. @default false */\n invalid: { type: Boolean, default: false },\n /**\n * Allow autofill extensions to appear in the input.\n * @default true when `type=\"password\"` or `name` is set, otherwise false\n */\n allowAutofillExtensions: { type: Boolean, default: undefined },\n /** Select all contents of the input when mounted, and whenever it turns true. @default false */\n autoSelect: { type: Boolean, default: undefined },\n /** Shows the clear button while the input has a value; called when it is clicked. */\n onClear: Function as PropType<(event: MouseEvent) => void>,\n /** Fully rounded pill shape. @default false, or true at the end of a `Field row` */\n pill: { type: Boolean, default: undefined },\n /** Applies a negative margin using the current gutter to optically align the input with surrounding content. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n id: String,\n name: String,\n /** @default \"text\" */\n type: { type: String, default: \"text\" },\n /** Controlled value. Bind `v-model:value` to keep it in sync. */\n value: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Initial value when uncontrolled. */\n defaultValue: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Native `autocomplete` of the <input>. */\n autoComplete: String,\n },\n emits: {\n \"update:value\": (value: string) => typeof value === \"string\",\n \"autofill\": () => true,\n },\n setup(props, { attrs, slots, emit, expose }) {\n const inputRef = ref<HTMLInputElement | null>(null)\n // Prevent 1Password from appearing: 1Password won't display if it thinks this field is for searching\n // Allow user to override this for connecting to labels.\n const onePasswordPreventionId = `search-ui-input-${useId()}`\n const pill = useFieldRowPill(() => props.pill)\n const focused = ref(false)\n\n // Redirect clicks on the container and adornments\n const handleMouseDown = (evt: MouseEvent) => {\n const input = inputRef.value\n // Bail out if the target is not an element or the input is not found\n if (!evt.target || !(evt.target instanceof Element) || !input) {\n return\n }\n // Bail out if the target is inside the input\n if (input.contains(evt.target)) {\n return\n }\n // Bail out if the target is a button\n if (evt.target.closest(\"button, [type='button'], [role='button'], [role='menuitem']\")) {\n return\n }\n\n evt.preventDefault()\n // If the input is not focused, focus it\n if (document.activeElement !== input) {\n input.focus()\n }\n\n const { left, top } = input.getBoundingClientRect()\n const { clientX, clientY } = evt\n // \"Before\" the input: top/left\n const isBefore = clientY < top || clientX < left\n // email, number and other types without the selection API throw on setSelectionRange\n const hasSelection = input.selectionStart !== null\n\n // If this is the first click, clear the selection.\n if (evt.detail === 1) {\n if (!hasSelection) return\n if (isBefore) {\n input.setSelectionRange(0, 0)\n } else {\n const length = input.value.length\n input.setSelectionRange(length, length)\n }\n }\n // If this is the second click, select the first or last word\n else if (evt.detail === 2) {\n if (!hasSelection) return\n // Split the input value into words and non-word characters\n const words = input.value.match(/\\w+|[^\\w\\s]/g) || []\n const selectedWord = isBefore ? words.at(0) : words.at(-1)\n if (selectedWord) {\n const wordIndex = isBefore ? input.value.indexOf(selectedWord) : input.value.lastIndexOf(selectedWord)\n input.setSelectionRange(wordIndex, wordIndex + selectedWord.length)\n }\n }\n // If this is the third click or greater, select the entire input\n else {\n input.select()\n }\n }\n\n const selectIfAuto = () => {\n if (props.autoSelect) {\n inputRef.value?.select()\n }\n }\n onMounted(() => {\n selectIfAuto()\n // An enclosing focus scope may focus the input during the same mount.\n // Reconcile after the mount finishes without focusing it a second time.\n void nextTick(() => {\n const input = inputRef.value\n focused.value = !!input && input.ownerDocument.activeElement === input\n })\n })\n watch(() => props.autoSelect, selectIfAuto, { flush: \"post\" })\n\n // The clear button unmounts once the value is gone, so keep focus in the input\n const handleClear = (evt: MouseEvent) => {\n inputRef.value?.focus()\n props.onClear?.(evt)\n }\n\n const handleAnimationStart = (evt: AnimationEvent) => {\n if (evt.animationName === \"native-autofill-in\") {\n emit(\"autofill\")\n }\n }\n\n const handleInput = (evt: Event) => {\n const target = evt.currentTarget as HTMLInputElement\n emit(\"update:value\", target.value)\n // Like a React controlled input, a `value` the parent does not update\n // is put back (Vue only re-applies `value` when this component renders)\n void nextTick(() => {\n if (props.value === undefined) return\n const value = String(props.value)\n if (target.value !== value) target.value = value\n })\n }\n\n expose({ focus: () => inputRef.value?.focus(), input: inputRef })\n\n return () => {\n const { class: className, ...restAttrs } = attrs\n const { value, defaultValue, disabled } = props\n const readOnly = props.readOnly || props.readonly\n // Default to `true` when type=\"password\" or presence of `name`\n const allowAutofillExtensions = props.allowAutofillExtensions ?? (props.type === \"password\" || !!props.name)\n const startAdornment = slots.startAdornment?.()\n const endAdornment = slots.endAdornment?.()\n const hasStartAdornment = hasContent(startAdornment)\n const hasEndAdornment = hasContent(endAdornment)\n\n // Determine if clear button should be shown\n const hasValue = String((value !== undefined ? value : defaultValue) ?? \"\") !== \"\"\n const showClearButton = !!props.onClear && hasValue && !disabled && !readOnly\n\n return h(\n \"div\",\n {\n \"class\": clsx(s.Container, className as ClassValue),\n \"data-slot\": \"input\",\n \"data-variant\": props.variant,\n \"data-size\": props.size,\n \"data-gutter-size\": props.gutterSize,\n \"data-focused\": focused.value,\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-readonly\": readOnly ? \"\" : undefined,\n \"data-invalid\": props.invalid ? \"\" : undefined,\n \"data-pill\": pill.value ? \"\" : undefined,\n \"data-optically-align\": props.opticallyAlign,\n \"data-has-start-adornment\": hasStartAdornment ? \"\" : undefined,\n \"data-has-end-adornment\": hasEndAdornment || showClearButton ? \"\" : undefined,\n \"onMousedown\": handleMouseDown,\n },\n [\n hasStartAdornment ? startAdornment : null,\n withDirectives(\n h(\n \"input\",\n mergeProps(restAttrs, {\n \"ref\": inputRef,\n \"id\": props.id || (allowAutofillExtensions ? undefined : onePasswordPreventionId),\n \"class\": s.Input,\n \"type\": props.type,\n // Only when set, so a native `autocomplete` attribute still applies\n ...(props.autoComplete !== undefined ? { autocomplete: props.autoComplete } : {}),\n // Expose the visual invalid state to assistive tech; an explicit aria-invalid wins\n \"aria-invalid\": restAttrs[\"aria-invalid\"] ?? (props.invalid || undefined),\n \"name\": props.name,\n // Controlled: the `value` property follows the prop. Uncontrolled:\n // `vDefaultValue` below sets the initial value, as in React.\n ...(value !== undefined ? { value } : {}),\n \"readonly\": readOnly,\n \"disabled\": disabled,\n \"onInput\": handleInput,\n // Use bubbling focus events for state, independently of a layer\n // capture listener. Caller @focus/@blur still receive their native events.\n \"onFocusin\": () => {\n focused.value = true\n },\n \"onFocusout\": () => {\n focused.value = false\n },\n \"onAnimationstart\": handleAnimationStart,\n // Prevent LastPass and 1Password from appearing\n \"data-lpignore\": allowAutofillExtensions ? undefined : true,\n \"data-1p-ignore\": allowAutofillExtensions ? undefined : true,\n }),\n ),\n [[vDefaultValue, value === undefined ? defaultValue : undefined]],\n ),\n showClearButton\n ? h(\"button\", { \"type\": \"button\", \"aria-label\": \"Clear input\", \"class\": s.Clear, \"onClick\": handleClear }, [\n h(X),\n ])\n : null,\n hasEndAdornment ? endAdornment : null,\n ],\n )\n }\n },\n})\n\ntype InputOwnProps = InstanceType<typeof InputComponent>[\"$props\"]\n\n/** Input props plus the native <input> attributes that fall through to it, as in React. */\nexport type InputProps = InputOwnProps & Omit<InputHTMLAttributes, keyof InputOwnProps>\n\n/** Text input with adornment slots, a clear button and autofill-extension control. */\nexport const Input = InputComponent as typeof InputComponent & { new (): { $props: InputProps } }\n\n/**\n * Canonical inline action button for Input adornments (React\n * `Input.AdornmentButton`): mic toggle, visibility toggle, copy, ... It sizes\n * itself off the parent Input so it matches the built-in clear button.\n */\nconst InputAdornmentButtonComponent = defineComponent({\n name: \"InputAdornmentButton\",\n props: {\n /** @default \"button\" */\n type: { type: String as PropType<\"button\" | \"submit\" | \"reset\">, default: \"button\" },\n /**\n * Semantic color tint for the pressed (`aria-pressed=\"true\"`) state, the\n * same palette Button accepts. Unset keeps the neutral primary-soft tint.\n */\n color: String as PropType<SemanticColor>,\n },\n setup(props, { slots }) {\n return () =>\n h(\"button\", { \"type\": props.type, \"class\": s.AdornmentButton, \"data-color\": props.color }, slots.default?.())\n },\n})\n\ntype InputAdornmentButtonOwnProps = InstanceType<typeof InputAdornmentButtonComponent>[\"$props\"]\n\n/** AdornmentButton props plus the native <button> attributes that fall through to it. */\nexport type InputAdornmentButtonProps = InputAdornmentButtonOwnProps &\n Omit<ButtonHTMLAttributes, keyof InputAdornmentButtonOwnProps>\n\nexport const InputAdornmentButton = InputAdornmentButtonComponent as typeof InputAdornmentButtonComponent & {\n new (): { $props: InputAdornmentButtonProps }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/components/Input/Input.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAsE,MAAM,KAAK,CAAA;AAEhL,OAAO,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAEhE,0DAA0D;AAC1D,6EAA6E;AAC7E,6EAA6E;AAC7E,oDAAoD;AACpD,+EAA+E;AAC/E,2EAA2E;AAC3E,0EAA0E;AAC1E,+BAA+B;AAC/B,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6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CACF,CAAC,CAAA;AAQF,MAAM,CAAC,MAAM,oBAAoB,GAAG,6BAEnC,CAAA","sourcesContent":["import clsx, { type ClassValue } from \"clsx\"\nimport { defineComponent, h, mergeProps, nextTick, onMounted, ref, useId, watch, withDirectives, type ButtonHTMLAttributes, type InputHTMLAttributes, type PropType } from \"vue\"\nimport type { ControlSize, SemanticColor, Sizes, Variants } from \"@plexui/styles/types\"\nimport { X, XCircleFilled } from \"../Icon/index.js\"\nimport { vDefaultValue } from \"../../lib/defaultValue.js\"\nimport { useFieldRowPill } from \"../../lib/fieldRow.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/Input/Input.module.css\"\n\n// Vue port of packages/ui/src/components/Input/Input.tsx.\n// - `class` goes to the container; every other attribute and native listener\n// (`@input`, `@change`, `@focus`, `style`, `placeholder`, ...) goes to the\n// <input>, as React spreads its rest props there.\n// - `value` + `update:value` support `v-model:value`; `default-value` sets the\n// initial value of an uncontrolled input through `vDefaultValue` (server\n// markup, hydration and later changes as in React), so re-renders never\n// reset what the user typed.\n// - `startAdornment` / `endAdornment` are slots. `onClear` stays a function\n// prop (`@clear` in templates) because its presence adds the clear button.\n// - `autoComplete` reaches the <input> as `autocomplete`, and `invalid` also\n// sets `aria-invalid` there unless the caller passes its own, as in React.\n\nconst InputComponent = defineComponent({\n name: \"Input\",\n inheritAttrs: false,\n props: {\n /** Visual style of the input. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"outline\" | \"soft\" | \"ghost\">>, default: \"outline\" },\n /** Controls the size of the input: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Controls gutter on the edges of the input, defaults to value from `size`. */\n gutterSize: String as PropType<Sizes<\"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">>,\n /** Disables the input visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Makes the input read-only. @default false */\n readOnly: { type: Boolean, default: false },\n /** Native spelling of `readOnly` (`<Input readonly />`). @default false */\n readonly: { type: Boolean, default: false },\n /** Mark the input as invalid. @default false */\n invalid: { type: Boolean, default: false },\n /**\n * Allow autofill extensions to appear in the input.\n * @default true when `type=\"password\"` or `name` is set, otherwise false\n */\n allowAutofillExtensions: { type: Boolean, default: undefined },\n /** Select all contents of the input when mounted, and whenever it turns true. @default false */\n autoSelect: { type: Boolean, default: undefined },\n /** Shows the clear button while the input has a value; called when it is clicked. */\n onClear: Function as PropType<(event: MouseEvent) => void>,\n /** Fully rounded pill shape. @default false, or true at the end of a `Field row` */\n pill: { type: Boolean, default: undefined },\n /** Applies a negative margin using the current gutter to optically align the input with surrounding content. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n id: String,\n name: String,\n /** @default \"text\" */\n type: { type: String, default: \"text\" },\n /** Controlled value. Bind `v-model:value` to keep it in sync. */\n value: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Initial value when uncontrolled. */\n defaultValue: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Native `autocomplete` of the <input>. */\n autoComplete: String,\n },\n emits: {\n \"update:value\": (value: string) => typeof value === \"string\",\n \"autofill\": () => true,\n },\n setup(props, { attrs, slots, emit, expose }) {\n const inputRef = ref<HTMLInputElement | null>(null)\n // Prevent 1Password from appearing: 1Password won't display if it thinks this field is for searching\n // Allow user to override this for connecting to labels.\n const onePasswordPreventionId = `search-ui-input-${useId()}`\n const pill = useFieldRowPill(() => props.pill)\n const focused = ref(false)\n\n // Redirect clicks on the container and adornments\n const handleMouseDown = (evt: MouseEvent) => {\n const input = inputRef.value\n // Bail out if the target is not an element or the input is not found\n if (!evt.target || !(evt.target instanceof Element) || !input) {\n return\n }\n // Bail out if the target is inside the input\n if (input.contains(evt.target)) {\n return\n }\n // Bail out if the target is a button\n if (evt.target.closest(\"button, [type='button'], [role='button'], [role='menuitem']\")) {\n return\n }\n\n evt.preventDefault()\n // If the input is not focused, focus it\n if (document.activeElement !== input) {\n input.focus()\n }\n\n const { left, top } = input.getBoundingClientRect()\n const { clientX, clientY } = evt\n // \"Before\" the input: top/left\n const isBefore = clientY < top || clientX < left\n // email, number and other types without the selection API throw on setSelectionRange\n const hasSelection = input.selectionStart !== null\n\n // If this is the first click, clear the selection.\n if (evt.detail === 1) {\n if (!hasSelection) return\n if (isBefore) {\n input.setSelectionRange(0, 0)\n } else {\n const length = input.value.length\n input.setSelectionRange(length, length)\n }\n }\n // If this is the second click, select the first or last word\n else if (evt.detail === 2) {\n if (!hasSelection) return\n // Split the input value into words and non-word characters\n const words = input.value.match(/\\w+|[^\\w\\s]/g) || []\n const selectedWord = isBefore ? words.at(0) : words.at(-1)\n if (selectedWord) {\n const wordIndex = isBefore ? input.value.indexOf(selectedWord) : input.value.lastIndexOf(selectedWord)\n input.setSelectionRange(wordIndex, wordIndex + selectedWord.length)\n }\n }\n // If this is the third click or greater, select the entire input\n else {\n input.select()\n }\n }\n\n const selectIfAuto = () => {\n if (props.autoSelect) {\n inputRef.value?.select()\n }\n }\n onMounted(() => {\n selectIfAuto()\n // An enclosing focus scope may focus the input during the same mount.\n // Reconcile after the mount finishes without focusing it a second time.\n void nextTick(() => {\n const input = inputRef.value\n focused.value = !!input && input.ownerDocument.activeElement === input\n })\n })\n watch(() => props.autoSelect, selectIfAuto, { flush: \"post\" })\n\n // The clear button unmounts once the value is gone, so keep focus in the input\n const handleClear = (evt: MouseEvent) => {\n inputRef.value?.focus()\n props.onClear?.(evt)\n }\n\n const handleAnimationStart = (evt: AnimationEvent) => {\n if (evt.animationName === \"native-autofill-in\") {\n emit(\"autofill\")\n }\n }\n\n const handleInput = (evt: Event) => {\n const target = evt.currentTarget as HTMLInputElement\n emit(\"update:value\", target.value)\n // Like a React controlled input, a `value` the parent does not update\n // is put back (Vue only re-applies `value` when this component renders)\n void nextTick(() => {\n if (props.value === undefined) return\n const value = String(props.value)\n if (target.value !== value) target.value = value\n })\n }\n\n expose({ focus: () => inputRef.value?.focus(), input: inputRef })\n\n return () => {\n const { class: className, ...restAttrs } = attrs\n const { value, defaultValue, disabled } = props\n const readOnly = props.readOnly || props.readonly\n // Default to `true` when type=\"password\" or presence of `name`\n const allowAutofillExtensions = props.allowAutofillExtensions ?? (props.type === \"password\" || !!props.name)\n const startAdornment = slots.startAdornment?.()\n const endAdornment = slots.endAdornment?.()\n const hasStartAdornment = hasContent(startAdornment)\n const hasEndAdornment = hasContent(endAdornment)\n\n // Determine if clear button should be shown\n const hasValue = String((value !== undefined ? value : defaultValue) ?? \"\") !== \"\"\n const showClearButton = !!props.onClear && hasValue && !disabled && !readOnly\n\n return h(\n \"div\",\n {\n \"class\": clsx(s.Container, className as ClassValue),\n \"data-slot\": \"input\",\n \"data-variant\": props.variant,\n \"data-size\": props.size,\n \"data-gutter-size\": props.gutterSize,\n \"data-focused\": focused.value,\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-readonly\": readOnly ? \"\" : undefined,\n \"data-invalid\": props.invalid ? \"\" : undefined,\n \"data-pill\": pill.value ? \"\" : undefined,\n \"data-optically-align\": props.opticallyAlign,\n \"data-has-start-adornment\": hasStartAdornment ? \"\" : undefined,\n \"data-has-end-adornment\": hasEndAdornment || showClearButton ? \"\" : undefined,\n \"onMousedown\": handleMouseDown,\n },\n [\n hasStartAdornment ? startAdornment : null,\n withDirectives(\n h(\n \"input\",\n mergeProps(restAttrs, {\n \"ref\": inputRef,\n \"id\": props.id || (allowAutofillExtensions ? undefined : onePasswordPreventionId),\n \"class\": s.Input,\n \"type\": props.type,\n // Only when set, so a native `autocomplete` attribute still applies\n ...(props.autoComplete !== undefined ? { autocomplete: props.autoComplete } : {}),\n // Expose the visual invalid state to assistive tech; an explicit aria-invalid wins\n \"aria-invalid\": restAttrs[\"aria-invalid\"] ?? (props.invalid || undefined),\n \"name\": props.name,\n // Controlled: the `value` property follows the prop. Uncontrolled:\n // `vDefaultValue` below sets the initial value, as in React.\n ...(value !== undefined ? { value } : {}),\n \"readonly\": readOnly,\n \"disabled\": disabled,\n \"onInput\": handleInput,\n // Use bubbling focus events for state, independently of a layer\n // capture listener. Caller @focus/@blur still receive their native events.\n \"onFocusin\": () => {\n focused.value = true\n },\n \"onFocusout\": () => {\n focused.value = false\n },\n \"onAnimationstart\": handleAnimationStart,\n // Prevent LastPass and 1Password from appearing\n \"data-lpignore\": allowAutofillExtensions ? undefined : true,\n \"data-1p-ignore\": allowAutofillExtensions ? undefined : true,\n }),\n ),\n [[vDefaultValue, value === undefined ? defaultValue : undefined]],\n ),\n showClearButton\n ? h(\"button\", { \"type\": \"button\", \"aria-label\": \"Clear input\", \"class\": s.Clear, \"onClick\": handleClear }, [\n h(X, { class: s.ClearIcon }),\n h(XCircleFilled, { class: s.ClearPhoneIcon }),\n ])\n : null,\n hasEndAdornment ? endAdornment : null,\n ],\n )\n }\n },\n})\n\ntype InputOwnProps = InstanceType<typeof InputComponent>[\"$props\"]\n\n/** Input props plus the native <input> attributes that fall through to it, as in React. */\nexport type InputProps = InputOwnProps & Omit<InputHTMLAttributes, keyof InputOwnProps>\n\n/** Text input with adornment slots, a clear button and autofill-extension control. */\nexport const Input = InputComponent as typeof InputComponent & { new (): { $props: InputProps } }\n\n/**\n * Canonical inline action button for Input adornments (React\n * `Input.AdornmentButton`): mic toggle, visibility toggle, copy, ... It sizes\n * itself off the parent Input so it matches the built-in clear button.\n */\nconst InputAdornmentButtonComponent = defineComponent({\n name: \"InputAdornmentButton\",\n props: {\n /** @default \"button\" */\n type: { type: String as PropType<\"button\" | \"submit\" | \"reset\">, default: \"button\" },\n /**\n * Semantic color tint for the pressed (`aria-pressed=\"true\"`) state, the\n * same palette Button accepts. Unset keeps the neutral primary-soft tint.\n */\n color: String as PropType<SemanticColor>,\n },\n setup(props, { slots }) {\n return () =>\n h(\"button\", { \"type\": props.type, \"class\": s.AdornmentButton, \"data-color\": props.color }, slots.default?.())\n },\n})\n\ntype InputAdornmentButtonOwnProps = InstanceType<typeof InputAdornmentButtonComponent>[\"$props\"]\n\n/** AdornmentButton props plus the native <button> attributes that fall through to it. */\nexport type InputAdornmentButtonProps = InputAdornmentButtonOwnProps &\n Omit<ButtonHTMLAttributes, keyof InputAdornmentButtonOwnProps>\n\nexport const InputAdornmentButton = InputAdornmentButtonComponent as typeof InputAdornmentButtonComponent & {\n new (): { $props: InputAdornmentButtonProps }\n}\n"]}
|
|
@@ -22,6 +22,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogBody, DialogFoo
|
|
|
22
22
|
import { Field } from "../Field/index.js";
|
|
23
23
|
import { Input } from "../Input/index.js";
|
|
24
24
|
import { flattenSlot } from "../Tooltip/slot.js";
|
|
25
|
+
import { renderMarkdown } from "../Markdown/pipeline.js";
|
|
25
26
|
import s from "@plexui/styles/components/MarkdownEditor/MarkdownEditor.module.css";
|
|
26
27
|
const getMarkdown = (editor) => editor.storage.markdown?.getMarkdown?.() ?? "";
|
|
27
28
|
// A link inserted as a text node, not as `<a>` HTML: the markdown parser runs
|
|
@@ -423,7 +424,9 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
423
424
|
]),
|
|
424
425
|
]),
|
|
425
426
|
h("div", { class: s.Editor, style: { minHeight: `${minHeight}px` } }, [
|
|
426
|
-
|
|
427
|
+
editor.value
|
|
428
|
+
? h(EditorContent, { editor: editor.value })
|
|
429
|
+
: editorFirstFrame(props.value ?? props.defaultValue ?? "", props.placeholder, props.disabled),
|
|
427
430
|
]),
|
|
428
431
|
h(LinkDialog, {
|
|
429
432
|
open: linkDialogOpen.value,
|
|
@@ -440,6 +443,151 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
440
443
|
};
|
|
441
444
|
},
|
|
442
445
|
});
|
|
446
|
+
// The editor reads markdown with `html: false` (markdown-it): HTML is not parsed, its characters are text, and the
|
|
447
|
+
// markdown around and inside it still is
|
|
448
|
+
function remarkWithoutHtml() {
|
|
449
|
+
const data = this.data();
|
|
450
|
+
(data.micromarkExtensions ??= []).push({ disable: { null: ["htmlFlow", "htmlText"] } });
|
|
451
|
+
}
|
|
452
|
+
// The editor's schema keeps paragraphs, lists, bold, italic, links and line breaks. ProseMirror parses anything else
|
|
453
|
+
// into them: a heading is a paragraph of its text, a code block a paragraph of its lines, a quote its paragraphs,
|
|
454
|
+
// inline code its text, an image or a rule nothing, and the text of a list item sits in a paragraph. Outside a code
|
|
455
|
+
// block it collapses white space, as the page does; the editor's text keeps its spaces (white-space: break-spaces)
|
|
456
|
+
const SCHEMA_AS_PARAGRAPH = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
457
|
+
const SCHEMA_BLOCKS = new Set(["p", "ul", "ol"]);
|
|
458
|
+
const textOf = (node) => node.value ?? (node.children ?? []).map(textOf).join("");
|
|
459
|
+
const isBlank = (node) => node.type === "text" && !node.value?.trim();
|
|
460
|
+
const lineBreak = () => ({ type: "element", tagName: "br", properties: {}, children: [] });
|
|
461
|
+
// White space of a paragraph's text as ProseMirror parses it: runs collapse to one space, none at the start of the
|
|
462
|
+
// paragraph, after a line break or after another space, none at its end
|
|
463
|
+
function collapseWhiteSpace(children) {
|
|
464
|
+
let previous = null;
|
|
465
|
+
let lineStart = true;
|
|
466
|
+
const walk = (nodes) => {
|
|
467
|
+
for (const node of nodes) {
|
|
468
|
+
if (node.type === "text") {
|
|
469
|
+
let value = (node.value ?? "").replace(/[ \t\r\n\f]+/g, " ");
|
|
470
|
+
if (value.startsWith(" ") && (lineStart || previous?.value?.endsWith(" ")))
|
|
471
|
+
value = value.slice(1);
|
|
472
|
+
node.value = value;
|
|
473
|
+
if (value) {
|
|
474
|
+
previous = node;
|
|
475
|
+
lineStart = false;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
else if (node.tagName === "br") {
|
|
479
|
+
lineStart = true;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
walk(node.children ?? []);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
walk(children);
|
|
487
|
+
if (previous)
|
|
488
|
+
previous.value = previous.value.replace(/ $/, "");
|
|
489
|
+
}
|
|
490
|
+
const paragraph = (children, { preserveWhiteSpace = false } = {}) => {
|
|
491
|
+
if (!preserveWhiteSpace)
|
|
492
|
+
collapseWhiteSpace(children);
|
|
493
|
+
return {
|
|
494
|
+
type: "element",
|
|
495
|
+
tagName: "p",
|
|
496
|
+
properties: {},
|
|
497
|
+
// An empty paragraph keeps its line, as ProseMirror's trailing break does
|
|
498
|
+
children: children.every((child) => child.type === "text" && !child.value) ? [lineBreak()] : children,
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
// tiptap-markdown drops the newline markdown-it writes after an element, outside a code block: a line that follows
|
|
502
|
+
// bold, a link or code joins it without a space
|
|
503
|
+
const dropNewlineAfterElements = (nodes) => nodes.map((node, index) => index && node.type === "text" && nodes[index - 1].type === "element" && node.value?.startsWith("\n")
|
|
504
|
+
? { ...node, value: node.value.slice(1) }
|
|
505
|
+
: node);
|
|
506
|
+
function toEditorSchema(nodes) {
|
|
507
|
+
return dropNewlineAfterElements(nodes).flatMap((node) => {
|
|
508
|
+
if (node.type !== "element")
|
|
509
|
+
return [node];
|
|
510
|
+
const children = node.children ?? [];
|
|
511
|
+
switch (node.tagName) {
|
|
512
|
+
case "img":
|
|
513
|
+
case "hr":
|
|
514
|
+
return [];
|
|
515
|
+
case "code":
|
|
516
|
+
return [{ type: "text", value: textOf(node) }];
|
|
517
|
+
case "pre": {
|
|
518
|
+
// ProseMirror keeps a code block's spaces and its newlines as line breaks, the last one followed by the
|
|
519
|
+
// trailing break of a paragraph that ends in a break
|
|
520
|
+
const lines = textOf(node).split("\n");
|
|
521
|
+
if (lines.every((line) => !line))
|
|
522
|
+
return [];
|
|
523
|
+
const content = [];
|
|
524
|
+
lines.forEach((line, index) => {
|
|
525
|
+
if (index)
|
|
526
|
+
content.push(lineBreak());
|
|
527
|
+
if (line)
|
|
528
|
+
content.push({ type: "text", value: line });
|
|
529
|
+
});
|
|
530
|
+
if (content[content.length - 1].tagName === "br")
|
|
531
|
+
content.push(lineBreak());
|
|
532
|
+
return [paragraph(content, { preserveWhiteSpace: true })];
|
|
533
|
+
}
|
|
534
|
+
case "blockquote":
|
|
535
|
+
return toEditorSchema(children);
|
|
536
|
+
case "p":
|
|
537
|
+
return [paragraph(toEditorSchema(children))];
|
|
538
|
+
case "li": {
|
|
539
|
+
const content = [];
|
|
540
|
+
let run = [];
|
|
541
|
+
const flush = () => {
|
|
542
|
+
if (!run.every(isBlank))
|
|
543
|
+
content.push(paragraph(run));
|
|
544
|
+
run = [];
|
|
545
|
+
};
|
|
546
|
+
for (const child of toEditorSchema(children)) {
|
|
547
|
+
if (child.type === "element" && SCHEMA_BLOCKS.has(child.tagName)) {
|
|
548
|
+
flush();
|
|
549
|
+
content.push(child);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
run.push(child);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
flush();
|
|
556
|
+
// A list item starts with a paragraph, an empty one if it has no text (an empty item, an image)
|
|
557
|
+
if (content[0]?.tagName !== "p")
|
|
558
|
+
content.unshift(paragraph([]));
|
|
559
|
+
return [{ ...node, children: content }];
|
|
560
|
+
}
|
|
561
|
+
case "ul":
|
|
562
|
+
case "ol":
|
|
563
|
+
return [{ ...node, children: toEditorSchema(children).filter((child) => !isBlank(child)) }];
|
|
564
|
+
default:
|
|
565
|
+
return SCHEMA_AS_PARAGRAPH.has(node.tagName)
|
|
566
|
+
? [paragraph(toEditorSchema(children))]
|
|
567
|
+
: [{ ...node, children: toEditorSchema(children) }];
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function rehypeEditorSchema() {
|
|
572
|
+
return (tree) => {
|
|
573
|
+
tree.children = toEditorSchema(tree.children ?? []).filter((child) => !isBlank(child));
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* The content before the editor exists, on the server and until it mounts: the markdown as the editor will show it,
|
|
578
|
+
* in its schema and its own boxes (EditorContent's, then ProseMirror's), so the page does not move when ProseMirror
|
|
579
|
+
* takes over, as in React. An empty editor shows its placeholder while it can be edited (`showOnlyWhenEditable`).
|
|
580
|
+
*/
|
|
581
|
+
const editorFirstFrame = (markdown, placeholder, disabled) => {
|
|
582
|
+
const hint = placeholder && !disabled;
|
|
583
|
+
return h("div", null, [
|
|
584
|
+
h("div", { class: ["tiptap", s.EditorContent] }, [
|
|
585
|
+
markdown.trim()
|
|
586
|
+
? renderMarkdown({ children: markdown, remarkPlugins: [remarkWithoutHtml], rehypePlugins: [rehypeEditorSchema] })
|
|
587
|
+
: h("p", { class: hint ? "is-editor-empty" : undefined, "data-placeholder": hint ? placeholder : undefined }, [h("br")]),
|
|
588
|
+
]),
|
|
589
|
+
]);
|
|
590
|
+
};
|
|
443
591
|
/**
|
|
444
592
|
* Compact rich text editor for markdown, with a formatting toolbar (bold,
|
|
445
593
|
* italic, lists, links). Bind the markdown with `v-model:value`.
|