@plexui/vue 0.5.2 → 0.6.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,26 +1,43 @@
1
1
  import { defineComponent, h } from "vue";
2
2
  import { wrapTextNodeSiblings } from "../../lib/renderHelpers.js";
3
+ import { X } from "../Icon/index.js";
3
4
  import s from "@plexui/styles/components/Badge/Badge.module.css";
4
5
  const BadgeComponent = defineComponent({
5
6
  name: "Badge",
6
7
  props: {
7
8
  /** Visual style of the badge. @default "soft" */
8
9
  variant: { type: String, default: "soft" },
9
- /** Size scale of the badge: `sm` 20px, `md` 22px, `lg` 24px. @default "sm" */
10
+ /** Size scale of the badge: `sm` 20px, `md` 22px, `lg` 24px, `xl` 32px. @default "sm" */
10
11
  size: { type: String, default: "sm" },
11
12
  /** Determines if the badge should be a fully rounded pill shape. @default false */
12
13
  pill: { type: Boolean, default: false },
13
14
  /** Color of the badge, related to its meaning or intent. @default "secondary" */
14
15
  color: { type: String, default: "secondary" },
16
+ /** Adds a cross at the end of the badge that calls this when pressed. */
17
+ onRemove: Function,
18
+ /** Accessible name of the cross. @default "Remove" */
19
+ removeLabel: { type: String, default: "Remove" },
20
+ /** Shows the cross as a mark, for a badge inside a control that takes the press. @default false */
21
+ removable: { type: Boolean, default: false },
15
22
  },
16
23
  setup(props, { slots }) {
17
- return () => h("div", {
18
- "class": s.Badge,
19
- "data-color": props.color,
20
- "data-size": props.size,
21
- "data-pill": props.pill ? "" : undefined,
22
- "data-variant": props.variant,
23
- }, wrapTextNodeSiblings(slots.default?.()));
24
+ const renderRemove = () => {
25
+ if (props.onRemove) {
26
+ return h("button", { "type": "button", "class": s.Remove, "aria-label": props.removeLabel, "onClick": props.onRemove }, [h(X)]);
27
+ }
28
+ return props.removable ? h("span", { "class": s.Remove, "aria-hidden": "true" }, [h(X)]) : null;
29
+ };
30
+ return () => {
31
+ const children = slots.default?.() ?? [];
32
+ const remove = renderRemove();
33
+ return h("div", {
34
+ "class": s.Badge,
35
+ "data-color": props.color,
36
+ "data-size": props.size,
37
+ "data-pill": props.pill ? "" : undefined,
38
+ "data-variant": props.variant,
39
+ }, wrapTextNodeSiblings(remove ? [...children, remove] : children));
40
+ };
24
41
  },
25
42
  });
26
43
  export const Badge = BadgeComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../../src/components/Badge/Badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAUhE,MAAM,cAAc,GAAG,eAAe,CAAC;IACrC,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,iDAAiD;QACjD,OAAO,EAAE,EAAE,IAAI,EAAE,MAA0D,EAAE,OAAO,EAAE,MAAM,EAAE;QAC9F,8EAA8E;QAC9E,IAAI,EAAE,EAAE,IAAI,EAAE,MAA6C,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5E,mFAAmF;QACnF,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;QACvC,iFAAiF;QACjF,KAAK,EAAE,EAAE,IAAI,EAAE,MAA8B,EAAE,OAAO,EAAE,WAAW,EAAE;KACtE;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,GAAG,EAAE,CACV,CAAC,CACC,KAAK,EACL;YACE,OAAO,EAAE,CAAC,CAAC,KAAK;YAChB,YAAY,EAAE,KAAK,CAAC,KAAK;YACzB,WAAW,EAAE,KAAK,CAAC,IAAI;YACvB,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;YACxC,cAAc,EAAE,KAAK,CAAC,OAAO;SAC9B,EACD,oBAAoB,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CACxC,CAAA;IACL,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport type { SemanticColors, Sizes, Variants } from \"@plexui/styles/types\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers.js\"\nimport s from \"@plexui/styles/components/Badge/Badge.module.css\"\n\n// Vue port of packages/ui/src/components/Badge/index.tsx. React spreads the\n// remaining props after its own attributes, so caller attributes win; Vue's\n// attribute fallthrough merges them onto the root the same way.\n\nexport type BadgeColor = SemanticColors<\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n>\n\nconst BadgeComponent = defineComponent({\n name: \"Badge\",\n props: {\n /** Visual style of the badge. @default \"soft\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\">>, default: \"soft\" },\n /** Size scale of the badge: `sm` 20px, `md` 22px, `lg` 24px. @default \"sm\" */\n size: { type: String as PropType<Sizes<\"sm\" | \"md\" | \"lg\">>, default: \"sm\" },\n /** Determines if the badge should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Color of the badge, related to its meaning or intent. @default \"secondary\" */\n color: { type: String as PropType<BadgeColor>, default: \"secondary\" },\n },\n setup(props, { slots }) {\n return () =>\n h(\n \"div\",\n {\n \"class\": s.Badge,\n \"data-color\": props.color,\n \"data-size\": props.size,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-variant\": props.variant,\n },\n wrapTextNodeSiblings(slots.default?.()),\n )\n },\n})\n\ntype BadgeOwnProps = InstanceType<typeof BadgeComponent>[\"$props\"]\n\n/** Badge props plus the native <div> attributes that fall through to it, as in React. */\nexport type BadgeProps = BadgeOwnProps & Omit<HTMLAttributes, keyof BadgeOwnProps>\n\nexport const Badge = BadgeComponent as typeof BadgeComponent & { new (): { $props: BadgeProps } }\n"]}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EAAE,EACnG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACP,CAAA;YACH,CAAC;YACD,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACjG,CAAC,CAAA;QAED,OAAO,GAAG,EAAE;YACV,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAA;YACxC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAA;YAE7B,OAAO,CAAC,CACN,KAAK,EACL;gBACE,OAAO,EAAE,CAAC,CAAC,KAAK;gBAChB,YAAY,EAAE,KAAK,CAAC,KAAK;gBACzB,WAAW,EAAE,KAAK,CAAC,IAAI;gBACvB,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;gBACxC,cAAc,EAAE,KAAK,CAAC,OAAO;aAC9B,EACD,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAChE,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport type { SemanticColors, Sizes, Variants } from \"@plexui/styles/types\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers.js\"\nimport { X } from \"../Icon/index.js\"\nimport s from \"@plexui/styles/components/Badge/Badge.module.css\"\n\n// Vue port of packages/ui/src/components/Badge/index.tsx. React spreads the\n// remaining props after its own attributes, so caller attributes win; Vue's\n// attribute fallthrough merges them onto the root the same way.\n\nexport type BadgeColor = SemanticColors<\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n>\n\nconst BadgeComponent = defineComponent({\n name: \"Badge\",\n props: {\n /** Visual style of the badge. @default \"soft\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\">>, default: \"soft\" },\n /** Size scale of the badge: `sm` 20px, `md` 22px, `lg` 24px, `xl` 32px. @default \"sm\" */\n size: { type: String as PropType<Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\">>, default: \"sm\" },\n /** Determines if the badge should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Color of the badge, related to its meaning or intent. @default \"secondary\" */\n color: { type: String as PropType<BadgeColor>, default: \"secondary\" },\n /** Adds a cross at the end of the badge that calls this when pressed. */\n onRemove: Function as PropType<(event: MouseEvent) => void>,\n /** Accessible name of the cross. @default \"Remove\" */\n removeLabel: { type: String, default: \"Remove\" },\n /** Shows the cross as a mark, for a badge inside a control that takes the press. @default false */\n removable: { type: Boolean, default: false },\n },\n setup(props, { slots }) {\n const renderRemove = () => {\n if (props.onRemove) {\n return h(\n \"button\",\n { \"type\": \"button\", \"class\": s.Remove, \"aria-label\": props.removeLabel, \"onClick\": props.onRemove },\n [h(X)],\n )\n }\n return props.removable ? h(\"span\", { \"class\": s.Remove, \"aria-hidden\": \"true\" }, [h(X)]) : null\n }\n\n return () => {\n const children = slots.default?.() ?? []\n const remove = renderRemove()\n\n return h(\n \"div\",\n {\n \"class\": s.Badge,\n \"data-color\": props.color,\n \"data-size\": props.size,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-variant\": props.variant,\n },\n wrapTextNodeSiblings(remove ? [...children, remove] : children),\n )\n }\n },\n})\n\ntype BadgeOwnProps = InstanceType<typeof BadgeComponent>[\"$props\"]\n\n/** Badge props plus the native <div> attributes that fall through to it, as in React. */\nexport type BadgeProps = BadgeOwnProps & Omit<HTMLAttributes, keyof BadgeOwnProps>\n\nexport const Badge = BadgeComponent as typeof BadgeComponent & { new (): { $props: BadgeProps } }\n"]}
@@ -1,6 +1,7 @@
1
1
  import clsx, {} from "clsx";
2
2
  import { Comment, Fragment, Static, Text, camelize, cloneVNode, defineComponent, h, isVNode, useId, } from "vue";
3
3
  import { FieldError } from "../FieldError/index.js";
4
+ import { provideFieldRow } from "../../lib/fieldRow.js";
4
5
  import { hasContent } from "../../lib/slotContent.js";
5
6
  import s from "@plexui/styles/components/Field/Field.module.css";
