@plexui/vue 0.36.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.
@@ -45,6 +45,11 @@ 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" */
@@ -199,12 +204,16 @@ const StepperComponent = defineComponent({
199
204
  "class": [s.Stepper, attrs.class],
200
205
  "data-disabled": props.disabled ? "" : undefined,
201
206
  "data-pill": props.pill ? "" : undefined,
207
+ "data-show-value": props.showValue ? "" : undefined,
202
208
  "onKeydown": handleKeyDown,
203
209
  "onFocus": (event) => emit("focus", event),
204
210
  "onBlur": (event) => emit("blur", event),
205
211
  }, [
206
212
  segment("decrement"),
207
- h("span", { "class": s.Separator, "aria-hidden": "true" }),
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" }),
208
217
  segment("increment"),
209
218
  props.name !== undefined ? h("input", { type: "hidden", name: props.name, value: value.value, disabled: props.disabled }) : null,
210
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,EAAiB,GAAG,EAAE,MAAM,KAAK,CAAA;AACvF,OAAO,CAAC,MAAM,sDAAsD,CAAA;AACpE,OAAO,EAAE,KAAK,EA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aAAa,EAAE,MAAM,EAAE,CAAC;YAC1D,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 /** 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 \"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,CAAC,CAAA;IAC9C,OAAO,QAAQ,CAAC,MAAM,CAAA;AACxB,CAAC,CAAA;AAED,8FAA8F;AAC9F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,SAAiB,EAAE,EAAE,GAAG,EAAE,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,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"]}
@@ -54,6 +54,14 @@ declare const StepperComponent: import("vue").DefineComponent<import("vue").Extr
54
54
  type: BooleanConstructor;
55
55
  default: boolean;
56
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
+ };
57
65
  /** Accessible name of the decrement segment. @default "Decrease" */
58
66
  decrementLabel: {
59
67
  type: StringConstructor;
@@ -141,6 +149,14 @@ declare const StepperComponent: import("vue").DefineComponent<import("vue").Extr
141
149
  type: BooleanConstructor;
142
150
  default: boolean;
143
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
+ };
144
160
  /** Accessible name of the decrement segment. @default "Decrease" */
145
161
  decrementLabel: {
146
162
  type: StringConstructor;
@@ -185,6 +201,7 @@ declare const StepperComponent: import("vue").DefineComponent<import("vue").Extr
185
201
  removeLabel: string;
186
202
  step: number;
187
203
  autoRepeat: boolean;
204
+ showValue: boolean;
188
205
  decrementLabel: string;
189
206
  incrementLabel: string;
190
207
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -244,6 +261,14 @@ export declare const Stepper: import("vue").DefineComponent<import("vue").Extrac
244
261
  type: BooleanConstructor;
245
262
  default: boolean;
246
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
+ };
247
272
  /** Accessible name of the decrement segment. @default "Decrease" */
248
273
  decrementLabel: {
249
274
  type: StringConstructor;
@@ -331,6 +356,14 @@ export declare const Stepper: import("vue").DefineComponent<import("vue").Extrac
331
356
  type: BooleanConstructor;
332
357
  default: boolean;
333
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
+ };
334
367
  /** Accessible name of the decrement segment. @default "Decrease" */
335
368
  decrementLabel: {
336
369
  type: StringConstructor;
@@ -375,6 +408,7 @@ export declare const Stepper: import("vue").DefineComponent<import("vue").Extrac
375
408
  removeLabel: string;
376
409
  step: number;
377
410
  autoRepeat: boolean;
411
+ showValue: boolean;
378
412
  decrementLabel: string;
379
413
  incrementLabel: string;
380
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.36.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.14.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",