@plexui/vue 0.35.0 → 0.37.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, defineComponent, h, onBeforeUnmount, ref } from "vue";
|
|
2
2
|
import s from "@plexui/styles/components/Stepper/Stepper.module.css";
|
|
3
|
-
import { Minus, Plus } from "../Icon/index.js";
|
|
3
|
+
import { Minus, Plus, RemoveTrash } from "../Icon/index.js";
|
|
4
4
|
// Vue port of packages/ui/src/components/Stepper/Stepper.tsx: the same DOM (a spin button with two
|
|
5
5
|
// unfocusable segments and an optional hidden input), keys, hold-to-repeat and clamped or wrapped steps.
|
|
6
6
|
// React's `value` + `onChange` become `value` + `update:value` (`v-model:value`) and `change`.
|
|
@@ -45,10 +45,22 @@ const StepperComponent = defineComponent({
|
|
|
45
45
|
disabled: { type: Boolean, default: false },
|
|
46
46
|
/** Fully rounded ends. @default true */
|
|
47
47
|
pill: { type: Boolean, default: true },
|
|
48
|
+
/**
|
|
49
|
+
* Shows the value between the minus and the plus on one fill, as a cart's quantity: round segments and no
|
|
50
|
+
* separator. Without it the stepper shows no value, as the native one. @default false
|
|
51
|
+
*/
|
|
52
|
+
showValue: { type: Boolean, default: false },
|
|
48
53
|
/** Accessible name of the decrement segment. @default "Decrease" */
|
|
49
54
|
decrementLabel: { type: String, default: "Decrease" },
|
|
50
55
|
/** Accessible name of the increment segment. @default "Increase" */
|
|
51
56
|
incrementLabel: { type: String, default: "Increase" },
|
|
57
|
+
/**
|
|
58
|
+
* Called (`@remove`) when the decrement segment is pressed at `min`. With it, the segment shows a trash can there
|
|
59
|
+
* and removes the item, as a cart's stepper does at a quantity of one (without `wrap`).
|
|
60
|
+
*/
|
|
61
|
+
onRemove: Function,
|
|
62
|
+
/** Accessible name of the decrement segment when it removes. @default "Remove" */
|
|
63
|
+
removeLabel: { type: String, default: "Remove" },
|
|
52
64
|
/** The name of the stepper. Submits its value with the owning form. */
|
|
53
65
|
name: String,
|
|
54
66
|
/** Accessible name of the value the stepper changes, when no visible label names it. */
|
|
@@ -96,9 +108,19 @@ const StepperComponent = defineComponent({
|
|
|
96
108
|
onBeforeUnmount(stopRepeat);
|
|
97
109
|
const atMin = computed(() => !props.wrap && value.value <= props.min);
|
|
98
110
|
const atMax = computed(() => !props.wrap && value.value >= props.max);
|
|
111
|
+
// At the minimum the decrement segment removes the item, when the owner can remove it
|
|
112
|
+
const removes = computed(() => atMin.value && props.onRemove !== undefined);
|
|
99
113
|
const startPress = (segment, event) => {
|
|
100
114
|
if (event.button !== 0 || props.disabled)
|
|
101
115
|
return;
|
|
116
|
+
if (segment === "decrement" && removes.value) {
|
|
117
|
+
const target = event.currentTarget;
|
|
118
|
+
if (target instanceof HTMLElement)
|
|
119
|
+
target.setPointerCapture?.(event.pointerId);
|
|
120
|
+
pressed.value = segment;
|
|
121
|
+
props.onRemove?.();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
102
124
|
if (segment === "decrement" ? atMin.value : atMax.value)
|
|
103
125
|
return;
|
|
104
126
|
const target = event.currentTarget;
|
|
@@ -120,6 +142,8 @@ const StepperComponent = defineComponent({
|
|
|
120
142
|
const handleClick = (segment, event) => {
|
|
121
143
|
if (event.detail !== 0 || props.disabled)
|
|
122
144
|
return;
|
|
145
|
+
if (segment === "decrement" && removes.value)
|
|
146
|
+
return props.onRemove?.();
|
|
123
147
|
stepBy(segment === "decrement" ? -1 : 1);
|
|
124
148
|
};
|
|
125
149
|
const handleKeyDown = (event) => {
|
|
@@ -132,6 +156,8 @@ const StepperComponent = defineComponent({
|
|
|
132
156
|
PageDown: () => stepBy(-1, 10),
|
|
133
157
|
Home: () => commit(props.min),
|
|
134
158
|
End: () => commit(props.max),
|
|
159
|
+
// At the minimum Delete or Backspace removes, as the trash can does; the arrows never do
|
|
160
|
+
...(removes.value && { Delete: () => props.onRemove?.(), Backspace: () => props.onRemove?.() }),
|
|
135
161
|
};
|
|
136
162
|
const action = keys[event.key];
|
|
137
163
|
if (!action)
|
|
@@ -140,15 +166,17 @@ const StepperComponent = defineComponent({
|
|
|
140
166
|
action();
|
|
141
167
|
};
|
|
142
168
|
const segment = (kind) => {
|
|
143
|
-
const
|
|
169
|
+
const remove = kind === "decrement" && removes.value;
|
|
170
|
+
const atEnd = !remove && (kind === "decrement" ? atMin.value : atMax.value);
|
|
144
171
|
return h("button", {
|
|
145
172
|
"type": "button",
|
|
146
173
|
"tabindex": -1,
|
|
147
|
-
"aria-label": kind === "decrement" ? props.decrementLabel : props.incrementLabel,
|
|
174
|
+
"aria-label": remove ? props.removeLabel : kind === "decrement" ? props.decrementLabel : props.incrementLabel,
|
|
148
175
|
"aria-disabled": atEnd || undefined,
|
|
149
176
|
"disabled": props.disabled,
|
|
150
177
|
"class": s.Segment,
|
|
151
178
|
"data-segment": kind,
|
|
179
|
+
"data-remove": remove ? "" : undefined,
|
|
152
180
|
"data-disabled": atEnd || props.disabled ? "" : undefined,
|
|
153
181
|
"data-pressed": pressed.value === kind && !props.disabled ? "" : undefined,
|
|
154
182
|
// Keeps the focus where it is, as a native stepper takes none.
|
|
@@ -158,7 +186,7 @@ const StepperComponent = defineComponent({
|
|
|
158
186
|
"onPointercancel": stopRepeat,
|
|
159
187
|
"onLostpointercapture": stopRepeat,
|
|
160
188
|
"onClick": (event) => handleClick(kind, event),
|
|
161
|
-
}, [h(kind === "decrement" ? Minus : Plus, { class: s.Icon })]);
|
|
189
|
+
}, [h(remove ? RemoveTrash : kind === "decrement" ? Minus : Plus, { class: s.Icon })]);
|
|
162
190
|
};
|
|
163
191
|
return () => h("div", {
|
|
164
192
|
...attrs,
|
|
@@ -171,16 +199,21 @@ const StepperComponent = defineComponent({
|
|
|
171
199
|
"aria-label": props.ariaLabel,
|
|
172
200
|
"aria-labelledby": props.ariaLabelledby,
|
|
173
201
|
"aria-describedby": props.ariaDescribedby,
|
|
202
|
+
"aria-keyshortcuts": removes.value ? "Delete" : undefined,
|
|
174
203
|
"aria-disabled": props.disabled || undefined,
|
|
175
204
|
"class": [s.Stepper, attrs.class],
|
|
176
205
|
"data-disabled": props.disabled ? "" : undefined,
|
|
177
206
|
"data-pill": props.pill ? "" : undefined,
|
|
207
|
+
"data-show-value": props.showValue ? "" : undefined,
|
|
178
208
|
"onKeydown": handleKeyDown,
|
|
179
209
|
"onFocus": (event) => emit("focus", event),
|
|
180
210
|
"onBlur": (event) => emit("blur", event),
|
|
181
211
|
}, [
|
|
182
212
|
segment("decrement"),
|
|
183
|
-
|
|
213
|
+
// The spin button already reads its value, so the shown one is not read again
|
|
214
|
+
props.showValue
|
|
215
|
+
? h("span", { "class": s.Value, "aria-hidden": "true" }, String(value.value))
|
|
216
|
+
: h("span", { "class": s.Separator, "aria-hidden": "true" }),
|
|
184
217
|
segment("increment"),
|
|
185
218
|
props.name !== undefined ? h("input", { type: "hidden", name: props.name, value: value.value, disabled: props.disabled }) : null,
|
|
186
219
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.js","sourceRoot":"","sources":["../../../../src/components/Stepper/Stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACxE,OAAO,CAAC,MAAM,sDAAsD,CAAA;AACpE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAE9C,mGAAmG;AACnG,yGAAyG;AACzG,+FAA+F;AAE/F,yFAAyF;AACzF,MAAM,YAAY,GAAG,GAAG,CAAA;AACxB,MAAM,eAAe,GAAG,GAAG,CAAA;AAE3B,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE;IAC7B,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC9C,OAAO,QAAQ,CAAC,MAAM,C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ent":["import { computed, defineComponent, h, onBeforeUnmount, ref } from \"vue\"\nimport s from \"@plexui/styles/components/Stepper/Stepper.module.css\"\nimport { Minus, Plus } from \"../Icon/index.js\"\n\n// Vue port of packages/ui/src/components/Stepper/Stepper.tsx: the same DOM (a spin button with two\n// unfocusable segments and an optional hidden input), keys, hold-to-repeat and clamped or wrapped steps.\n// React's `value` + `onChange` become `value` + `update:value` (`v-model:value`) and `change`.\n\n/** Delay before a held segment starts repeating, and the time between repeats, in ms. */\nconst REPEAT_DELAY = 400\nconst REPEAT_INTERVAL = 100\n\nconst decimals = (n: number) => {\n const [, fraction = \"\"] = String(n).split(\".\")\n return fraction.length\n}\n\n/** The value one step away, clamped to the range or wrapped, without floating point drift. */\nexport const stepValue = (current: number, direction: 1 | -1, { min, max, step, wrap }: { min: number; max: number; step: number; wrap: boolean }) => {\n const precision = Math.max(decimals(step), decimals(min), decimals(current))\n const next = Number((current + direction * step).toFixed(precision))\n if (next > max) return wrap ? min : max\n if (next < min) return wrap ? max : min\n return next\n}\n\ntype Segment = \"decrement\" | \"increment\"\n\nconst StepperComponent = defineComponent({\n name: \"Stepper\",\n inheritAttrs: false,\n props: {\n /** The `id` of the stepper. */\n id: String,\n /** The controlled value. Bind with `v-model:value`. */\n value: { type: Number, default: undefined },\n /** The value when it is initially rendered. Use when you do not need to control the value. @default min */\n defaultValue: { type: Number, default: undefined },\n /** The lowest value. @default 0 */\n min: { type: Number, default: 0 },\n /** The highest value. @default 100 */\n max: { type: Number, default: 100 },\n /** The amount each step adds or removes. @default 1 */\n step: { type: Number, default: 1 },\n /** A step past `max` continues from `min`, and one below `min` from `max`. @default false */\n wrap: { type: Boolean, default: false },\n /** Holding a segment keeps stepping, as a native stepper does. @default true */\n autoRepeat: { type: Boolean, default: true },\n /** When `true`, prevents the user from interacting with the stepper. */\n disabled: { type: Boolean, default: false },\n /** Fully rounded ends. @default true */\n pill: { type: Boolean, default: true },\n /** Accessible name of the decrement segment. @default \"Decrease\" */\n decrementLabel: { type: String, default: \"Decrease\" },\n /** Accessible name of the increment segment. @default \"Increase\" */\n incrementLabel: { type: String, default: \"Increase\" },\n /** The name of the stepper. Submits its value with the owning form. */\n name: String,\n /** Accessible name of the value the stepper changes, when no visible label names it. */\n ariaLabel: String,\n /** The `id` of the visible label of the value the stepper changes. */\n ariaLabelledby: String,\n /** The `id` of an element that describes the stepper, such as the text that shows its value. */\n ariaDescribedby: String,\n },\n emits: {\n /** The value changed */\n \"update:value\": (value: number) => typeof value === \"number\",\n /** The value changed (React `onChange`) */\n change: (value: number) => typeof value === \"number\",\n /** The stepper gained focus */\n focus: (event: FocusEvent) => event.type === \"focus\",\n /** The stepper lost focus */\n blur: (event: FocusEvent) => event.type === \"blur\",\n },\n setup(props, { attrs, emit }) {\n const internalValue = ref(props.defaultValue ?? props.min)\n const value = computed(() => props.value ?? internalValue.value)\n const pressed = ref<Segment | null>(null)\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const commit = (next: number) => {\n if (next === value.value) return false\n if (props.value === undefined) internalValue.value = next\n emit(\"update:value\", next)\n emit(\"change\", next)\n return true\n }\n\n const stepBy = (direction: 1 | -1, times = 1) => {\n let next = value.value\n for (let i = 0; i < times; i++) next = stepValue(next, direction, props)\n return commit(next)\n }\n\n const stopRepeat = () => {\n clearTimeout(timer)\n timer = undefined\n pressed.value = null\n }\n onBeforeUnmount(stopRepeat)\n\n const atMin = computed(() => !props.wrap && value.value <= props.min)\n const atMax = computed(() => !props.wrap && value.value >= props.max)\n\n const startPress = (segment: Segment, event: PointerEvent) => {\n if (event.button !== 0 || props.disabled) return\n if (segment === \"decrement\" ? atMin.value : atMax.value) return\n const target = event.currentTarget\n if (target instanceof HTMLElement) target.setPointerCapture?.(event.pointerId)\n pressed.value = segment\n const direction = segment === \"decrement\" ? -1 : 1\n stepBy(direction)\n if (!props.autoRepeat) return\n const repeat = () => {\n if (props.disabled || !stepBy(direction)) return stopRepeat()\n timer = setTimeout(repeat, REPEAT_INTERVAL)\n }\n timer = setTimeout(repeat, REPEAT_DELAY)\n }\n\n // A pointer steps on press, so only a click without one (assistive technology, `element.click()`) steps here.\n const handleClick = (segment: Segment, event: MouseEvent) => {\n if (event.detail !== 0 || props.disabled) return\n stepBy(segment === \"decrement\" ? -1 : 1)\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (props.disabled || event.altKey || event.ctrlKey || event.metaKey) return\n const keys: Record<string, () => void> = {\n ArrowUp: () => stepBy(1),\n ArrowDown: () => stepBy(-1),\n PageUp: () => stepBy(1, 10),\n PageDown: () => stepBy(-1, 10),\n Home: () => commit(props.min),\n End: () => commit(props.max),\n }\n const action = keys[event.key]\n if (!action) return\n event.preventDefault()\n action()\n }\n\n const segment = (kind: Segment) => {\n const atEnd = kind === \"decrement\" ? atMin.value : atMax.value\n return h(\"button\", {\n \"type\": \"button\",\n \"tabindex\": -1,\n \"aria-label\": kind === \"decrement\" ? props.decrementLabel : props.incrementLabel,\n \"aria-disabled\": atEnd || undefined,\n \"disabled\": props.disabled,\n \"class\": s.Segment,\n \"data-segment\": kind,\n \"data-disabled\": atEnd || props.disabled ? \"\" : undefined,\n \"data-pressed\": pressed.value === kind && !props.disabled ? \"\" : undefined,\n // Keeps the focus where it is, as a native stepper takes none.\n \"onMousedown\": (event: MouseEvent) => event.preventDefault(),\n \"onPointerdown\": (event: PointerEvent) => startPress(kind, event),\n \"onPointerup\": stopRepeat,\n \"onPointercancel\": stopRepeat,\n \"onLostpointercapture\": stopRepeat,\n \"onClick\": (event: MouseEvent) => handleClick(kind, event),\n }, [h(kind === \"decrement\" ? Minus : Plus, { class: s.Icon })])\n }\n\n return () => h(\"div\", {\n ...attrs,\n \"id\": props.id,\n \"role\": \"spinbutton\",\n \"tabindex\": props.disabled ? -1 : 0,\n \"aria-valuenow\": value.value,\n \"aria-valuemin\": props.min,\n \"aria-valuemax\": props.max,\n \"aria-label\": props.ariaLabel,\n \"aria-labelledby\": props.ariaLabelledby,\n \"aria-describedby\": props.ariaDescribedby,\n \"aria-disabled\": props.disabled || undefined,\n \"class\": [s.Stepper, attrs.class],\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"onKeydown\": handleKeyDown,\n \"onFocus\": (event: FocusEvent) => emit(\"focus\", event),\n \"onBlur\": (event: FocusEvent) => emit(\"blur\", event),\n }, [\n segment(\"decrement\"),\n h(\"span\", { \"class\": s.Separator, \"aria-hidden\": \"true\" }),\n segment(\"increment\"),\n props.name !== undefined ? h(\"input\", { type: \"hidden\", name: props.name, value: value.value, disabled: props.disabled }) : null,\n ])\n },\n})\n\ntype StepperOwnProps = InstanceType<typeof StepperComponent>[\"$props\"]\n\n/** Stepper props. */\nexport type StepperProps = StepperOwnProps\n\n/**\n * Two segments that decrease and increase a number, as the iOS 26 stepper does. It shows no value of its own:\n * name it with `aria-label` or `aria-labelledby` and show the value beside it. Keyboard focus lands on the\n * stepper, a spin button: Up and Down step, Page Up and Page Down step ten times, Home and End go to the range ends.\n */\nexport const Stepper = StepperComponent\n"]}
|
|
1
|
+
{"version":3,"file":"Stepper.js","sourceRoot":"","sources":["../../../../src/components/Stepper/Stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAiB,GAAG,EAAE,MAAM,KAAK,CAAA;AACvF,OAAO,CAAC,MAAM,sDAAsD,CAAA;AACpE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE3D,mGAAmG;AACnG,yGAAyG;AACzG,+FAA+F;AAE/F,yFAAyF;AACzF,MAAM,YAAY,GAAG,GAAG,CAAA;AACxB,MAAM,eAAe,GAAG,GAAG,CAAA;AAE3B,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE;IAC7B,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,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EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;YAC9D,OAAO,CAAC,WAAW,CAAC;YACpB,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;SACjI,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA;AAOF;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAA","sourcesContent":["import { computed, defineComponent, h, onBeforeUnmount, type PropType, ref } from \"vue\"\nimport s from \"@plexui/styles/components/Stepper/Stepper.module.css\"\nimport { Minus, Plus, RemoveTrash } from \"../Icon/index.js\"\n\n// Vue port of packages/ui/src/components/Stepper/Stepper.tsx: the same DOM (a spin button with two\n// unfocusable segments and an optional hidden input), keys, hold-to-repeat and clamped or wrapped steps.\n// React's `value` + `onChange` become `value` + `update:value` (`v-model:value`) and `change`.\n\n/** Delay before a held segment starts repeating, and the time between repeats, in ms. */\nconst REPEAT_DELAY = 400\nconst REPEAT_INTERVAL = 100\n\nconst decimals = (n: number) => {\n const [, fraction = \"\"] = String(n).split(\".\")\n return fraction.length\n}\n\n/** The value one step away, clamped to the range or wrapped, without floating point drift. */\nexport const stepValue = (current: number, direction: 1 | -1, { min, max, step, wrap }: { min: number; max: number; step: number; wrap: boolean }) => {\n const precision = Math.max(decimals(step), decimals(min), decimals(current))\n const next = Number((current + direction * step).toFixed(precision))\n if (next > max) return wrap ? min : max\n if (next < min) return wrap ? max : min\n return next\n}\n\ntype Segment = \"decrement\" | \"increment\"\n\nconst StepperComponent = defineComponent({\n name: \"Stepper\",\n inheritAttrs: false,\n props: {\n /** The `id` of the stepper. */\n id: String,\n /** The controlled value. Bind with `v-model:value`. */\n value: { type: Number, default: undefined },\n /** The value when it is initially rendered. Use when you do not need to control the value. @default min */\n defaultValue: { type: Number, default: undefined },\n /** The lowest value. @default 0 */\n min: { type: Number, default: 0 },\n /** The highest value. @default 100 */\n max: { type: Number, default: 100 },\n /** The amount each step adds or removes. @default 1 */\n step: { type: Number, default: 1 },\n /** A step past `max` continues from `min`, and one below `min` from `max`. @default false */\n wrap: { type: Boolean, default: false },\n /** Holding a segment keeps stepping, as a native stepper does. @default true */\n autoRepeat: { type: Boolean, default: true },\n /** When `true`, prevents the user from interacting with the stepper. */\n disabled: { type: Boolean, default: false },\n /** Fully rounded ends. @default true */\n pill: { type: Boolean, default: true },\n /**\n * Shows the value between the minus and the plus on one fill, as a cart's quantity: round segments and no\n * separator. Without it the stepper shows no value, as the native one. @default false\n */\n showValue: { type: Boolean, default: false },\n /** Accessible name of the decrement segment. @default \"Decrease\" */\n decrementLabel: { type: String, default: \"Decrease\" },\n /** Accessible name of the increment segment. @default \"Increase\" */\n incrementLabel: { type: String, default: \"Increase\" },\n /**\n * Called (`@remove`) when the decrement segment is pressed at `min`. With it, the segment shows a trash can there\n * and removes the item, as a cart's stepper does at a quantity of one (without `wrap`).\n */\n onRemove: Function as PropType<() => void>,\n /** Accessible name of the decrement segment when it removes. @default \"Remove\" */\n removeLabel: { type: String, default: \"Remove\" },\n /** The name of the stepper. Submits its value with the owning form. */\n name: String,\n /** Accessible name of the value the stepper changes, when no visible label names it. */\n ariaLabel: String,\n /** The `id` of the visible label of the value the stepper changes. */\n ariaLabelledby: String,\n /** The `id` of an element that describes the stepper, such as the text that shows its value. */\n ariaDescribedby: String,\n },\n emits: {\n /** The value changed */\n \"update:value\": (value: number) => typeof value === \"number\",\n /** The value changed (React `onChange`) */\n change: (value: number) => typeof value === \"number\",\n /** The stepper gained focus */\n focus: (event: FocusEvent) => event.type === \"focus\",\n /** The stepper lost focus */\n blur: (event: FocusEvent) => event.type === \"blur\",\n },\n setup(props, { attrs, emit }) {\n const internalValue = ref(props.defaultValue ?? props.min)\n const value = computed(() => props.value ?? internalValue.value)\n const pressed = ref<Segment | null>(null)\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const commit = (next: number) => {\n if (next === value.value) return false\n if (props.value === undefined) internalValue.value = next\n emit(\"update:value\", next)\n emit(\"change\", next)\n return true\n }\n\n const stepBy = (direction: 1 | -1, times = 1) => {\n let next = value.value\n for (let i = 0; i < times; i++) next = stepValue(next, direction, props)\n return commit(next)\n }\n\n const stopRepeat = () => {\n clearTimeout(timer)\n timer = undefined\n pressed.value = null\n }\n onBeforeUnmount(stopRepeat)\n\n const atMin = computed(() => !props.wrap && value.value <= props.min)\n const atMax = computed(() => !props.wrap && value.value >= props.max)\n // At the minimum the decrement segment removes the item, when the owner can remove it\n const removes = computed(() => atMin.value && props.onRemove !== undefined)\n\n const startPress = (segment: Segment, event: PointerEvent) => {\n if (event.button !== 0 || props.disabled) return\n if (segment === \"decrement\" && removes.value) {\n const target = event.currentTarget\n if (target instanceof HTMLElement) target.setPointerCapture?.(event.pointerId)\n pressed.value = segment\n props.onRemove?.()\n return\n }\n if (segment === \"decrement\" ? atMin.value : atMax.value) return\n const target = event.currentTarget\n if (target instanceof HTMLElement) target.setPointerCapture?.(event.pointerId)\n pressed.value = segment\n const direction = segment === \"decrement\" ? -1 : 1\n stepBy(direction)\n if (!props.autoRepeat) return\n const repeat = () => {\n if (props.disabled || !stepBy(direction)) return stopRepeat()\n timer = setTimeout(repeat, REPEAT_INTERVAL)\n }\n timer = setTimeout(repeat, REPEAT_DELAY)\n }\n\n // A pointer steps on press, so only a click without one (assistive technology, `element.click()`) steps here.\n const handleClick = (segment: Segment, event: MouseEvent) => {\n if (event.detail !== 0 || props.disabled) return\n if (segment === \"decrement\" && removes.value) return props.onRemove?.()\n stepBy(segment === \"decrement\" ? -1 : 1)\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (props.disabled || event.altKey || event.ctrlKey || event.metaKey) return\n const keys: Record<string, () => void> = {\n ArrowUp: () => stepBy(1),\n ArrowDown: () => stepBy(-1),\n PageUp: () => stepBy(1, 10),\n PageDown: () => stepBy(-1, 10),\n Home: () => commit(props.min),\n End: () => commit(props.max),\n // At the minimum Delete or Backspace removes, as the trash can does; the arrows never do\n ...(removes.value && { Delete: () => props.onRemove?.(), Backspace: () => props.onRemove?.() }),\n }\n const action = keys[event.key]\n if (!action) return\n event.preventDefault()\n action()\n }\n\n const segment = (kind: Segment) => {\n const remove = kind === \"decrement\" && removes.value\n const atEnd = !remove && (kind === \"decrement\" ? atMin.value : atMax.value)\n return h(\"button\", {\n \"type\": \"button\",\n \"tabindex\": -1,\n \"aria-label\": remove ? props.removeLabel : kind === \"decrement\" ? props.decrementLabel : props.incrementLabel,\n \"aria-disabled\": atEnd || undefined,\n \"disabled\": props.disabled,\n \"class\": s.Segment,\n \"data-segment\": kind,\n \"data-remove\": remove ? \"\" : undefined,\n \"data-disabled\": atEnd || props.disabled ? \"\" : undefined,\n \"data-pressed\": pressed.value === kind && !props.disabled ? \"\" : undefined,\n // Keeps the focus where it is, as a native stepper takes none.\n \"onMousedown\": (event: MouseEvent) => event.preventDefault(),\n \"onPointerdown\": (event: PointerEvent) => startPress(kind, event),\n \"onPointerup\": stopRepeat,\n \"onPointercancel\": stopRepeat,\n \"onLostpointercapture\": stopRepeat,\n \"onClick\": (event: MouseEvent) => handleClick(kind, event),\n }, [h(remove ? RemoveTrash : kind === \"decrement\" ? Minus : Plus, { class: s.Icon })])\n }\n\n return () => h(\"div\", {\n ...attrs,\n \"id\": props.id,\n \"role\": \"spinbutton\",\n \"tabindex\": props.disabled ? -1 : 0,\n \"aria-valuenow\": value.value,\n \"aria-valuemin\": props.min,\n \"aria-valuemax\": props.max,\n \"aria-label\": props.ariaLabel,\n \"aria-labelledby\": props.ariaLabelledby,\n \"aria-describedby\": props.ariaDescribedby,\n \"aria-keyshortcuts\": removes.value ? \"Delete\" : undefined,\n \"aria-disabled\": props.disabled || undefined,\n \"class\": [s.Stepper, attrs.class],\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-show-value\": props.showValue ? \"\" : undefined,\n \"onKeydown\": handleKeyDown,\n \"onFocus\": (event: FocusEvent) => emit(\"focus\", event),\n \"onBlur\": (event: FocusEvent) => emit(\"blur\", event),\n }, [\n segment(\"decrement\"),\n // The spin button already reads its value, so the shown one is not read again\n props.showValue\n ? h(\"span\", { \"class\": s.Value, \"aria-hidden\": \"true\" }, String(value.value))\n : h(\"span\", { \"class\": s.Separator, \"aria-hidden\": \"true\" }),\n segment(\"increment\"),\n props.name !== undefined ? h(\"input\", { type: \"hidden\", name: props.name, value: value.value, disabled: props.disabled }) : null,\n ])\n },\n})\n\ntype StepperOwnProps = InstanceType<typeof StepperComponent>[\"$props\"]\n\n/** Stepper props. */\nexport type StepperProps = StepperOwnProps\n\n/**\n * Two segments that decrease and increase a number, as the iOS 26 stepper does. It shows no value of its own:\n * name it with `aria-label` or `aria-labelledby` and show the value beside it. Keyboard focus lands on the\n * stepper, a spin button: Up and Down step, Page Up and Page Down step ten times, Home and End go to the range ends.\n */\nexport const Stepper = StepperComponent\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
1
2
|
/** The value one step away, clamped to the range or wrapped, without floating point drift. */
|
|
2
3
|
export declare const stepValue: (current: number, direction: 1 | -1, { min, max, step, wrap }: {
|
|
3
4
|
min: number;
|
|
@@ -53,6 +54,14 @@ declare const StepperComponent: import("vue").DefineComponent<import("vue").Extr
|
|
|
53
54
|
type: BooleanConstructor;
|
|
54
55
|
default: boolean;
|
|
55
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Shows the value between the minus and the plus on one fill, as a cart's quantity: round segments and no
|
|
59
|
+
* separator. Without it the stepper shows no value, as the native one. @default false
|
|
60
|
+
*/
|
|
61
|
+
showValue: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
56
65
|
/** Accessible name of the decrement segment. @default "Decrease" */
|
|
57
66
|
decrementLabel: {
|
|
58
67
|
type: StringConstructor;
|
|
@@ -63,6 +72,16 @@ declare const StepperComponent: import("vue").DefineComponent<import("vue").Extr
|
|
|
63
72
|
type: StringConstructor;
|
|
64
73
|
default: string;
|
|
65
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Called (`@remove`) when the decrement segment is pressed at `min`. With it, the segment shows a trash can there
|
|
77
|
+
* and removes the item, as a cart's stepper does at a quantity of one (without `wrap`).
|
|
78
|
+
*/
|
|
79
|
+
onRemove: PropType<() => void>;
|
|
80
|
+
/** Accessible name of the decrement segment when it removes. @default "Remove" */
|
|
81
|
+
removeLabel: {
|
|
82
|
+
type: StringConstructor;
|
|
83
|
+
default: string;
|
|
84
|
+
};
|
|
66
85
|
/** The name of the stepper. Submits its value with the owning form. */
|
|
67
86
|
name: StringConstructor;
|
|
68
87
|
/** Accessible name of the value the stepper changes, when no visible label names it. */
|
|
@@ -130,6 +149,14 @@ declare const StepperComponent: import("vue").DefineComponent<import("vue").Extr
|
|
|
130
149
|
type: BooleanConstructor;
|
|
131
150
|
default: boolean;
|
|
132
151
|
};
|
|
152
|
+
/**
|
|
153
|
+
* Shows the value between the minus and the plus on one fill, as a cart's quantity: round segments and no
|
|
154
|
+
* separator. Without it the stepper shows no value, as the native one. @default false
|
|
155
|
+
*/
|
|
156
|
+
showValue: {
|
|
157
|
+
type: BooleanConstructor;
|
|
158
|
+
default: boolean;
|
|
159
|
+
};
|
|
133
160
|
/** Accessible name of the decrement segment. @default "Decrease" */
|
|
134
161
|
decrementLabel: {
|
|
135
162
|
type: StringConstructor;
|
|
@@ -140,6 +167,16 @@ declare const StepperComponent: import("vue").DefineComponent<import("vue").Extr
|
|
|
140
167
|
type: StringConstructor;
|
|
141
168
|
default: string;
|
|
142
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* Called (`@remove`) when the decrement segment is pressed at `min`. With it, the segment shows a trash can there
|
|
172
|
+
* and removes the item, as a cart's stepper does at a quantity of one (without `wrap`).
|
|
173
|
+
*/
|
|
174
|
+
onRemove: PropType<() => void>;
|
|
175
|
+
/** Accessible name of the decrement segment when it removes. @default "Remove" */
|
|
176
|
+
removeLabel: {
|
|
177
|
+
type: StringConstructor;
|
|
178
|
+
default: string;
|
|
179
|
+
};
|
|
143
180
|
/** The name of the stepper. Submits its value with the owning form. */
|
|
144
181
|
name: StringConstructor;
|
|
145
182
|
/** Accessible name of the value the stepper changes, when no visible label names it. */
|
|
@@ -161,8 +198,10 @@ declare const StepperComponent: import("vue").DefineComponent<import("vue").Extr
|
|
|
161
198
|
pill: boolean;
|
|
162
199
|
max: number;
|
|
163
200
|
min: number;
|
|
201
|
+
removeLabel: string;
|
|
164
202
|
step: number;
|
|
165
203
|
autoRepeat: boolean;
|
|
204
|
+
showValue: boolean;
|
|
166
205
|
decrementLabel: string;
|
|
167
206
|
incrementLabel: string;
|
|
168
207
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -222,6 +261,14 @@ export declare const Stepper: import("vue").DefineComponent<import("vue").Extrac
|
|
|
222
261
|
type: BooleanConstructor;
|
|
223
262
|
default: boolean;
|
|
224
263
|
};
|
|
264
|
+
/**
|
|
265
|
+
* Shows the value between the minus and the plus on one fill, as a cart's quantity: round segments and no
|
|
266
|
+
* separator. Without it the stepper shows no value, as the native one. @default false
|
|
267
|
+
*/
|
|
268
|
+
showValue: {
|
|
269
|
+
type: BooleanConstructor;
|
|
270
|
+
default: boolean;
|
|
271
|
+
};
|
|
225
272
|
/** Accessible name of the decrement segment. @default "Decrease" */
|
|
226
273
|
decrementLabel: {
|
|
227
274
|
type: StringConstructor;
|
|
@@ -232,6 +279,16 @@ export declare const Stepper: import("vue").DefineComponent<import("vue").Extrac
|
|
|
232
279
|
type: StringConstructor;
|
|
233
280
|
default: string;
|
|
234
281
|
};
|
|
282
|
+
/**
|
|
283
|
+
* Called (`@remove`) when the decrement segment is pressed at `min`. With it, the segment shows a trash can there
|
|
284
|
+
* and removes the item, as a cart's stepper does at a quantity of one (without `wrap`).
|
|
285
|
+
*/
|
|
286
|
+
onRemove: PropType<() => void>;
|
|
287
|
+
/** Accessible name of the decrement segment when it removes. @default "Remove" */
|
|
288
|
+
removeLabel: {
|
|
289
|
+
type: StringConstructor;
|
|
290
|
+
default: string;
|
|
291
|
+
};
|
|
235
292
|
/** The name of the stepper. Submits its value with the owning form. */
|
|
236
293
|
name: StringConstructor;
|
|
237
294
|
/** Accessible name of the value the stepper changes, when no visible label names it. */
|
|
@@ -299,6 +356,14 @@ export declare const Stepper: import("vue").DefineComponent<import("vue").Extrac
|
|
|
299
356
|
type: BooleanConstructor;
|
|
300
357
|
default: boolean;
|
|
301
358
|
};
|
|
359
|
+
/**
|
|
360
|
+
* Shows the value between the minus and the plus on one fill, as a cart's quantity: round segments and no
|
|
361
|
+
* separator. Without it the stepper shows no value, as the native one. @default false
|
|
362
|
+
*/
|
|
363
|
+
showValue: {
|
|
364
|
+
type: BooleanConstructor;
|
|
365
|
+
default: boolean;
|
|
366
|
+
};
|
|
302
367
|
/** Accessible name of the decrement segment. @default "Decrease" */
|
|
303
368
|
decrementLabel: {
|
|
304
369
|
type: StringConstructor;
|
|
@@ -309,6 +374,16 @@ export declare const Stepper: import("vue").DefineComponent<import("vue").Extrac
|
|
|
309
374
|
type: StringConstructor;
|
|
310
375
|
default: string;
|
|
311
376
|
};
|
|
377
|
+
/**
|
|
378
|
+
* Called (`@remove`) when the decrement segment is pressed at `min`. With it, the segment shows a trash can there
|
|
379
|
+
* and removes the item, as a cart's stepper does at a quantity of one (without `wrap`).
|
|
380
|
+
*/
|
|
381
|
+
onRemove: PropType<() => void>;
|
|
382
|
+
/** Accessible name of the decrement segment when it removes. @default "Remove" */
|
|
383
|
+
removeLabel: {
|
|
384
|
+
type: StringConstructor;
|
|
385
|
+
default: string;
|
|
386
|
+
};
|
|
312
387
|
/** The name of the stepper. Submits its value with the owning form. */
|
|
313
388
|
name: StringConstructor;
|
|
314
389
|
/** Accessible name of the value the stepper changes, when no visible label names it. */
|
|
@@ -330,8 +405,10 @@ export declare const Stepper: import("vue").DefineComponent<import("vue").Extrac
|
|
|
330
405
|
pill: boolean;
|
|
331
406
|
max: number;
|
|
332
407
|
min: number;
|
|
408
|
+
removeLabel: string;
|
|
333
409
|
step: number;
|
|
334
410
|
autoRepeat: boolean;
|
|
411
|
+
showValue: boolean;
|
|
335
412
|
decrementLabel: string;
|
|
336
413
|
incrementLabel: string;
|
|
337
414
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexui/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Plex UI components for Vue 3, built on Reka UI and the shared @plexui/styles CSS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@maskito/core": "5.2.2",
|
|
78
78
|
"@maskito/kit": "5.2.2",
|
|
79
79
|
"@maskito/vue": "5.2.2",
|
|
80
|
-
"@plexui/styles": "^0.
|
|
80
|
+
"@plexui/styles": "^0.15.0",
|
|
81
81
|
"@tanstack/table-core": "8.21.3",
|
|
82
82
|
"@tanstack/vue-table": "8.21.3",
|
|
83
83
|
"@tiptap/core": "3.21.0",
|