6
7
  const CONTROL_SIZES = new Set(["3xs", "2xs", "xs", "sm", "md", "lg", "xl", "2xl", "3xl"]);
@@ -126,6 +127,7 @@ const FieldComponent = defineComponent({
126
127
  slots: Object,
127
128
  setup(props, { attrs, slots }) {
128
129
  const generatedId = useId();
130
+ provideFieldRow(() => !!props.row && (props.orientation ?? "horizontal") === "horizontal");
129
131
  return () => {
130
132
  const { required, row, opticallyAlign } = props;
131
133
  const orientation = props.orientation ?? (row ? "horizontal" : "vertical");
@@ -186,6 +188,7 @@ const FieldComponent = defineComponent({
186
188
  h("div", { class: s.Control }, resolvedChildren),
187
189
  hasError ? h(FieldError, { id: errorId }, () => [errorMessage]) : null,
188
190
  ]),
191
+ row && slots.action ? h("div", { class: s.Action }, [slots.action()]) : null,
189
192
  ]);
190
193
  };
191
194
  },
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../../src/components/Field/Field.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,eAAe,EACf,CAAC,EACD,OAAO,EACP,KAAK,GAMN,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,CAAC,MAAM,kDAAkD,CAAA;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E,EAAE;oBAChC,cAAc;wBACZ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAyB,CAAC,CAAC,CAAC,CAAC;wBAClH,CAAC,CAAC,YAAY;oBAChB,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,CAAC,WAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;iBAC3G,CAAC;gBACF,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE;oBAC7B,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,gBAAgB,CAAC;oBAChD,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,YAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;iBACrF,CAAC;aACH,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,mFAAmF;AACnF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import clsx, { type ClassValue } from \"clsx\"\nimport {\n Comment,\n Fragment,\n Static,\n Text,\n camelize,\n cloneVNode,\n defineComponent,\n h,\n isVNode,\n useId,\n type PropType,\n type SlotsType,\n type VNode,\n type VNodeArrayChildren,\n type VNodeChild,\n} from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { FieldError } from \"../FieldError/index.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/Field/Field.module.css\"\n\n// Vue port of packages/ui/src/components/Field/Field.tsx.\n//\n// - `label`, `description` and `errorMessage` take a string prop or a slot of\n// the same name (the slot wins), like React's ReactNode props.\n// - Children: React accepts an element, which Field clones with the field\n// props, or a render prop `(fieldProps) => ReactNode`, which it leaves alone.\n// Both are the default slot here, which receives the field props:\n// - a slot that reads them (`v-slot=\"fieldProps\"` + `v-bind=\"fieldProps\"`,\n// `v-slot=\"{ id }\"`, `(fieldProps) => h(...)`) is the render prop: its\n// content renders as it is.\n// - a slot that does not read them and holds exactly one element or\n// component gets it cloned like React's `cloneElement`: `opticallyAlign`\n// replaces the child's own, the child's own `id` stays and the label's\n// `for` follows it, `aria-describedby` is joined after the child's own\n// ids, and an explicit `aria-invalid` on the child wins. Template\n// comments do not count as children (JSX comments); the\n// placeholder of a `v-if` that renders nothing does, like `{false}` in a\n// React children array, so `<A v-if=\"x\" /><Input />` is not cloned.\n// - anything else (text, several roots, a `v-for` list) renders as it is,\n// like a React child that is not a single element.\n// - content a wrapper forwards with `<slot />` counts as its own roots, as\n// React's `children` passed on to Field are the elements themselves.\n// - As in React only `class` reaches the root element; other attributes are\n// dropped. On a `row` they all reach it, as React's rest props do.\n\nexport type FieldChildProps = {\n id: string\n /** The label's id. Bind it to a control that the label's `for` cannot name, such as a Select trigger. */\n \"aria-labelledby\"?: string\n \"aria-describedby\"?: string\n \"aria-invalid\"?: boolean\n opticallyAlign?: \"start\" | \"end\"\n}\n\ntype Props = Record<string, unknown>\n\nconst CONTROL_SIZES: ReadonlySet<unknown> = new Set([\"3xs\", \"2xs\", \"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\", \"3xl\"])\n\n/** The slot props, recording whether the slot read them (the render-prop form). */\nconst trackUse = (target: FieldChildProps) => {\n const state = { used: false }\n const proxy = new Proxy(target, {\n get(object, key, receiver) {\n state.used = true\n return Reflect.get(object, key, receiver)\n },\n has(object, key) {\n state.used = true\n return Reflect.has(object, key)\n },\n ownKeys(object) {\n state.used = true\n return Reflect.ownKeys(object)\n },\n getOwnPropertyDescriptor(object, key) {\n state.used = true\n return Reflect.getOwnPropertyDescriptor(object, key)\n },\n })\n return { proxy, state }\n}\n\n/** Like React's `isValidElement` for a slot root: an element or a component. */\nconst isElementVNode = (node: VNode) => {\n const { type } = node\n if (type === Fragment || type === Text || type === Comment || type === Static) return false\n if (typeof type === \"object\" && type !== null && (\"__isTeleport\" in type || \"__isSuspense\" in type)) return false\n return true\n}\n\n/**\n * Template comments (`<!-- note -->`) are no children, like JSX comments.\n * The empty placeholder of a `v-if` that renders nothing (or of a `false`\n * child) still counts, like `{false}` in a React children array.\n */\nconst isTemplateComment = (node: VNodeArrayChildren[number]) =>\n isVNode(node) && node.type === Comment && !!node.children && node.children !== \"v-if\"\n\n/**\n * Unwraps content forwarded through a wrapper's `<slot />`: the fragment\n * `renderSlot` creates, keyed `_<slot name>`.\n */\nconst unwrapForwardedSlots = (nodes: VNodeArrayChildren): VNodeArrayChildren =>\n nodes.flatMap((node) =>\n isVNode(node) &&\n node.type === Fragment &&\n typeof node.key === \"string\" &&\n node.key.startsWith(\"_\") &&\n Array.isArray(node.children)\n ? unwrapForwardedSlots(node.children)\n : [node],\n )\n\n/** The one element a non-render-prop slot holds, if it holds exactly one. */\nconst singleElement = (nodes: VNodeArrayChildren): VNode | undefined => {\n const roots = unwrapForwardedSlots(nodes).filter((node) => !isTemplateComment(node))\n if (roots.length !== 1) return undefined\n const [root] = roots\n return isVNode(root) && isElementVNode(root) ? root : undefined\n}\n\n/** A child prop under its attribute name or its camelCase prop name. */\nconst childProp = (props: Props, name: string) => props[name] ?? props[camelize(name)]\n\n/**\n * `cloneElement(child, fieldProps)` with React Field's merging rules. A child\n * without its own name (`aria-label`, `aria-labelledby`, `label`, a `#label`\n * slot) is also labelled by the field's label, which names triggers `for`\n * cannot reach.\n */\nconst cloneWithFieldProps = (child: VNode, fieldChildProps: FieldChildProps, labelId: string): VNode => {\n const own: Props = { ...(child.props ?? {}) }\n const childDescribedBy = childProp(own, \"aria-describedby\") as string | undefined\n const childInvalid = childProp(own, \"aria-invalid\")\n const childSlots = child.children\n const childNamed =\n childProp(own, \"aria-label\") != null ||\n childProp(own, \"aria-labelledby\") != null ||\n own.label != null ||\n (childSlots != null && typeof childSlots === \"object\" && !Array.isArray(childSlots) && \"label\" in childSlots)\n\n const overrides: Props = {\n ...fieldChildProps,\n // Merge with the child's own associations instead of overwriting them\n \"aria-describedby\": [childDescribedBy, fieldChildProps[\"aria-describedby\"]].filter(Boolean).join(\" \") || undefined,\n \"aria-invalid\": childInvalid ?? fieldChildProps[\"aria-invalid\"],\n ...(!childNamed && { \"aria-labelledby\": labelId }),\n }\n\n // One spelling per prop, so the field's value is the one that applies\n for (const key of Object.keys(overrides)) {\n for (const spelling of [key, camelize(key), key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)]) {\n delete own[spelling]\n }\n }\n\n return cloneVNode({ ...child, props: own } as VNode, overrides)\n}\n\nconst FieldComponent = defineComponent({\n name: \"Field\",\n inheritAttrs: false,\n props: {\n /** Label text for the field (or the `label` slot) */\n label: String,\n /** Helper text below the label, linked via `aria-describedby` (or the `description` slot) */\n description: String,\n /**\n * Error message below the control (or the `errorMessage` slot). When set,\n * the control gets `aria-invalid=\"true\"`. Rendered with FieldError.\n */\n errorMessage: String,\n /** Content at the end of the label row, such as a link that acts on the field (or the `labelAction` slot) */\n labelAction: String,\n /** Font size of the label, to match the control's size. @default the child control's `size`, else \"md\" */\n size: String as PropType<ControlSize>,\n /** Shows a required asterisk after the label. Visual only: no `required` attribute. @default false */\n required: { type: Boolean, default: false },\n /** Layout direction of label and control. @default \"horizontal\" on a `row`, else \"vertical\" */\n orientation: String as PropType<\"vertical\" | \"horizontal\">,\n /** One line of a FieldGroup: label at the start, control at the end. @default false */\n row: { type: Boolean, default: false },\n /** On a `row`, the control takes the rest of the line after the label. @default false */\n fill: { type: Boolean, default: false },\n /** Overrides the generated id set on the control and the label's `for`. A child's own `id` wins over both. */\n id: String,\n /** Optically aligns the control's text with surrounding content; passed to the control. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n },\n slots: Object as SlotsType<{\n /** The control. Read the props to render them yourself (React's render prop). */\n default?: (fieldProps: FieldChildProps) => VNodeChild\n label?: () => VNodeChild\n labelAction?: () => VNodeChild\n description?: () => VNodeChild\n errorMessage?: () => VNodeChild\n }>,\n setup(props, { attrs, slots }) {\n const generatedId = useId()\n\n return () => {\n const { required, row, opticallyAlign } = props\n const orientation = props.orientation ?? (row ? \"horizontal\" : \"vertical\")\n const fieldId = props.id || `field-${generatedId}`\n const labelId = `${fieldId}-label`\n\n const description = slots.description ? slots.description() : props.description\n const hasDescription = slots.description ? hasContent(description as VNodeArrayChildren) : !!description\n const errorMessage = slots.errorMessage ? slots.errorMessage() : props.errorMessage\n const hasError = slots.errorMessage ? hasContent(errorMessage as VNodeArrayChildren) : !!errorMessage\n\n const descriptionId = hasDescription ? `${fieldId}-description` : undefined\n const errorId = hasError ? `${fieldId}-error` : undefined\n\n // Build aria-describedby from description + error IDs\n const ariaDescribedBy = [descriptionId, errorId].filter(Boolean).join(\" \") || undefined\n const invalid = hasError\n\n // Props to inject into the child control\n const fieldChildProps: FieldChildProps = {\n \"id\": fieldId,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": invalid || undefined,\n ...(opticallyAlign && { opticallyAlign }),\n }\n\n // Resolve the children\n let resolvedChildren: VNodeArrayChildren | undefined\n let childSize: unknown\n // The control's id, which the label's `for` has to match\n let controlId = fieldId\n if (slots.default) {\n const { proxy, state } = trackUse({ ...fieldChildProps, \"aria-labelledby\": labelId })\n const nodes = slots.default(proxy) as VNodeArrayChildren\n const child = state.used ? undefined : singleElement(nodes)\n childSize = child?.props?.size\n controlId = (child?.props?.id as string | undefined) || fieldId\n resolvedChildren = child ? [cloneWithFieldProps(child, { ...fieldChildProps, id: controlId }, labelId)] : nodes\n }\n const size = props.size ?? (CONTROL_SIZES.has(childSize) ? (childSize as ControlSize) : \"md\")\n\n const labelAction = slots.labelAction ? slots.labelAction() : props.labelAction\n const hasLabelAction = slots.labelAction ? hasContent(labelAction as VNodeArrayChildren) : !!labelAction\n const labelElement = h(\"label\", { class: s.Label, id: labelId, for: controlId }, [\n slots.label ? slots.label() : props.label,\n required ? h(\"span\", { \"class\": s.RequiredIndicator, \"aria-hidden\": \"true\" }, \"*\") : null,\n ])\n\n return h(\n \"div\",\n {\n ...(row && attrs),\n \"class\": clsx(s.Field, attrs.class as ClassValue),\n \"data-size\": size,\n \"data-orientation\": orientation,\n \"data-optically-align\": opticallyAlign,\n \"data-row\": row ? \"\" : undefined,\n \"data-fill\": props.fill ? \"\" : undefined,\n },\n [\n h(\"div\", { class: s.LabelGroup }, [\n hasLabelAction\n ? h(\"div\", { class: s.LabelRow }, [labelElement, h(\"div\", { class: s.LabelAction }, [labelAction as VNodeChild])])\n : labelElement,\n hasDescription ? h(\"div\", { class: s.Description, id: descriptionId }, [description as VNodeChild]) : null,\n ]),\n h(\"div\", { class: s.Content }, [\n h(\"div\", { class: s.Control }, resolvedChildren),\n hasError ? h(FieldError, { id: errorId }, () => [errorMessage as VNodeChild]) : null,\n ]),\n ],\n )\n }\n },\n})\n\ntype FieldOwnProps = InstanceType<typeof FieldComponent>[\"$props\"]\n\n/** Field props; `class` reaches the root element. */\nexport type FieldProps = FieldOwnProps & { class?: ClassValue }\n\n/** Form field wrapper with label, description, error and accessibility linking. */\nexport const Field = FieldComponent as typeof FieldComponent & { new (): { $props: FieldProps } }\n"]}
1
+ {"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../../src/components/Field/Field.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,eAAe,EACf,CAAC,EACD,OAAO,EACP,KAAK,GAMN,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,UAA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EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;aAC7E,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,mFAAmF;AACnF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import clsx, { type ClassValue } from \"clsx\"\nimport {\n Comment,\n Fragment,\n Static,\n Text,\n camelize,\n cloneVNode,\n defineComponent,\n h,\n isVNode,\n useId,\n type PropType,\n type SlotsType,\n type VNode,\n type VNodeArrayChildren,\n type VNodeChild,\n} from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { FieldError } from \"../FieldError/index.js\"\nimport { provideFieldRow } from \"../../lib/fieldRow.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/Field/Field.module.css\"\n\n// Vue port of packages/ui/src/components/Field/Field.tsx.\n//\n// - `label`, `description` and `errorMessage` take a string prop or a slot of\n// the same name (the slot wins), like React's ReactNode props.\n// - Children: React accepts an element, which Field clones with the field\n// props, or a render prop `(fieldProps) => ReactNode`, which it leaves alone.\n// Both are the default slot here, which receives the field props:\n// - a slot that reads them (`v-slot=\"fieldProps\"` + `v-bind=\"fieldProps\"`,\n// `v-slot=\"{ id }\"`, `(fieldProps) => h(...)`) is the render prop: its\n// content renders as it is.\n// - a slot that does not read them and holds exactly one element or\n// component gets it cloned like React's `cloneElement`: `opticallyAlign`\n// replaces the child's own, the child's own `id` stays and the label's\n// `for` follows it, `aria-describedby` is joined after the child's own\n// ids, and an explicit `aria-invalid` on the child wins. Template\n// comments do not count as children (JSX comments); the\n// placeholder of a `v-if` that renders nothing does, like `{false}` in a\n// React children array, so `<A v-if=\"x\" /><Input />` is not cloned.\n// - anything else (text, several roots, a `v-for` list) renders as it is,\n// like a React child that is not a single element.\n// - content a wrapper forwards with `<slot />` counts as its own roots, as\n// React's `children` passed on to Field are the elements themselves.\n// - As in React only `class` reaches the root element; other attributes are\n// dropped. On a `row` they all reach it, as React's rest props do.\n\nexport type FieldChildProps = {\n id: string\n /** The label's id. Bind it to a control that the label's `for` cannot name, such as a Select trigger. */\n \"aria-labelledby\"?: string\n \"aria-describedby\"?: string\n \"aria-invalid\"?: boolean\n opticallyAlign?: \"start\" | \"end\"\n}\n\ntype Props = Record<string, unknown>\n\nconst CONTROL_SIZES: ReadonlySet<unknown> = new Set([\"3xs\", \"2xs\", \"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\", \"3xl\"])\n\n/** The slot props, recording whether the slot read them (the render-prop form). */\nconst trackUse = (target: FieldChildProps) => {\n const state = { used: false }\n const proxy = new Proxy(target, {\n get(object, key, receiver) {\n state.used = true\n return Reflect.get(object, key, receiver)\n },\n has(object, key) {\n state.used = true\n return Reflect.has(object, key)\n },\n ownKeys(object) {\n state.used = true\n return Reflect.ownKeys(object)\n },\n getOwnPropertyDescriptor(object, key) {\n state.used = true\n return Reflect.getOwnPropertyDescriptor(object, key)\n },\n })\n return { proxy, state }\n}\n\n/** Like React's `isValidElement` for a slot root: an element or a component. */\nconst isElementVNode = (node: VNode) => {\n const { type } = node\n if (type === Fragment || type === Text || type === Comment || type === Static) return false\n if (typeof type === \"object\" && type !== null && (\"__isTeleport\" in type || \"__isSuspense\" in type)) return false\n return true\n}\n\n/**\n * Template comments (`<!-- note -->`) are no children, like JSX comments.\n * The empty placeholder of a `v-if` that renders nothing (or of a `false`\n * child) still counts, like `{false}` in a React children array.\n */\nconst isTemplateComment = (node: VNodeArrayChildren[number]) =>\n isVNode(node) && node.type === Comment && !!node.children && node.children !== \"v-if\"\n\n/**\n * Unwraps content forwarded through a wrapper's `<slot />`: the fragment\n * `renderSlot` creates, keyed `_<slot name>`.\n */\nconst unwrapForwardedSlots = (nodes: VNodeArrayChildren): VNodeArrayChildren =>\n nodes.flatMap((node) =>\n isVNode(node) &&\n node.type === Fragment &&\n typeof node.key === \"string\" &&\n node.key.startsWith(\"_\") &&\n Array.isArray(node.children)\n ? unwrapForwardedSlots(node.children)\n : [node],\n )\n\n/** The one element a non-render-prop slot holds, if it holds exactly one. */\nconst singleElement = (nodes: VNodeArrayChildren): VNode | undefined => {\n const roots = unwrapForwardedSlots(nodes).filter((node) => !isTemplateComment(node))\n if (roots.length !== 1) return undefined\n const [root] = roots\n return isVNode(root) && isElementVNode(root) ? root : undefined\n}\n\n/** A child prop under its attribute name or its camelCase prop name. */\nconst childProp = (props: Props, name: string) => props[name] ?? props[camelize(name)]\n\n/**\n * `cloneElement(child, fieldProps)` with React Field's merging rules. A child\n * without its own name (`aria-label`, `aria-labelledby`, `label`, a `#label`\n * slot) is also labelled by the field's label, which names triggers `for`\n * cannot reach.\n */\nconst cloneWithFieldProps = (child: VNode, fieldChildProps: FieldChildProps, labelId: string): VNode => {\n const own: Props = { ...(child.props ?? {}) }\n const childDescribedBy = childProp(own, \"aria-describedby\") as string | undefined\n const childInvalid = childProp(own, \"aria-invalid\")\n const childSlots = child.children\n const childNamed =\n childProp(own, \"aria-label\") != null ||\n childProp(own, \"aria-labelledby\") != null ||\n own.label != null ||\n (childSlots != null && typeof childSlots === \"object\" && !Array.isArray(childSlots) && \"label\" in childSlots)\n\n const overrides: Props = {\n ...fieldChildProps,\n // Merge with the child's own associations instead of overwriting them\n \"aria-describedby\": [childDescribedBy, fieldChildProps[\"aria-describedby\"]].filter(Boolean).join(\" \") || undefined,\n \"aria-invalid\": childInvalid ?? fieldChildProps[\"aria-invalid\"],\n ...(!childNamed && { \"aria-labelledby\": labelId }),\n }\n\n // One spelling per prop, so the field's value is the one that applies\n for (const key of Object.keys(overrides)) {\n for (const spelling of [key, camelize(key), key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)]) {\n delete own[spelling]\n }\n }\n\n return cloneVNode({ ...child, props: own } as VNode, overrides)\n}\n\nconst FieldComponent = defineComponent({\n name: \"Field\",\n inheritAttrs: false,\n props: {\n /** Label text for the field (or the `label` slot) */\n label: String,\n /** Helper text below the label, linked via `aria-describedby` (or the `description` slot) */\n description: String,\n /**\n * Error message below the control (or the `errorMessage` slot). When set,\n * the control gets `aria-invalid=\"true\"`. Rendered with FieldError.\n */\n errorMessage: String,\n /** Content at the end of the label row, such as a link that acts on the field (or the `labelAction` slot) */\n labelAction: String,\n /** Font size of the label, to match the control's size. @default the child control's `size`, else \"md\" */\n size: String as PropType<ControlSize>,\n /** Shows a required asterisk after the label. Visual only: no `required` attribute. @default false */\n required: { type: Boolean, default: false },\n /** Layout direction of label and control. @default \"horizontal\" on a `row`, else \"vertical\" */\n orientation: String as PropType<\"vertical\" | \"horizontal\">,\n /** One line of a FieldGroup: label at the start, control at the end. @default false */\n row: { type: Boolean, default: false },\n /** On a `row`, the control takes the rest of the line after the label. @default false */\n fill: { type: Boolean, default: false },\n /** Overrides the generated id set on the control and the label's `for`. A child's own `id` wins over both. */\n id: String,\n /** Optically aligns the control's text with surrounding content; passed to the control. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n },\n slots: Object as SlotsType<{\n /** The control. Read the props to render them yourself (React's render prop). */\n default?: (fieldProps: FieldChildProps) => VNodeChild\n label?: () => VNodeChild\n labelAction?: () => VNodeChild\n /** On a `fill` row, a control at the end of the row, such as a button that adds to a list. */\n action?: () => VNodeChild\n description?: () => VNodeChild\n errorMessage?: () => VNodeChild\n }>,\n setup(props, { attrs, slots }) {\n const generatedId = useId()\n\n provideFieldRow(() => !!props.row && (props.orientation ?? \"horizontal\") === \"horizontal\")\n\n return () => {\n const { required, row, opticallyAlign } = props\n const orientation = props.orientation ?? (row ? \"horizontal\" : \"vertical\")\n const fieldId = props.id || `field-${generatedId}`\n const labelId = `${fieldId}-label`\n\n const description = slots.description ? slots.description() : props.description\n const hasDescription = slots.description ? hasContent(description as VNodeArrayChildren) : !!description\n const errorMessage = slots.errorMessage ? slots.errorMessage() : props.errorMessage\n const hasError = slots.errorMessage ? hasContent(errorMessage as VNodeArrayChildren) : !!errorMessage\n\n const descriptionId = hasDescription ? `${fieldId}-description` : undefined\n const errorId = hasError ? `${fieldId}-error` : undefined\n\n // Build aria-describedby from description + error IDs\n const ariaDescribedBy = [descriptionId, errorId].filter(Boolean).join(\" \") || undefined\n const invalid = hasError\n\n // Props to inject into the child control\n const fieldChildProps: FieldChildProps = {\n \"id\": fieldId,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": invalid || undefined,\n ...(opticallyAlign && { opticallyAlign }),\n }\n\n // Resolve the children\n let resolvedChildren: VNodeArrayChildren | undefined\n let childSize: unknown\n // The control's id, which the label's `for` has to match\n let controlId = fieldId\n if (slots.default) {\n const { proxy, state } = trackUse({ ...fieldChildProps, \"aria-labelledby\": labelId })\n const nodes = slots.default(proxy) as VNodeArrayChildren\n const child = state.used ? undefined : singleElement(nodes)\n childSize = child?.props?.size\n controlId = (child?.props?.id as string | undefined) || fieldId\n resolvedChildren = child ? [cloneWithFieldProps(child, { ...fieldChildProps, id: controlId }, labelId)] : nodes\n }\n const size = props.size ?? (CONTROL_SIZES.has(childSize) ? (childSize as ControlSize) : \"md\")\n\n const labelAction = slots.labelAction ? slots.labelAction() : props.labelAction\n const hasLabelAction = slots.labelAction ? hasContent(labelAction as VNodeArrayChildren) : !!labelAction\n const labelElement = h(\"label\", { class: s.Label, id: labelId, for: controlId }, [\n slots.label ? slots.label() : props.label,\n required ? h(\"span\", { \"class\": s.RequiredIndicator, \"aria-hidden\": \"true\" }, \"*\") : null,\n ])\n\n return h(\n \"div\",\n {\n ...(row && attrs),\n \"class\": clsx(s.Field, attrs.class as ClassValue),\n \"data-size\": size,\n \"data-orientation\": orientation,\n \"data-optically-align\": opticallyAlign,\n \"data-row\": row ? \"\" : undefined,\n \"data-fill\": props.fill ? \"\" : undefined,\n },\n [\n h(\"div\", { class: s.LabelGroup }, [\n hasLabelAction\n ? h(\"div\", { class: s.LabelRow }, [labelElement, h(\"div\", { class: s.LabelAction }, [labelAction as VNodeChild])])\n : labelElement,\n hasDescription ? h(\"div\", { class: s.Description, id: descriptionId }, [description as VNodeChild]) : null,\n ]),\n h(\"div\", { class: s.Content }, [\n h(\"div\", { class: s.Control }, resolvedChildren),\n hasError ? h(FieldError, { id: errorId }, () => [errorMessage as VNodeChild]) : null,\n ]),\n row && slots.action ? h(\"div\", { class: s.Action }, [slots.action()]) : null,\n ],\n )\n }\n },\n})\n\ntype FieldOwnProps = InstanceType<typeof FieldComponent>[\"$props\"]\n\n/** Field props; `class` reaches the root element. */\nexport type FieldProps = FieldOwnProps & { class?: ClassValue }\n\n/** Form field wrapper with label, description, error and accessibility linking. */\nexport const Field = FieldComponent as typeof FieldComponent & { new (): { $props: FieldProps } }\n"]}
@@ -2,6 +2,7 @@ import clsx, {} from "clsx";
2
2
  import { defineComponent, h, mergeProps, nextTick, onMounted, ref, useId, watch, withDirectives } from "vue";
3
3
  import { X } from "../Icon/index.js";
4
4
  import { vDefaultValue } from "../../lib/defaultValue.js";
5
+ import { useFieldRowPill } from "../../lib/fieldRow.js";
5
6
  import { hasContent } from "../../lib/slotContent.js";
6
7
  import s from "@plexui/styles/components/Input/Input.module.css";
7
8
  // Vue port of packages/ui/src/components/Input/Input.tsx.
@@ -43,7 +44,7 @@ const InputComponent = defineComponent({
43
44
  autoSelect: { type: Boolean, default: undefined },
44
45
  /** Shows the clear button while the input has a value; called when it is clicked. */
45
46
  onClear: Function,
46
- /** Fully rounded pill shape. @default false */
47
+ /** Fully rounded pill shape. @default false, or true at the end of a `Field row` */
47
48
  pill: { type: Boolean, default: undefined },
48
49
  /** Applies a negative margin using the current gutter to optically align the input with surrounding content. */
49
50
  opticallyAlign: String,
@@ -67,6 +68,7 @@ const InputComponent = defineComponent({
67
68
  // Prevent 1Password from appearing: 1Password won't display if it thinks this field is for searching
68
69
  // Allow user to override this for connecting to labels.
69
70
  const onePasswordPreventionId = `search-ui-input-${useId()}`;
71
+ const pill = useFieldRowPill(() => props.pill);
70
72
  const focused = ref(false);
71
73
  // Redirect clicks on the container and adornments
72
74
  const handleMouseDown = (evt) => {
@@ -177,7 +179,7 @@ const InputComponent = defineComponent({
177
179
  "data-disabled": disabled ? "" : undefined,
178
180
  "data-readonly": readOnly ? "" : undefined,
179
181
  "data-invalid": props.invalid ? "" : undefined,
180
- "data-pill": props.pill ? "" : undefined,
182
+ "data-pill": pill.value ? "" : undefined,
181
183
  "data-optically-align": props.opticallyAlign,
182
184
  "data-has-start-adornment": hasStartAdornment ? "" : undefined,
183
185
  "data-has-end-adornment": hasEndAdornment || showClearButton ? "" : undefined,
@@ -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,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAsE,MAAM,KAAK,CAAA;AAEhL,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,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,6EAA6E;AAC7E,6EAA6E;AAE7E,MAAM,cAAc,GAAG,eAAe,CAAC;IACrC,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL,oDAAoD;QACpD,OAAO,EAAE,EAAE,IAAI,EAAE,MAA0D,EAAE,OAAO,EAAE,SAAS,EAAE;QACjG,iFAAiF;QACjF,IAAI,EAAE,EAAE,IAAI,EAAE,MAA+B,EAAE,OAAO,EAAE,IAAI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AE,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 { 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 */\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) => true,\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 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(selectIfAuto)\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 = 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\": props.pill ? \"\" : 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 \"onFocus\": () => {\n focused.value = true\n },\n \"onBlur\": () => {\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,MAAM,kBAAkB,CAAA;AACpC,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,6EAA6E;AAC7E,6EAA6E;AAE7E,MAAM,cAAc,GAAG,eAAe,CAAC;IACrC,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL,oDAAoD;QACpD,OAAO,EAAE,EAAE,IAAI,EAAE,MAA0D,EAAE,OAAO,EAAE,SAAS,EAAE;QACjG,iFAAiF;QACjF,IAAI,EAAE,EAAE,IAAI,EAAE,MAA+B,EAAE,OAAO,EAAE,IAAI,EAAE;QAC9D,gFAAgF;QAChF,UAAU,EAAE,MAAmE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AwB;QACxB,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) => true,\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(selectIfAuto)\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 = 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 \"onFocus\": () => {\n focused.value = true\n },\n \"onBlur\": () => {\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,6 +1,7 @@
1
1
  import { defineComponent, h, inject, nextTick, onMounted, provide, ref, watch, withDirectives, } from "vue";
2
2
  import { Button } from "../Button/index.js";
3
3
  import { vDefaultValue, vServerText } from "../../lib/defaultValue.js";
4
+ import { useFieldRowPill } from "../../lib/fieldRow.js";
4
5
  import s from "@plexui/styles/components/InputGroup/InputGroup.module.css";
5
6
  const InputGroupKey = Symbol("InputGroup");
6
7
  const CONTROL_SELECTOR = "[data-slot='input-group-control']";
@@ -31,20 +32,21 @@ const InputGroupComponent = defineComponent({
31
32
  variant: { type: String, default: "outline" },
32
33
  /** Controls the size of the group, on the same scale as Input: `3xs` 22px up to `3xl` 48px. @default "md" */
33
34
  size: { type: String, default: "md" },
34
- /** Fully rounded group, with pill buttons inside. @default false */
35
- pill: { type: Boolean, default: false },
35
+ /** Fully rounded group, with pill buttons inside. @default false, or true at the end of a `Field row` */
36
+ pill: { type: Boolean, default: undefined },
36
37
  /** Disables the control and the buttons inside the group. @default false */
37
38
  disabled: { type: Boolean, default: false },
38
39
  /** Mark the group as invalid. @default false */
39
40
  invalid: { type: Boolean, default: false },
40
41
  },
41
42
  setup(props, { attrs, slots }) {
43
+ const pill = useFieldRowPill(() => props.pill);
42
44
  provide(InputGroupKey, {
43
45
  get size() {
44
46
  return props.size;
45
47
  },
46
48
  get pill() {
47
- return props.pill;
49
+ return pill.value;
48
50
  },
49
51
  get disabled() {
50
52
  return props.disabled;
@@ -74,7 +76,7 @@ const InputGroupComponent = defineComponent({
74
76
  "data-slot": "input-group",
75
77
  "data-variant": props.variant,
76
78
  "data-size": props.size,
77
- "data-pill": props.pill ? "" : undefined,
79
+ "data-pill": pill.value ? "" : undefined,
78
80
  "data-disabled": props.disabled ? "" : undefined,
79
81
  "data-invalid": props.invalid ? "" : undefined,
80
82
  "class": [s.InputGroup, className],
@@ -1 +1 @@
1
- {"version":3,"file":"InputGroup.js","sourceRoot":"","sources":["../../../../src/components/InputGroup/InputGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,CAAC,EACD,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,GAAG,EACH,KAAK,EACL,cAAc,GAMf,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,MAAM,EAAsC,MAAM,oBAAoB,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,CAAC,MAAM,4DAA4D,CAAA;AAmB1E,MAAM,aAAa,GAAoC,MAAM,CAAC,YAAY,CAAC,CAAA;AAE3E,MAAM,gBAAgB,GAAG,mCAAmC,CAAA;AAE5D,yEAAyE;AACzE,MAAM,aAAa,GAAG,CAAC,QAAiB,EAAE,GAAU,EAAE,EAAE;IACtD,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjE,IAAI,OAAO,EAAE,KAAK,UAAU;YAAE,EAAE,CAAC,GAAG,CAAC,CAAA;IACvC,CAAC;AACH,CAAC,CAAA;AAED,uFAAuF;AACvF,MAAM,WAAW,GAAqC;IACpD,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,IAAI;IACV,IAAI,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,EAAE;QAC3C,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE;KAChD;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;QACzC,OAAO,GAAG,EAAE,CACV,CAAC,CACC,MAAM,EACN;YACE,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC;YACtC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,EAAE,IAAI;YAC/B,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,EAAE,QAAQ;YAC3C,KAAK,EAAE,CAAC,CAAC,MAAM;SAChB,EACD,KAAK,CACN,CAAA;IACL,CAAC;CACF,CAAC,CAAA;AAQF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAE/B,CAAA;AAED,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;IAC5C,IAAI,EAAE,gBAAgB;IACtB,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE;QACrB,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACjG,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n defineComponent,\n h,\n inject,\n nextTick,\n onMounted,\n provide,\n ref,\n watch,\n withDirectives,\n type HTMLAttributes,\n type InjectionKey,\n type InputHTMLAttributes,\n type PropType,\n type TextareaHTMLAttributes,\n} from \"vue\"\nimport type { ControlSize, Variants } from \"@plexui/styles/types\"\nimport { Button, type ButtonColor, type ButtonProps } from \"../Button/index.js\"\nimport { vDefaultValue, vServerText } from \"../../lib/defaultValue.js\"\nimport s from \"@plexui/styles/components/InputGroup/InputGroup.module.css\"\n\n// Vue port of packages/ui/src/components/InputGroup/InputGroup.tsx.\n// Exports are flat (`InputGroupInput` for `InputGroup.Input`, ...). The group\n// provides its size, pill, disabled and invalid state to the parts, as the\n// React context does. React spreads the remaining props after its own\n// attributes, so caller attributes win; Vue's attribute fallthrough merges\n// them the same way. `InputGroupInput` / `InputGroupTextarea` take\n// `v-model:value` and `default-value` like Input and Textarea (the textarea's\n// text content follows the value and its value is set imperatively, as in\n// Textarea).\n\ntype InputGroupContext = {\n readonly size: ControlSize\n readonly pill: boolean\n readonly disabled: boolean\n readonly invalid: boolean\n}\n\nconst InputGroupKey: InjectionKey<InputGroupContext> = Symbol(\"InputGroup\")\n\nconst CONTROL_SELECTOR = \"[data-slot='input-group-control']\"\n\n// A fallthrough listener is a function or, when merged, an array of them\nconst callListeners = (listener: unknown, evt: Event) => {\n for (const fn of Array.isArray(listener) ? listener : [listener]) {\n if (typeof fn === \"function\") fn(evt)\n }\n}\n\n/** Button size for each group size: the closest Button that fits inside the control */\nconst BUTTON_SIZE: Record<ControlSize, ControlSize> = {\n \"3xs\": \"3xs\",\n \"2xs\": \"3xs\",\n \"xs\": \"3xs\",\n \"sm\": \"3xs\",\n \"md\": \"2xs\",\n \"lg\": \"sm\",\n \"xl\": \"md\",\n \"2xl\": \"lg\",\n \"3xl\": \"xl\",\n}\n\nconst InputGroupComponent = defineComponent({\n name: \"InputGroup\",\n inheritAttrs: false,\n props: {\n /** Visual style of the group. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"outline\" | \"soft\">>, default: \"outline\" },\n /** Controls the size of the group, on the same scale as Input: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Fully rounded group, with pill buttons inside. @default false */\n pill: { type: Boolean, default: false },\n /** Disables the control and the buttons inside the group. @default false */\n disabled: { type: Boolean, default: false },\n /** Mark the group as invalid. @default false */\n invalid: { type: Boolean, default: false },\n },\n setup(props, { attrs, slots }) {\n provide(InputGroupKey, {\n get size() {\n return props.size\n },\n get pill() {\n return props.pill\n },\n get disabled() {\n return props.disabled\n },\n get invalid() {\n return props.invalid\n },\n })\n\n // Clicks on the frame, icons and text focus the control, as in Input\n const handleMouseDown = (evt: MouseEvent) => {\n callListeners(attrs.onMousedown, evt)\n const control = (evt.currentTarget as HTMLElement).querySelector<HTMLElement>(CONTROL_SELECTOR)\n const { target } = evt\n if (evt.defaultPrevented || !control || !(target instanceof Element) || control.contains(target)) {\n return\n }\n // Buttons, links, menus and other controls in the addons take their own clicks\n if (target.closest(\"button, a, input, textarea, select, [role='button'], [role='menuitem']\")) {\n return\n }\n evt.preventDefault()\n control.focus()\n }\n\n return () => {\n const { class: className, onMousedown: _onMousedown, ...restAttrs } = attrs\n return h(\n \"div\",\n {\n \"data-slot\": \"input-group\",\n \"data-variant\": props.variant,\n \"data-size\": props.size,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-invalid\": props.invalid ? \"\" : undefined,\n \"class\": [s.InputGroup, className],\n \"onMousedown\": handleMouseDown,\n ...restAttrs,\n },\n slots.default?.(),\n )\n }\n },\n})\n\ntype InputGroupOwnProps = InstanceType<typeof InputGroupComponent>[\"$props\"]\n\n/** InputGroup props plus the native <div> attributes that fall through to it, as in React. */\nexport type InputGroupProps = InputGroupOwnProps & Omit<HTMLAttributes, keyof InputGroupOwnProps>\n\n/** An input or textarea with icons, text, buttons and menus attached inside one frame. */\nexport const InputGroup = InputGroupComponent as typeof InputGroupComponent & {\n new (): { $props: InputGroupProps }\n}\n\n// `value` / `default-value` / `update:value` for the native control, as in Input\nconst controlProps = {\n /** Controlled value; use with `v-model:value` */\n value: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Initial value of an uncontrolled control */\n defaultValue: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Disables the control; defaults to the group's `disabled` */\n disabled: { type: Boolean, default: undefined },\n}\n\nconst useControl = (props: { value?: string | number }, emit: (event: \"update:value\", value: string) => void) => {\n const group = inject(InputGroupKey, null)\n const handleInput = (evt: Event) => {\n const target = evt.currentTarget as HTMLInputElement | HTMLTextAreaElement\n emit(\"update:value\", target.value)\n // Like a React controlled input, a `value` the parent does not update is put back\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 return { group, handleInput }\n}\n\nconst InputGroupInputComponent = defineComponent({\n name: \"InputGroupInput\",\n props: {\n ...controlProps,\n /** @default \"text\" */\n type: { type: String, default: \"text\" },\n },\n emits: {\n \"update:value\": (_value: string) => true,\n },\n setup(props, { emit }) {\n const { group, handleInput } = useControl(props, emit)\n return () =>\n withDirectives(\n h(\"input\", {\n \"type\": props.type,\n \"data-slot\": \"input-group-control\",\n \"class\": s.Control,\n \"disabled\": props.disabled ?? group?.disabled,\n // Expose the group's invalid state to assistive tech; an explicit aria-invalid wins\n \"aria-invalid\": group?.invalid || undefined,\n ...(props.value !== undefined ? { value: props.value } : {}),\n \"onInput\": handleInput,\n }),\n [[vDefaultValue, props.value === undefined ? props.defaultValue : undefined]],\n )\n },\n})\n\ntype InputGroupInputOwnProps = InstanceType<typeof InputGroupInputComponent>[\"$props\"]\n\n/** InputGroupInput props plus the native <input> attributes that fall through to it. */\nexport type InputGroupInputProps = InputGroupInputOwnProps &\n Omit<InputHTMLAttributes, keyof InputGroupInputOwnProps | \"size\">\n\n/** The native <input> of the group, without its own frame (React `InputGroup.Input`). */\nexport const InputGroupInput = InputGroupInputComponent as typeof InputGroupInputComponent & {\n new (): { $props: InputGroupInputProps }\n}\n\nconst InputGroupTextareaComponent = defineComponent({\n name: \"InputGroupTextarea\",\n props: {\n ...controlProps,\n /** @default 3 */\n rows: { type: [Number, String] as PropType<number | string>, default: 3 },\n },\n emits: {\n \"update:value\": (_value: string) => true,\n },\n setup(props, { emit }) {\n const group = inject(InputGroupKey, null)\n const textareaRef = ref<HTMLTextAreaElement | null>(null)\n\n // Set imperatively, like React DOM: a `value` prop would make Vue mirror\n // it into a `value` attribute, which React never renders\n const syncValue = () => {\n const textarea = textareaRef.value\n if (!textarea || props.value === undefined) return\n const value = String(props.value)\n if (textarea.value !== value) textarea.value = value\n }\n onMounted(() => {\n // React's initTextarea: the initial text becomes the (dirty) value\n const textarea = textareaRef.value\n const initialValue = textarea?.textContent ?? \"\"\n if (textarea && initialValue !== \"\") textarea.value = initialValue\n })\n watch(() => props.value, syncValue, { flush: \"post\" })\n\n const handleInput = (evt: Event) => {\n emit(\"update:value\", (evt.currentTarget as HTMLTextAreaElement).value)\n // A controlled value the parent did not update wins over the typed text\n void nextTick(syncValue)\n }\n\n return () => {\n // React keeps the textarea's text content in sync with the controlled\n // value, else with `defaultValue`\n const textContent = String(props.value ?? props.defaultValue ?? \"\")\n return withDirectives(\n h(\"textarea\", {\n \"ref\": textareaRef,\n \"rows\": props.rows,\n \"data-slot\": \"input-group-control\",\n \"class\": s.Control,\n \"disabled\": props.disabled ?? group?.disabled,\n \"aria-invalid\": group?.invalid || undefined,\n textContent,\n \"onInput\": handleInput,\n }),\n [[vServerText, textContent]],\n )\n }\n },\n})\n\ntype InputGroupTextareaOwnProps = InstanceType<typeof InputGroupTextareaComponent>[\"$props\"]\n\n/** InputGroupTextarea props plus the native <textarea> attributes that fall through to it. */\nexport type InputGroupTextareaProps = InputGroupTextareaOwnProps &\n Omit<TextareaHTMLAttributes, keyof InputGroupTextareaOwnProps>\n\n/** The native <textarea> of the group (React `InputGroup.Textarea`). */\nexport const InputGroupTextarea = InputGroupTextareaComponent as typeof InputGroupTextareaComponent & {\n new (): { $props: InputGroupTextareaProps }\n}\n\nexport type InputGroupAddonAlign = \"inline-start\" | \"inline-end\" | \"block-start\" | \"block-end\"\n\n/** Icons, text and buttons beside, above or below the control (React `InputGroup.Addon`). */\nexport const InputGroupAddon = defineComponent({\n name: \"InputGroupAddon\",\n props: {\n /**\n * Where the addon sits: before or after the control on its line, or as a\n * row above or below it.\n * @default \"inline-start\"\n */\n align: { type: String as PropType<InputGroupAddonAlign>, default: \"inline-start\" },\n },\n setup(props, { slots }) {\n return () =>\n h(\n \"div\",\n { \"data-slot\": \"input-group-addon\", \"data-align\": props.align, \"class\": s.Addon },\n slots.default?.(),\n )\n },\n})\n\nexport type InputGroupAddonProps = InstanceType<typeof InputGroupAddon>[\"$props\"] &\n Omit<HTMLAttributes, keyof InstanceType<typeof InputGroupAddon>[\"$props\"]>\n\nconst InputGroupButtonComponent = defineComponent({\n name: \"InputGroupButton\",\n props: {\n /** Color for the button. @default \"secondary\" */\n color: { type: String as PropType<ButtonColor>, default: \"secondary\" },\n /** Style variant. @default \"ghost\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\" | \"ghost\">>, default: \"ghost\" },\n pill: { type: Boolean, default: undefined },\n disabled: { type: Boolean, default: undefined },\n },\n setup(props, { slots }) {\n const group = inject(InputGroupKey, null)\n return () =>\n h(\n Button,\n {\n color: props.color,\n variant: props.variant,\n size: BUTTON_SIZE[group?.size ?? \"md\"],\n pill: props.pill ?? group?.pill,\n disabled: props.disabled ?? group?.disabled,\n class: s.Button,\n },\n slots,\n )\n },\n})\n\ntype InputGroupButtonOwnProps = InstanceType<typeof InputGroupButtonComponent>[\"$props\"]\n\n/** InputGroupButton props plus the Button props (except `size`) that fall through to it, as in React. */\nexport type InputGroupButtonProps = InputGroupButtonOwnProps &\n Omit<ButtonProps, keyof InputGroupButtonOwnProps | \"size\">\n\n/**\n * A ghost `Button` sized from the group (React `InputGroup.Button`). Takes the\n * Button props except `size`; `pill` and `disabled` default to the group's.\n */\nexport const InputGroupButton = InputGroupButtonComponent as typeof InputGroupButtonComponent & {\n new (): { $props: InputGroupButtonProps }\n}\n\n/** Text and icons inside an addon: prefixes, units, counters (React `InputGroup.Text`). */\nexport const InputGroupText = defineComponent({\n name: \"InputGroupText\",\n setup(_props, { slots }) {\n return () => h(\"span\", { \"data-slot\": \"input-group-text\", \"class\": s.Text }, slots.default?.())\n },\n})\n\nexport type InputGroupTextProps = HTMLAttributes\n"]}
1
+ {"version":3,"file":"InputGroup.js","sourceRoot":"","sources":["../../../../src/components/InputGroup/InputGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,CAAC,EACD,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,GAAG,EACH,KAAK,EACL,cAAc,GAMf,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,MAAM,EAAsC,MAAM,oBAAoB,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,CAAC,MAAM,4DAA4D,CAAA;AAmB1E,MAAM,aAAa,GAAoC,MAAM,CAAC,YAAY,CAAC,CAAA;AAE3E,MAAM,gBAAgB,GAAG,mCAAmC,CAAA;AAE5D,yEAAyE;AACzE,MAAM,aAAa,GAAG,CAAC,QAAiB,EAAE,GAAU,EAAE,EAAE;IACtD,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjE,IAAI,OAAO,EAAE,KAAK,UAAU;YAAE,EAAE,CAAC,GAAG,CAAC,CAAA;IACvC,CAAC;AACH,CAAC,CAAA;AAED,uFAAuF;AACvF,MAAM,WAAW,GAAqC;IACpD,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;CACZ,CAAA;AAED,MAAM,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,SAAS,EAAE;QAC3C,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE;KAChD;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;QACzC,OAAO,GAAG,EAAE,CACV,CAAC,CACC,MAAM,EACN;YACE,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC;YACtC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,EAAE,IAAI;YAC/B,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,EAAE,QAAQ;YAC3C,KAAK,EAAE,CAAC,CAAC,MAAM;SAChB,EACD,KAAK,CACN,CAAA;IACL,CAAC;CACF,CAAC,CAAA;AAQF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAE/B,CAAA;AAED,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;IAC5C,IAAI,EAAE,gBAAgB;IACtB,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE;QACrB,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACjG,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n defineComponent,\n h,\n inject,\n nextTick,\n onMounted,\n provide,\n ref,\n watch,\n withDirectives,\n type HTMLAttributes,\n type InjectionKey,\n type InputHTMLAttributes,\n type PropType,\n type TextareaHTMLAttributes,\n} from \"vue\"\nimport type { ControlSize, Variants } from \"@plexui/styles/types\"\nimport { Button, type ButtonColor, type ButtonProps } from \"../Button/index.js\"\nimport { vDefaultValue, vServerText } from \"../../lib/defaultValue.js\"\nimport { useFieldRowPill } from \"../../lib/fieldRow.js\"\nimport s from \"@plexui/styles/components/InputGroup/InputGroup.module.css\"\n\n// Vue port of packages/ui/src/components/InputGroup/InputGroup.tsx.\n// Exports are flat (`InputGroupInput` for `InputGroup.Input`, ...). The group\n// provides its size, pill, disabled and invalid state to the parts, as the\n// React context does. React spreads the remaining props after its own\n// attributes, so caller attributes win; Vue's attribute fallthrough merges\n// them the same way. `InputGroupInput` / `InputGroupTextarea` take\n// `v-model:value` and `default-value` like Input and Textarea (the textarea's\n// text content follows the value and its value is set imperatively, as in\n// Textarea).\n\ntype InputGroupContext = {\n readonly size: ControlSize\n readonly pill: boolean\n readonly disabled: boolean\n readonly invalid: boolean\n}\n\nconst InputGroupKey: InjectionKey<InputGroupContext> = Symbol(\"InputGroup\")\n\nconst CONTROL_SELECTOR = \"[data-slot='input-group-control']\"\n\n// A fallthrough listener is a function or, when merged, an array of them\nconst callListeners = (listener: unknown, evt: Event) => {\n for (const fn of Array.isArray(listener) ? listener : [listener]) {\n if (typeof fn === \"function\") fn(evt)\n }\n}\n\n/** Button size for each group size: the closest Button that fits inside the control */\nconst BUTTON_SIZE: Record<ControlSize, ControlSize> = {\n \"3xs\": \"3xs\",\n \"2xs\": \"3xs\",\n \"xs\": \"3xs\",\n \"sm\": \"3xs\",\n \"md\": \"2xs\",\n \"lg\": \"sm\",\n \"xl\": \"md\",\n \"2xl\": \"lg\",\n \"3xl\": \"xl\",\n}\n\nconst InputGroupComponent = defineComponent({\n name: \"InputGroup\",\n inheritAttrs: false,\n props: {\n /** Visual style of the group. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"outline\" | \"soft\">>, default: \"outline\" },\n /** Controls the size of the group, on the same scale as Input: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Fully rounded group, with pill buttons inside. @default false, or true at the end of a `Field row` */\n pill: { type: Boolean, default: undefined },\n /** Disables the control and the buttons inside the group. @default false */\n disabled: { type: Boolean, default: false },\n /** Mark the group as invalid. @default false */\n invalid: { type: Boolean, default: false },\n },\n setup(props, { attrs, slots }) {\n const pill = useFieldRowPill(() => props.pill)\n\n provide(InputGroupKey, {\n get size() {\n return props.size\n },\n get pill() {\n return pill.value\n },\n get disabled() {\n return props.disabled\n },\n get invalid() {\n return props.invalid\n },\n })\n\n // Clicks on the frame, icons and text focus the control, as in Input\n const handleMouseDown = (evt: MouseEvent) => {\n callListeners(attrs.onMousedown, evt)\n const control = (evt.currentTarget as HTMLElement).querySelector<HTMLElement>(CONTROL_SELECTOR)\n const { target } = evt\n if (evt.defaultPrevented || !control || !(target instanceof Element) || control.contains(target)) {\n return\n }\n // Buttons, links, menus and other controls in the addons take their own clicks\n if (target.closest(\"button, a, input, textarea, select, [role='button'], [role='menuitem']\")) {\n return\n }\n evt.preventDefault()\n control.focus()\n }\n\n return () => {\n const { class: className, onMousedown: _onMousedown, ...restAttrs } = attrs\n return h(\n \"div\",\n {\n \"data-slot\": \"input-group\",\n \"data-variant\": props.variant,\n \"data-size\": props.size,\n \"data-pill\": pill.value ? \"\" : undefined,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-invalid\": props.invalid ? \"\" : undefined,\n \"class\": [s.InputGroup, className],\n \"onMousedown\": handleMouseDown,\n ...restAttrs,\n },\n slots.default?.(),\n )\n }\n },\n})\n\ntype InputGroupOwnProps = InstanceType<typeof InputGroupComponent>[\"$props\"]\n\n/** InputGroup props plus the native <div> attributes that fall through to it, as in React. */\nexport type InputGroupProps = InputGroupOwnProps & Omit<HTMLAttributes, keyof InputGroupOwnProps>\n\n/** An input or textarea with icons, text, buttons and menus attached inside one frame. */\nexport const InputGroup = InputGroupComponent as typeof InputGroupComponent & {\n new (): { $props: InputGroupProps }\n}\n\n// `value` / `default-value` / `update:value` for the native control, as in Input\nconst controlProps = {\n /** Controlled value; use with `v-model:value` */\n value: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Initial value of an uncontrolled control */\n defaultValue: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Disables the control; defaults to the group's `disabled` */\n disabled: { type: Boolean, default: undefined },\n}\n\nconst useControl = (props: { value?: string | number }, emit: (event: \"update:value\", value: string) => void) => {\n const group = inject(InputGroupKey, null)\n const handleInput = (evt: Event) => {\n const target = evt.currentTarget as HTMLInputElement | HTMLTextAreaElement\n emit(\"update:value\", target.value)\n // Like a React controlled input, a `value` the parent does not update is put back\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 return { group, handleInput }\n}\n\nconst InputGroupInputComponent = defineComponent({\n name: \"InputGroupInput\",\n props: {\n ...controlProps,\n /** @default \"text\" */\n type: { type: String, default: \"text\" },\n },\n emits: {\n \"update:value\": (_value: string) => true,\n },\n setup(props, { emit }) {\n const { group, handleInput } = useControl(props, emit)\n return () =>\n withDirectives(\n h(\"input\", {\n \"type\": props.type,\n \"data-slot\": \"input-group-control\",\n \"class\": s.Control,\n \"disabled\": props.disabled ?? group?.disabled,\n // Expose the group's invalid state to assistive tech; an explicit aria-invalid wins\n \"aria-invalid\": group?.invalid || undefined,\n ...(props.value !== undefined ? { value: props.value } : {}),\n \"onInput\": handleInput,\n }),\n [[vDefaultValue, props.value === undefined ? props.defaultValue : undefined]],\n )\n },\n})\n\ntype InputGroupInputOwnProps = InstanceType<typeof InputGroupInputComponent>[\"$props\"]\n\n/** InputGroupInput props plus the native <input> attributes that fall through to it. */\nexport type InputGroupInputProps = InputGroupInputOwnProps &\n Omit<InputHTMLAttributes, keyof InputGroupInputOwnProps | \"size\">\n\n/** The native <input> of the group, without its own frame (React `InputGroup.Input`). */\nexport const InputGroupInput = InputGroupInputComponent as typeof InputGroupInputComponent & {\n new (): { $props: InputGroupInputProps }\n}\n\nconst InputGroupTextareaComponent = defineComponent({\n name: \"InputGroupTextarea\",\n props: {\n ...controlProps,\n /** @default 3 */\n rows: { type: [Number, String] as PropType<number | string>, default: 3 },\n },\n emits: {\n \"update:value\": (_value: string) => true,\n },\n setup(props, { emit }) {\n const group = inject(InputGroupKey, null)\n const textareaRef = ref<HTMLTextAreaElement | null>(null)\n\n // Set imperatively, like React DOM: a `value` prop would make Vue mirror\n // it into a `value` attribute, which React never renders\n const syncValue = () => {\n const textarea = textareaRef.value\n if (!textarea || props.value === undefined) return\n const value = String(props.value)\n if (textarea.value !== value) textarea.value = value\n }\n onMounted(() => {\n // React's initTextarea: the initial text becomes the (dirty) value\n const textarea = textareaRef.value\n const initialValue = textarea?.textContent ?? \"\"\n if (textarea && initialValue !== \"\") textarea.value = initialValue\n })\n watch(() => props.value, syncValue, { flush: \"post\" })\n\n const handleInput = (evt: Event) => {\n emit(\"update:value\", (evt.currentTarget as HTMLTextAreaElement).value)\n // A controlled value the parent did not update wins over the typed text\n void nextTick(syncValue)\n }\n\n return () => {\n // React keeps the textarea's text content in sync with the controlled\n // value, else with `defaultValue`\n const textContent = String(props.value ?? props.defaultValue ?? \"\")\n return withDirectives(\n h(\"textarea\", {\n \"ref\": textareaRef,\n \"rows\": props.rows,\n \"data-slot\": \"input-group-control\",\n \"class\": s.Control,\n \"disabled\": props.disabled ?? group?.disabled,\n \"aria-invalid\": group?.invalid || undefined,\n textContent,\n \"onInput\": handleInput,\n }),\n [[vServerText, textContent]],\n )\n }\n },\n})\n\ntype InputGroupTextareaOwnProps = InstanceType<typeof InputGroupTextareaComponent>[\"$props\"]\n\n/** InputGroupTextarea props plus the native <textarea> attributes that fall through to it. */\nexport type InputGroupTextareaProps = InputGroupTextareaOwnProps &\n Omit<TextareaHTMLAttributes, keyof InputGroupTextareaOwnProps>\n\n/** The native <textarea> of the group (React `InputGroup.Textarea`). */\nexport const InputGroupTextarea = InputGroupTextareaComponent as typeof InputGroupTextareaComponent & {\n new (): { $props: InputGroupTextareaProps }\n}\n\nexport type InputGroupAddonAlign = \"inline-start\" | \"inline-end\" | \"block-start\" | \"block-end\"\n\n/** Icons, text and buttons beside, above or below the control (React `InputGroup.Addon`). */\nexport const InputGroupAddon = defineComponent({\n name: \"InputGroupAddon\",\n props: {\n /**\n * Where the addon sits: before or after the control on its line, or as a\n * row above or below it.\n * @default \"inline-start\"\n */\n align: { type: String as PropType<InputGroupAddonAlign>, default: \"inline-start\" },\n },\n setup(props, { slots }) {\n return () =>\n h(\n \"div\",\n { \"data-slot\": \"input-group-addon\", \"data-align\": props.align, \"class\": s.Addon },\n slots.default?.(),\n )\n },\n})\n\nexport type InputGroupAddonProps = InstanceType<typeof InputGroupAddon>[\"$props\"] &\n Omit<HTMLAttributes, keyof InstanceType<typeof InputGroupAddon>[\"$props\"]>\n\nconst InputGroupButtonComponent = defineComponent({\n name: \"InputGroupButton\",\n props: {\n /** Color for the button. @default \"secondary\" */\n color: { type: String as PropType<ButtonColor>, default: \"secondary\" },\n /** Style variant. @default \"ghost\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\" | \"ghost\">>, default: \"ghost\" },\n pill: { type: Boolean, default: undefined },\n disabled: { type: Boolean, default: undefined },\n },\n setup(props, { slots }) {\n const group = inject(InputGroupKey, null)\n return () =>\n h(\n Button,\n {\n color: props.color,\n variant: props.variant,\n size: BUTTON_SIZE[group?.size ?? \"md\"],\n pill: props.pill ?? group?.pill,\n disabled: props.disabled ?? group?.disabled,\n class: s.Button,\n },\n slots,\n )\n },\n})\n\ntype InputGroupButtonOwnProps = InstanceType<typeof InputGroupButtonComponent>[\"$props\"]\n\n/** InputGroupButton props plus the Button props (except `size`) that fall through to it, as in React. */\nexport type InputGroupButtonProps = InputGroupButtonOwnProps &\n Omit<ButtonProps, keyof InputGroupButtonOwnProps | \"size\">\n\n/**\n * A ghost `Button` sized from the group (React `InputGroup.Button`). Takes the\n * Button props except `size`; `pill` and `disabled` default to the group's.\n */\nexport const InputGroupButton = InputGroupButtonComponent as typeof InputGroupButtonComponent & {\n new (): { $props: InputGroupButtonProps }\n}\n\n/** Text and icons inside an addon: prefixes, units, counters (React `InputGroup.Text`). */\nexport const InputGroupText = defineComponent({\n name: \"InputGroupText\",\n setup(_props, { slots }) {\n return () => h(\"span\", { \"data-slot\": \"input-group-text\", \"class\": s.Text }, slots.default?.())\n },\n})\n\nexport type InputGroupTextProps = HTMLAttributes\n"]}
@@ -2,6 +2,7 @@ import clsx from "clsx";
2
2
  import { cloneVNode, computed, createCommentVNode, defineComponent, h, inject, markRaw, nextTick, onBeforeUnmount, onBeforeUpdate, onMounted, provide, ref, shallowRef, toRaw, useId, watch, } from "vue";
3
3
  import { PopoverAnchor as RekaPopoverAnchor, PopoverContent as RekaPopoverContent, PopoverPortal as RekaPopoverPortal, PopoverRoot as RekaPopoverRoot, injectPopoverRootContext, useId as useRekaId, } from "reka-ui";
4
4
  import { useEscCloseStack } from "../../composables/useEscCloseStack.js";
5
+ import { useFieldRowPill } from "../../lib/fieldRow.js";
5
6
  import { preventDefaultHandler, pressHandlers, toCssVariables, waitForAnimationFrame } from "../../lib/helpers.js";
6
7
  import { Check, Info, Search } from "../Icon/index.js";
7
8
  import { Input } from "../Input/index.js";
@@ -39,8 +40,8 @@ const selectProps = {
39
40
  loading: { type: Boolean, default: false },
40
41
  /** Style variant for the select trigger. @default "outline" */
41
42
  variant: { type: String, default: "outline" },
42
- /** Fully rounded pill shape for the trigger. @default false */
43
- pill: { type: Boolean, default: false },
43
+ /** Fully rounded pill shape for the trigger. @default false, or true at the end of a `Field row` */
44
+ pill: { type: Boolean, default: undefined },
44
45
  /** Size of the trigger: `3xs` 22px up to `3xl` 48px. @default "md" */
45
46
  size: { type: String, default: "md" },
46
47
  /** Icon displayed in the far right of the select trigger. @default "dropdown" */
@@ -143,6 +144,7 @@ const SelectComponent = defineComponent({
143
144
  emits: ["update:value", "change"],
144
145
  setup(rawProps, { emit, slots }) {
145
146
  const props = rawProps;
147
+ const pill = useFieldRowPill(() => props.pill);
146
148
  // Block default is dynamic, based on `variant`
147
149
  const block = computed(() => props.block ?? props.variant !== "ghost");
148
150
  // Align default is dynamic, based on `block`
@@ -210,6 +212,7 @@ const SelectComponent = defineComponent({
210
212
  triggerId: `select-trigger-${useId()}`,
211
213
  triggerEl: shallowRef(null),
212
214
  block,
215
+ pill,
213
216
  align,
214
217
  alignOffset,
215
218
  listWidth,
@@ -233,7 +236,7 @@ const SelectTrigger = defineComponent({
233
236
  onOpenChange: Function,
234
237
  },
235
238
  setup(ownProps, { attrs }) {
236
- const { props, slots, slotsVersion, triggerId, triggerEl, block, onSelect } = useSelectContext();
239
+ const { props, slots, slotsVersion, triggerId, triggerEl, block, pill, onSelect } = useSelectContext();
237
240
  const typeahead = createTypeahead();
238
241
  const setTriggerEl = (instance) => {
239
242
  triggerEl.value = instance?.$el ?? null;
@@ -300,7 +303,7 @@ const SelectTrigger = defineComponent({
300
303
  "class": props.triggerClassName,
301
304
  "selected": !isPlaceholder,
302
305
  "variant": props.variant,
303
- "pill": props.pill,
306
+ "pill": pill.value,
304
307
  "block": block.value,
305
308
  "size": props.size,
306
309
  "disabled": props.disabled,
@@ -522,7 +525,7 @@ const SelectContentElement = markRaw(defineComponent({
522
525
  const SelectPopoverContent = defineComponent({
523
526
  name: "SelectPopoverContent",
524
527
  setup() {
525
- const { props, align, alignOffset, listWidth, listMaxWidth } = useSelectContext();
528
+ const { props, align, alignOffset, listWidth, listMaxWidth, pill } = useSelectContext();
526
529
  const { handleRootOpenChange, popoverTriggerEl } = inject(CustomSelectContextKey);
527
530
  // Radix (1.8.1) dismisses on the click that follows a primary pointer down outside
528
531
  const { onPointerDownOutside, onFocusOutside } = useDeferredPointerDownOutside((originalEvent) => {
@@ -535,7 +538,7 @@ const SelectPopoverContent = defineComponent({
535
538
  forceMount: true,
536
539
  as: SelectContentElement,
537
540
  class: s.MenuList,
538
- "data-pill": props.pill ? "" : undefined,
541
+ "data-pill": pill.value ? "" : undefined,
539
542
  side: props.side,
540
543
  sideOffset: 5,
541
544
  align: align.value,