@planningcenter/tapestry 4.15.0 → 4.15.1-qa-1684.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.
Files changed (34) hide show
  1. package/dist/components/link/BaseLink.d.ts.map +1 -1
  2. package/dist/components/link/BaseLink.js +5 -1
  3. package/dist/components/link/BaseLink.js.map +1 -1
  4. package/dist/components/tag/Tag.d.ts +59 -0
  5. package/dist/components/tag/Tag.d.ts.map +1 -0
  6. package/dist/components/tag/Tag.js +31 -0
  7. package/dist/components/tag/Tag.js.map +1 -0
  8. package/dist/components/tag/TagContent.d.ts +19 -0
  9. package/dist/components/tag/TagContent.d.ts.map +1 -0
  10. package/dist/components/tag/TagContent.js +26 -0
  11. package/dist/components/tag/TagContent.js.map +1 -0
  12. package/dist/components/tag/index.d.ts +4 -0
  13. package/dist/components/tag/index.d.ts.map +1 -0
  14. package/dist/components/tag/useTagMenu.d.ts +31 -0
  15. package/dist/components/tag/useTagMenu.d.ts.map +1 -0
  16. package/dist/components/tag/useTagMenu.js +56 -0
  17. package/dist/components/tag/useTagMenu.js.map +1 -0
  18. package/dist/reactRender.css +400 -200
  19. package/dist/reactRender.css.map +1 -1
  20. package/dist/reactRenderLegacy.css +400 -200
  21. package/dist/reactRenderLegacy.css.map +1 -1
  22. package/dist/tapestryMount.css +400 -200
  23. package/dist/tapestryMount.css.map +1 -1
  24. package/dist/tapestryMountLegacy.css +400 -200
  25. package/dist/tapestryMountLegacy.css.map +1 -1
  26. package/dist/unstable.css +200 -0
  27. package/dist/unstable.css.map +1 -1
  28. package/dist/unstable.d.ts +2 -0
  29. package/dist/unstable.d.ts.map +1 -1
  30. package/dist/unstable.js +1 -0
  31. package/dist/unstable.js.map +1 -1
  32. package/docs/components/tag.md +41 -0
  33. package/docs/llms.txt +3 -0
  34. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"BaseLink.d.ts","sourceRoot":"","sources":["../../../src/components/link/BaseLink.tsx"],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C,MAAM,kBAAkB,GAAG,UAAU,GAAG,MAAM,CAC/C,GAAG;IACF,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACxB,CAAA;AAEH,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,CACN,iBAAiB,GAAG;IAClB;;;;;OAKG;IACH,OAAO,EAAE,IAAI,CAAA;IACb,IAAI,CAAC,EAAE,KAAK,CAAA;CACb,CACF,GACD,QAAQ,CAAC,iBAAiB,GAAG;IAAE,OAAO,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEnE,eAAO,MAAM,QAAQ,gGA4DpB,CAAA"}
@@ -6,6 +6,10 @@ import React__default, { forwardRef } from 'react';
6
6
 
7
7
  const BaseLink = forwardRef(({ asChild = false, "aria-describedby": ariaDescribedBy, children, className, external = false, fullWidth, href, kind, label, prefix, size, suffix, ...restProps }, ref) => {
8
8
  const { describedBy, mergedProps, mergedRef } = useTooltipTriggerProps(restProps, ref, ariaDescribedBy);
9
+ const content = label || children;
10
+ const hasContent = Boolean(content) || content === 0;
11
+ if (!hasContent)
12
+ return null;
9
13
  const combinedClassName = classNames(kind && "tds-btn", size && size !== "md" && kind && COMPONENT_SIZE_CLASS_MAP[size], kind && COMPONENT_KIND_CLASS_MAP[kind], fullWidth && "tds-btn--full-width", className, { "tds-btn--prefix": prefix, "tds-btn--suffix": suffix });
10
14
  const externalProps = external
11
15
  ? { rel: "noopener noreferrer", target: "_blank" }
@@ -13,7 +17,7 @@ const BaseLink = forwardRef(({ asChild = false, "aria-describedby": ariaDescribe
13
17
  const Comp = asChild ? Slot : "a";
14
18
  return (React__default.createElement(Comp, { ...(!asChild && { href }), className: combinedClassName, ref: mergedRef, ...mergedProps, "aria-describedby": describedBy, ...externalProps },
15
19
  wrapStringWithSpan(prefix),
16
- React__default.createElement(Slottable, null, label || children),
20
+ React__default.createElement(Slottable, null, content),
17
21
  wrapStringWithSpan(suffix)));
18
22
  });
19
23
  BaseLink.displayName = "BaseLink";
@@ -1 +1 @@
1
- {"version":3,"file":"BaseLink.js","sources":["../../../src/components/link/BaseLink.tsx"],"sourcesContent":["import \"../button/btn.css\"\n\nimport { useTooltipTriggerProps } from \"@components/internal/tooltip/useTooltipTriggerProps\"\nimport { Slot, Slottable } from \"@radix-ui/react-slot\"\nimport {\n BaseComponentProps,\n COMPONENT_KIND_CLASS_MAP,\n COMPONENT_SIZE_CLASS_MAP,\n ComponentKind,\n wrapStringWithSpan,\n} from \"@utilities/buttonLinkShared\"\nimport { Simplify } from \"@utilities/typeUtils\"\nimport classNames from \"classnames\"\nimport React, { AnchorHTMLAttributes, forwardRef } from \"react\"\n\ntype BaseLinkBaseProps = BaseComponentProps &\n Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof BaseComponentProps | \"children\" | \"href\"\n > & {\n children?: React.ReactNode\n external?: boolean\n kind?: ComponentKind\n label?: React.ReactNode\n }\n\nexport type BaseLinkElementProps =\n | Simplify<\n BaseLinkBaseProps & {\n /**\n * When true, merges the link's styling onto the child element instead\n * of rendering an `<a>`. Use to wrap a router link (e.g. react-router,\n * Next.js) or any link-like component. The `external` prop still\n * applies — it spreads `rel`/`target` onto the child element.\n */\n asChild: true\n href?: never\n }\n >\n | Simplify<BaseLinkBaseProps & { asChild?: false; href: string }>\n\nexport const BaseLink = forwardRef<HTMLAnchorElement, BaseLinkElementProps>(\n (\n {\n asChild = false,\n \"aria-describedby\": ariaDescribedBy,\n children,\n className,\n external = false,\n fullWidth,\n href,\n kind,\n label,\n prefix,\n size,\n suffix,\n ...restProps\n }: BaseLinkElementProps,\n ref\n ) => {\n const { describedBy, mergedProps, mergedRef } = useTooltipTriggerProps(\n restProps,\n ref,\n ariaDescribedBy\n )\n\n const combinedClassName = classNames(\n kind && \"tds-btn\",\n size && size !== \"md\" && kind && COMPONENT_SIZE_CLASS_MAP[size],\n kind && COMPONENT_KIND_CLASS_MAP[kind],\n fullWidth && \"tds-btn--full-width\",\n className,\n { \"tds-btn--prefix\": prefix, \"tds-btn--suffix\": suffix }\n )\n\n const externalProps = external\n ? { rel: \"noopener noreferrer\", target: \"_blank\" }\n : {}\n\n const Comp = asChild ? Slot : \"a\"\n\n return (\n <Comp\n {...(!asChild && { href })}\n className={combinedClassName}\n ref={mergedRef}\n {...mergedProps}\n aria-describedby={describedBy}\n {...externalProps}\n >\n {wrapStringWithSpan(prefix)}\n <Slottable>{label || children}</Slottable>\n {wrapStringWithSpan(suffix)}\n </Comp>\n )\n }\n)\n\nBaseLink.displayName = \"BaseLink\"\n"],"names":["React"],"mappings":";;;;;;MAyCa,QAAQ,GAAG,UAAU,CAChC,CACE,EACE,OAAO,GAAG,KAAK,EACf,kBAAkB,EAAE,eAAe,EACnC,QAAQ,EACR,SAAS,EACT,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,GAAG,SAAS,EACS,EACvB,GAAG,KACD;AACF,IAAA,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,sBAAsB,CACpE,SAAS,EACT,GAAG,EACH,eAAe,CAChB;IAED,MAAM,iBAAiB,GAAG,UAAU,CAClC,IAAI,IAAI,SAAS,EACjB,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,wBAAwB,CAAC,IAAI,CAAC,EAC/D,IAAI,IAAI,wBAAwB,CAAC,IAAI,CAAC,EACtC,SAAS,IAAI,qBAAqB,EAClC,SAAS,EACT,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,CACzD;IAED,MAAM,aAAa,GAAG;UAClB,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ;UAC9C,EAAE;IAEN,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,GAAG;IAEjC,QACEA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAA,IACE,CAAC,OAAO,IAAI,EAAE,IAAI,EAAE,CAAC,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,SAAS,EAAA,GACV,WAAW,EAAA,kBAAA,EACG,WAAW,EAAA,GACzB,aAAa,EAAA;QAEhB,kBAAkB,CAAC,MAAM,CAAC;AAC3B,QAAAA,cAAA,CAAA,aAAA,CAAC,SAAS,EAAA,IAAA,EAAE,KAAK,IAAI,QAAQ,CAAa;AACzC,QAAA,kBAAkB,CAAC,MAAM,CAAC,CACtB;AAEX,CAAC;AAGH,QAAQ,CAAC,WAAW,GAAG,UAAU;;;;"}
1
+ {"version":3,"file":"BaseLink.js","sources":["../../../src/components/link/BaseLink.tsx"],"sourcesContent":["import \"../button/btn.css\"\n\nimport { useTooltipTriggerProps } from \"@components/internal/tooltip/useTooltipTriggerProps\"\nimport { Slot, Slottable } from \"@radix-ui/react-slot\"\nimport {\n BaseComponentProps,\n COMPONENT_KIND_CLASS_MAP,\n COMPONENT_SIZE_CLASS_MAP,\n ComponentKind,\n wrapStringWithSpan,\n} from \"@utilities/buttonLinkShared\"\nimport { Simplify } from \"@utilities/typeUtils\"\nimport classNames from \"classnames\"\nimport React, { AnchorHTMLAttributes, forwardRef } from \"react\"\n\ntype BaseLinkBaseProps = BaseComponentProps &\n Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof BaseComponentProps | \"children\" | \"href\"\n > & {\n children?: React.ReactNode\n external?: boolean\n kind?: ComponentKind\n label?: React.ReactNode\n }\n\nexport type BaseLinkElementProps =\n | Simplify<\n BaseLinkBaseProps & {\n /**\n * When true, merges the link's styling onto the child element instead\n * of rendering an `<a>`. Use to wrap a router link (e.g. react-router,\n * Next.js) or any link-like component. The `external` prop still\n * applies — it spreads `rel`/`target` onto the child element.\n */\n asChild: true\n href?: never\n }\n >\n | Simplify<BaseLinkBaseProps & { asChild?: false; href: string }>\n\nexport const BaseLink = forwardRef<HTMLAnchorElement, BaseLinkElementProps>(\n (\n {\n asChild = false,\n \"aria-describedby\": ariaDescribedBy,\n children,\n className,\n external = false,\n fullWidth,\n href,\n kind,\n label,\n prefix,\n size,\n suffix,\n ...restProps\n }: BaseLinkElementProps,\n ref\n ) => {\n const { describedBy, mergedProps, mergedRef } = useTooltipTriggerProps(\n restProps,\n ref,\n ariaDescribedBy\n )\n\n const content = label || children\n const hasContent = Boolean(content) || content === 0\n\n if (!hasContent) return null\n\n const combinedClassName = classNames(\n kind && \"tds-btn\",\n size && size !== \"md\" && kind && COMPONENT_SIZE_CLASS_MAP[size],\n kind && COMPONENT_KIND_CLASS_MAP[kind],\n fullWidth && \"tds-btn--full-width\",\n className,\n { \"tds-btn--prefix\": prefix, \"tds-btn--suffix\": suffix }\n )\n\n const externalProps = external\n ? { rel: \"noopener noreferrer\", target: \"_blank\" }\n : {}\n\n const Comp = asChild ? Slot : \"a\"\n\n return (\n <Comp\n {...(!asChild && { href })}\n className={combinedClassName}\n ref={mergedRef}\n {...mergedProps}\n aria-describedby={describedBy}\n {...externalProps}\n >\n {wrapStringWithSpan(prefix)}\n <Slottable>{content}</Slottable>\n {wrapStringWithSpan(suffix)}\n </Comp>\n )\n }\n)\n\nBaseLink.displayName = \"BaseLink\"\n"],"names":["React"],"mappings":";;;;;;MAyCa,QAAQ,GAAG,UAAU,CAChC,CACE,EACE,OAAO,GAAG,KAAK,EACf,kBAAkB,EAAE,eAAe,EACnC,QAAQ,EACR,SAAS,EACT,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,GAAG,SAAS,EACS,EACvB,GAAG,KACD;AACF,IAAA,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,sBAAsB,CACpE,SAAS,EACT,GAAG,EACH,eAAe,CAChB;AAED,IAAA,MAAM,OAAO,GAAG,KAAK,IAAI,QAAQ;IACjC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,KAAK,CAAC;AAEpD,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,IAAI;IAE5B,MAAM,iBAAiB,GAAG,UAAU,CAClC,IAAI,IAAI,SAAS,EACjB,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,wBAAwB,CAAC,IAAI,CAAC,EAC/D,IAAI,IAAI,wBAAwB,CAAC,IAAI,CAAC,EACtC,SAAS,IAAI,qBAAqB,EAClC,SAAS,EACT,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,CACzD;IAED,MAAM,aAAa,GAAG;UAClB,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ;UAC9C,EAAE;IAEN,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,GAAG;IAEjC,QACEA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAA,IACE,CAAC,OAAO,IAAI,EAAE,IAAI,EAAE,CAAC,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,SAAS,EAAA,GACV,WAAW,EAAA,kBAAA,EACG,WAAW,EAAA,GACzB,aAAa,EAAA;QAEhB,kBAAkB,CAAC,MAAM,CAAC;QAC3BA,cAAA,CAAA,aAAA,CAAC,SAAS,EAAA,IAAA,EAAE,OAAO,CAAa;AAC/B,QAAA,kBAAkB,CAAC,MAAM,CAAC,CACtB;AAEX,CAAC;AAGH,QAAQ,CAAC,WAAW,GAAG,UAAU;;;;"}
@@ -0,0 +1,59 @@
1
+ import React, { type HTMLAttributes, type ReactNode } from "react";
2
+ import { type TagOption } from "./useTagMenu";
3
+ export type { TagOption } from "./useTagMenu";
4
+ export type TagColor = "aqua" | "blue" | "green" | "indigo" | "magenta" | "neutral" | "orange" | "pink" | "purple" | "teal" | "yellow";
5
+ export type TagVariant = "bold" | "subtle";
6
+ interface TagBaseProps {
7
+ className?: string;
8
+ /** The hue. Defaults to `neutral`. */
9
+ color?: TagColor;
10
+ /** Text before the name, on a darker fill. */
11
+ label?: string;
12
+ /**
13
+ * The text of the tag. With `options`, the name of the current option.
14
+ */
15
+ name: string;
16
+ /** Defaults to `subtle`. */
17
+ variant?: TagVariant;
18
+ }
19
+ interface TagIconProps {
20
+ /** Leading icon. Cannot be used with `onDismiss` or `options`. */
21
+ icon?: ReactNode;
22
+ onChange?: never;
23
+ onDismiss?: never;
24
+ options?: never;
25
+ }
26
+ interface TagDismissProps {
27
+ icon?: never;
28
+ onChange?: never;
29
+ /** Shows the ✕ when set. Called when the ✕ is pressed. */
30
+ onDismiss?: () => void;
31
+ options?: never;
32
+ }
33
+ interface TagMenuProps {
34
+ icon?: never;
35
+ /** Called with the picked option. */
36
+ onChange: (option: TagOption) => void;
37
+ onDismiss?: () => void;
38
+ /**
39
+ * The values the tag can change to. Shows a menu button after the name.
40
+ * The menu marks the option whose `name` matches.
41
+ */
42
+ options: TagOption[];
43
+ }
44
+ /**
45
+ * A tag has a leading icon, or its ✕ and menu buttons, not both, so the
46
+ * icons do not compete.
47
+ */
48
+ export type TagProps = TagBaseProps & (TagDismissProps | TagIconProps | TagMenuProps);
49
+ /** `TagProps`, plus any other attribute of the root `div`, such as `id`. */
50
+ export type TagElementProps = Omit<HTMLAttributes<HTMLDivElement>, keyof TagProps | "children"> & TagProps;
51
+ /**
52
+ * A small, colored label for a value, such as a status or a category. A tag
53
+ * can show a label before its name, a ✕ to remove it, and a menu that
54
+ * changes its value.
55
+ *
56
+ * @component
57
+ */
58
+ export declare function Tag({ className, color, icon, label, name, onChange, onDismiss, options, variant, ...restProps }: TagElementProps): React.JSX.Element;
59
+ //# sourceMappingURL=Tag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tag.d.ts","sourceR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,MAAM,IAAI,CAAA;IACtB;;;OAGG;IACH,OAAO,EAAE,SAAS,EAAE,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,GACjC,CAAC,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC,CAAA;AAEjD,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,cAAc,CAAC,cAAc,CAAC,EAC9B,MAAM,QAAQ,GAAG,UAAU,CAC5B,GACC,QAAQ,CAAA;AAEV;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,EAClB,SAAS,EACT,KAAiB,EACjB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAkB,EAClB,GAAG,SAAS,EACb,EAAE,eAAe,qBA0CjB"}
@@ -0,0 +1,31 @@
1
+ import Icon from '../../utilities/Icon.js';
2
+ import classNames from 'classnames';
3
+ import React__default from 'react';
4
+ import { TagContent, tagText } from './TagContent.js';
5
+ import { useTagMenu } from './useTagMenu.js';
6
+
7
+ /**
8
+ * A small, colored label for a value, such as a status or a category. A tag
9
+ * can show a label before its name, a ✕ to remove it, and a menu that
10
+ * changes its value.
11
+ *
12
+ * @component
13
+ */
14
+ function Tag({ className, color = "neutral", icon, label, name, onChange, onDismiss, options, variant = "subtle", ...restProps }) {
15
+ const text = tagText(label, name);
16
+ const hasMenu = !!options?.length;
17
+ const menu = useTagMenu({
18
+ buttonLabel: `Change ${text}`,
19
+ menuLabel: label ?? name,
20
+ onChange: (option) => onChange?.(option),
21
+ options: options ?? [],
22
+ selectedName: name,
23
+ });
24
+ return (React__default.createElement("div", { ...restProps, className: classNames("tds-tag", `tds-tag--${color}`, `tds-tag--${variant}`, className) },
25
+ React__default.createElement(TagContent, { dismissButton: onDismiss && (React__default.createElement("button", { "aria-label": `Remove ${text}`, className: "tds-tag-dismiss", onClick: onDismiss, type: "button" },
26
+ React__default.createElement(Icon, { "aria-hidden": true, symbol: "general#x" }))), icon: icon, label: label, menuButton: hasMenu && menu.button, name: name }),
27
+ hasMenu && menu.popover));
28
+ }
29
+
30
+ export { Tag };
31
+ //# sourceMappingURL=Tag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tag.js","sources":["../../../src/components/tag/Tag.tsx"],"sourcesContent":["import Icon from \"@utilities/Icon\"\nimport classNames from \"classnames\"\nimport React, { type HTMLAttributes, type ReactNode } from \"react\"\n\nimport { TagContent, tagText } from \"./TagContent\"\nimport { type TagOption, useTagMenu } from \"./useTagMenu\"\n\nexport type { TagOption } from \"./useTagMenu\"\n\nexport type TagColor =\n | \"aqua\"\n | \"blue\"\n | \"green\"\n | \"indigo\"\n | \"magenta\"\n | \"neutral\"\n | \"orange\"\n | \"pink\"\n | \"purple\"\n | \"teal\"\n | \"yellow\"\n\nexport type TagVariant = \"bold\" | \"subtle\"\n\ninterface TagBaseProps {\n className?: string\n /** The hue. Defaults to `neutral`. */\n color?: TagColor\n /** Text before the name, on a darker fill. */\n label?: string\n /**\n * The text of the tag. With `options`, the name of the current option.\n */\n name: string\n /** Defaults to `subtle`. */\n variant?: TagVariant\n}\n\ninterface TagIconProps {\n /** Leading icon. Cannot be used with `onDismiss` or `options`. */\n icon?: ReactNode\n onChange?: never\n onDismiss?: never\n options?: never\n}\n\ninterface TagDismissProps {\n icon?: never\n onChange?: never\n /** Shows the ✕ when set. Called when the ✕ is pressed. */\n onDismiss?: () => void\n options?: never\n}\n\ninterface TagMenuProps {\n icon?: never\n /** Called with the picked option. */\n onChange: (option: TagOption) => void\n onDismiss?: () => void\n /**\n * The values the tag can change to. Shows a menu button after the name.\n * The menu marks the option whose `name` matches.\n */\n options: TagOption[]\n}\n\n/**\n * A tag has a leading icon, or its ✕ and menu buttons, not both, so the\n * icons do not compete.\n */\nexport type TagProps = TagBaseProps &\n (TagDismissProps | TagIconProps | TagMenuProps)\n\n/** `TagProps`, plus any other attribute of the root `div`, such as `id`. */\nexport type TagElementProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n keyof TagProps | \"children\"\n> &\n TagProps\n\n/**\n * A small, colored label for a value, such as a status or a category. A tag\n * can show a label before its name, a ✕ to remove it, and a menu that\n * changes its value.\n *\n * @component\n */\nexport function Tag({\n className,\n color = \"neutral\",\n icon,\n label,\n name,\n onChange,\n onDismiss,\n options,\n variant = \"subtle\",\n ...restProps\n}: TagElementProps) {\n const text = tagText(label, name)\n const hasMenu = !!options?.length\n const menu = useTagMenu({\n buttonLabel: `Change ${text}`,\n menuLabel: label ?? name,\n onChange: (option) => onChange?.(option),\n options: options ?? [],\n selectedName: name,\n })\n\n return (\n <div\n {...restProps}\n className={classNames(\n \"tds-tag\",\n `tds-tag--${color}`,\n `tds-tag--${variant}`,\n className\n )}\n >\n <TagContent\n dismissButton={\n onDismiss && (\n <button\n aria-label={`Remove ${text}`}\n className=\"tds-tag-dismiss\"\n onClick={onDismiss}\n type=\"button\"\n >\n <Icon aria-hidden symbol=\"general#x\" />\n </button>\n )\n }\n icon={icon}\n label={label}\n menuButton={hasMenu && menu.button}\n name={name}\n />\n {hasMenu && menu.popover}\n </div>\n )\n}\n"],"names":["React"],"mappings":";;;;;;AAgFA;;;;;;AAMG;AACG,SAAU,GAAG,CAAC,EAClB,SAAS,EACT,KAAK,GAAG,SAAS,EACjB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,GAAG,QAAQ,EAClB,GAAG,SAAS,EACI,EAAA;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;AACjC,IAAA,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM;IACjC,MAAM,IAAI,GAAG,UAAU,CAAC;QACtB,WAAW,EAAE,CAAA,OAAA,EAAU,IAAI,CAAA,CAAE;QAC7B,SAAS,EAAE,KAAK,IAAI,IAAI;QACxB,QAAQ,EAAE,CAAC,MAAM,KAAK,QAAQ,GAAG,MAAM,CAAC;QACxC,OAAO,EAAE,OAAO,IAAI,EAAE;AACtB,QAAA,YAAY,EAAE,IAAI;AACnB,KAAA,CAAC;AAEF,IAAA,QACEA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GACM,SAAS,EACb,SAAS,EAAE,UAAU,CACnB,SAAS,EACT,CAAA,SAAA,EAAY,KAAK,EAAE,EACnB,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,EACrB,SAAS,CACV,EAAA;QAEDA,cAAA,CAAA,aAAA,CAAC,UAAU,IACT,aAAa,EACX,SAAS,KACPA,cAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,YAAA,EACc,CAAA,OAAA,EAAU,IAAI,CAAA,CAAE,EAC5B,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,SAAS,EAClB,IAAI,EAAC,QAAQ,EAAA;AAEb,gBAAAA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAA,aAAA,EAAA,IAAA,EAAa,MAAM,EAAC,WAAW,EAAA,CAAG,CAChC,CACV,EAEH,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,OAAO,IAAI,IAAI,CAAC,MAAM,EAClC,IAAI,EAAE,IAAI,EAAA,CACV;AACD,QAAA,OAAO,IAAI,IAAI,CAAC,OAAO,CACpB;AAEV;;;;"}
@@ -0,0 +1,19 @@
1
+ import React, { type ReactNode } from "react";
2
+ interface TagContentProps {
3
+ /** The ✕ button. Always after the name. */
4
+ dismissButton?: ReactNode;
5
+ icon?: ReactNode;
6
+ label?: string;
7
+ /** The menu button. After the name and the ✕. */
8
+ menuButton?: ReactNode;
9
+ name: string;
10
+ }
11
+ /** The text screen readers read for a tag: "label: name", or the name. */
12
+ export declare function tagText(label: string | undefined, name: string): string;
13
+ /**
14
+ * The markup inside a tag. With a label, screen readers read one hidden
15
+ * "label: name" text, so the two parts are not read as separate items.
16
+ */
17
+ export declare function TagContent({ dismissButton, icon, label, menuButton, name, }: TagContentProps): React.JSX.Element;
18
+ export {};
19
+ //# sourceMappingURL=TagContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagContent.d.ts","sourceRoot":"","sources":["../../../src/components/tag/TagContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE7C,UAAU,eAAe;IACvB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,0EAA0E;AAC1E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,UAE9D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,aAAa,EACb,IAAI,EACJ,KAAK,EACL,UAAU,EACV,IAAI,GACL,EAAE,eAAe,qBA0BjB"}
@@ -0,0 +1,26 @@
1
+ import React__default from 'react';
2
+
3
+ /** The text screen readers read for a tag: "label: name", or the name. */
4
+ function tagText(label, name) {
5
+ return label ? `${label}: ${name}` : name;
6
+ }
7
+ /**
8
+ * The markup inside a tag. With a label, screen readers read one hidden
9
+ * "label: name" text, so the two parts are not read as separate items.
10
+ */
11
+ function TagContent({ dismissButton, icon, label, menuButton, name, }) {
12
+ const iconNode = icon && (React__default.createElement("span", { "aria-hidden": true, className: "tds-tag-icon" }, icon));
13
+ return (React__default.createElement(React__default.Fragment, null,
14
+ label && (React__default.createElement("span", { className: "tds-tag-text--hidden" }, tagText(label, name))),
15
+ label && (React__default.createElement("span", { "aria-hidden": true, className: "tds-tag-label" },
16
+ iconNode,
17
+ label)),
18
+ React__default.createElement("span", { className: "tds-tag-value" },
19
+ !label && iconNode,
20
+ React__default.createElement("span", { "aria-hidden": label ? true : undefined }, name),
21
+ dismissButton,
22
+ menuButton)));
23
+ }
24
+
25
+ export { TagContent, tagText };
26
+ //# sourceMappingURL=TagContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagContent.js","sources":["../../../src/components/tag/TagContent.tsx"],"sourcesContent":["import React, { type ReactNode } from \"react\"\n\ninterface TagContentProps {\n /** The ✕ button. Always after the name. */\n dismissButton?: ReactNode\n icon?: ReactNode\n label?: string\n /** The menu button. After the name and the ✕. */\n menuButton?: ReactNode\n name: string\n}\n\n/** The text screen readers read for a tag: \"label: name\", or the name. */\nexport function tagText(label: string | undefined, name: string) {\n return label ? `${label}: ${name}` : name\n}\n\n/**\n * The markup inside a tag. With a label, screen readers read one hidden\n * \"label: name\" text, so the two parts are not read as separate items.\n */\nexport function TagContent({\n dismissButton,\n icon,\n label,\n menuButton,\n name,\n}: TagContentProps) {\n const iconNode = icon && (\n <span aria-hidden className=\"tds-tag-icon\">\n {icon}\n </span>\n )\n\n return (\n <>\n {label && (\n <span className=\"tds-tag-text--hidden\">{tagText(label, name)}</span>\n )}\n {label && (\n <span aria-hidden className=\"tds-tag-label\">\n {iconNode}\n {label}\n </span>\n )}\n <span className=\"tds-tag-value\">\n {!label && iconNode}\n <span aria-hidden={label ? true : undefined}>{name}</span>\n {dismissButton}\n {menuButton}\n </span>\n </>\n )\n}\n"],"names":["React"],"mappings":";;AAYA;AACM,SAAU,OAAO,CAAC,KAAyB,EAAE,IAAY,EAAA;AAC7D,IAAA,OAAO,KAAK,GAAG,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,GAAG,IAAI;AAC3C;AAEA;;;AAGG;AACG,SAAU,UAAU,CAAC,EACzB,aAAa,EACb,IAAI,EACJ,KAAK,EACL,UAAU,EACV,IAAI,GACY,EAAA;AAChB,IAAA,MAAM,QAAQ,GAAG,IAAI,KACnBA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAA,IAAA,EAAkB,SAAS,EAAC,cAAc,EAAA,EACvC,IAAI,CACA,CACR;AAED,IAAA,QACEA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA;AACG,QAAA,KAAK,KACJA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,sBAAsB,EAAA,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAQ,CACrE;AACA,QAAA,KAAK,KACJA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAA,IAAA,EAAkB,SAAS,EAAC,eAAe,EAAA;YACxC,QAAQ;AACR,YAAA,KAAK,CACD,CACR;QACDA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,eAAe,EAAA;YAC5B,CAAC,KAAK,IAAI,QAAQ;YACnBA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAmB,KAAK,GAAG,IAAI,GAAG,SAAS,EAAA,EAAG,IAAI,CAAQ;YACzD,aAAa;YACb,UAAU,CACN,CACN;AAEP;;;;"}
@@ -0,0 +1,4 @@
1
+ import "./index.css";
2
+ export type { TagColor, TagElementProps, TagOption, TagProps, TagVariant, } from "./Tag";
3
+ export { Tag } from "./Tag";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/tag/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,YAAY,EACV,QAAQ,EACR,eAAe,EACf,SAAS,EACT,QAAQ,EACR,UAAU,GACX,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA"}
@@ -0,0 +1,31 @@
1
+ import "../dropdown/index.css";
2
+ import { type ReactNode } from "react";
3
+ import type { Key } from "react-aria-components";
4
+ export interface TagOption {
5
+ id: Key;
6
+ name: string;
7
+ }
8
+ interface UseTagMenuOptions {
9
+ /** Accessible name of the menu button. */
10
+ buttonLabel: string;
11
+ /** Accessible name of the menu. */
12
+ menuLabel: string;
13
+ onChange: (option: TagOption) => void;
14
+ options: TagOption[];
15
+ /** The name of the current option. The menu marks the option with this name. */
16
+ selectedName: string;
17
+ }
18
+ interface TagMenu {
19
+ /** The menu button. Place it inside the tag, after the name. */
20
+ button: ReactNode;
21
+ /** The menu. */
22
+ popover: ReactNode;
23
+ }
24
+ /**
25
+ * The menu button and single-select menu that change a tag's value.
26
+ * Internal to Tag. The menu is non-modal, like Dropdown's, so one click on
27
+ * another Tag's menu button closes this menu and opens that one.
28
+ */
29
+ export declare function useTagMenu({ buttonLabel, menuLabel, onChange, options, selectedName, }: UseTagMenuOptions): TagMenu;
30
+ export {};
31
+ //# sourceMappingURL=useTagMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTagMenu.d.ts","sourceRoot":"","sources":["../../../src/components/tag/useTagMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAG9B,OAAc,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAA;AAE1E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAKhD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,GAAG,CAAA;IACP,IAAI,EAAE,MAAM,CAAA;CACb;AAED,UAAU,iBAAiB;IACzB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAA;IACnB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAA;IACrC,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,UAAU,OAAO;IACf,gEAAgE;IAChE,MAAM,EAAE,SAAS,CAAA;IACjB,gBAAgB;IAChB,OAAO,EAAE,SAAS,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,WAAW,EACX,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAuF7B"}
@@ -0,0 +1,56 @@
1
+ import Icon from '../../utilities/Icon.js';
2
+ import React__default, { useState, useRef, useEffect } from 'react';
3
+ import { useInteractOutside, usePreventScroll, FocusScope } from 'react-aria';
4
+ import { Button } from 'react-aria-components/Button';
5
+ import { Menu, MenuItem } from 'react-aria-components/Menu';
6
+ import { Popover } from 'react-aria-components/Popover';
7
+
8
+ /**
9
+ * The menu button and single-select menu that change a tag's value.
10
+ * Internal to Tag. The menu is non-modal, like Dropdown's, so one click on
11
+ * another Tag's menu button closes this menu and opens that one.
12
+ */
13
+ function useTagMenu({ buttonLabel, menuLabel, onChange, options, selectedName, }) {
14
+ const [isOpen, setOpen] = useState(false);
15
+ const buttonRef = useRef(null);
16
+ const popoverRef = useRef(null);
17
+ const [isPointerDownOutside, setIsPointerDownOutside] = useState(false);
18
+ const selected = options.find((option) => option.name === selectedName);
19
+ useEffect(() => {
20
+ if (!isOpen)
21
+ setIsPointerDownOutside(false);
22
+ }, [isOpen]);
23
+ useInteractOutside({
24
+ isDisabled: !isOpen,
25
+ onInteractOutside: (event) => {
26
+ if (buttonRef.current?.contains(event.target))
27
+ return;
28
+ setOpen(false);
29
+ },
30
+ onInteractOutsideStart: () => setIsPointerDownOutside(true),
31
+ ref: popoverRef,
32
+ });
33
+ usePreventScroll({ isDisabled: !isOpen });
34
+ const handleSelectionChange = (keys) => {
35
+ if (keys === "all")
36
+ return;
37
+ const [key] = keys;
38
+ const option = options.find((o) => o.id === key);
39
+ if (option)
40
+ onChange(option);
41
+ };
42
+ const button = (React__default.createElement(Button, { "aria-expanded": isOpen, "aria-haspopup": "menu", "aria-label": buttonLabel, className: "tds-tag-menu-button", onPress: () => setOpen((open) => !open), ref: buttonRef },
43
+ React__default.createElement(Icon, { "aria-hidden": true, symbol: "general#down-caret" })));
44
+ const popover = (React__default.createElement(Popover, { className: "tds-dropdown-popover", isNonModal: true, isOpen: isOpen, onOpenChange: setOpen, placement: "bottom", ref: popoverRef, shouldCloseOnInteractOutside: () => false, triggerRef: buttonRef },
45
+ React__default.createElement(FocusScope, { contain: !isPointerDownOutside },
46
+ React__default.createElement(Menu, { "aria-label": menuLabel,
47
+ // eslint-disable-next-line jsx-a11y/no-autofocus -- a menu opened by its button must move focus into the menu
48
+ autoFocus: "first", disallowEmptySelection: true, items: options, onClose: () => setOpen(false), onSelectionChange: handleSelectionChange, selectedKeys: selected ? [selected.id] : [], selectionMode: "single" }, (option) => (React__default.createElement(MenuItem, { className: "tds-dropdown-item", textValue: option.name }, ({ isSelected }) => (React__default.createElement(React__default.Fragment, null,
49
+ React__default.createElement("span", { slot: "prefix" },
50
+ React__default.createElement(Icon, { "aria-hidden": true, style: { visibility: isSelected ? "visible" : "hidden" }, symbol: "general#check" })),
51
+ React__default.createElement("span", { slot: "label" }, option.name)))))))));
52
+ return { button, popover };
53
+ }
54
+
55
+ export { useTagMenu };
56
+ //# sourceMappingURL=useTagMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTagMenu.js","sources":["../../../src/components/tag/useTagMenu.tsx"],"sourcesContent":["import \"../dropdown/index.css\"\n\nimport Icon from \"@utilities/Icon\"\nimport React, { type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { FocusScope, useInteractOutside, usePreventScroll } from \"react-aria\"\nimport type { Key } from \"react-aria-components\"\nimport { Button as AriaButton } from \"react-aria-components/Button\"\nimport { Menu, MenuItem } from \"react-aria-components/Menu\"\nimport { Popover } from \"react-aria-components/Popover\"\n\nexport interface TagOption {\n id: Key\n name: string\n}\n\ninterface UseTagMenuOptions {\n /** Accessible name of the menu button. */\n buttonLabel: string\n /** Accessible name of the menu. */\n menuLabel: string\n onChange: (option: TagOption) => void\n options: TagOption[]\n /** The name of the current option. The menu marks the option with this name. */\n selectedName: string\n}\n\ninterface TagMenu {\n /** The menu button. Place it inside the tag, after the name. */\n button: ReactNode\n /** The menu. */\n popover: ReactNode\n}\n\n/**\n * The menu button and single-select menu that change a tag's value.\n * Internal to Tag. The menu is non-modal, like Dropdown's, so one click on\n * another Tag's menu button closes this menu and opens that one.\n */\nexport function useTagMenu({\n buttonLabel,\n menuLabel,\n onChange,\n options,\n selectedName,\n}: UseTagMenuOptions): TagMenu {\n const [isOpen, setOpen] = useState(false)\n const buttonRef = useRef<HTMLButtonElement | null>(null)\n const popoverRef = useRef<HTMLElement>(null)\n const [isPointerDownOutside, setIsPointerDownOutside] = useState(false)\n const selected = options.find((option) => option.name === selectedName)\n\n useEffect(() => {\n if (!isOpen) setIsPointerDownOutside(false)\n }, [isOpen])\n\n useInteractOutside({\n isDisabled: !isOpen,\n onInteractOutside: (event) => {\n if (buttonRef.current?.contains(event.target as Node)) return\n setOpen(false)\n },\n onInteractOutsideStart: () => setIsPointerDownOutside(true),\n ref: popoverRef,\n })\n usePreventScroll({ isDisabled: !isOpen })\n\n const handleSelectionChange = (keys: \"all\" | Set<Key>) => {\n if (keys === \"all\") return\n const [key] = keys\n const option = options.find((o) => o.id === key)\n if (option) onChange(option)\n }\n\n const button = (\n <AriaButton\n aria-expanded={isOpen}\n aria-haspopup=\"menu\"\n aria-label={buttonLabel}\n className=\"tds-tag-menu-button\"\n onPress={() => setOpen((open) => !open)}\n ref={buttonRef}\n >\n <Icon aria-hidden symbol=\"general#down-caret\" />\n </AriaButton>\n )\n\n const popover = (\n <Popover\n className=\"tds-dropdown-popover\"\n isNonModal\n isOpen={isOpen}\n onOpenChange={setOpen}\n placement=\"bottom\"\n ref={popoverRef}\n shouldCloseOnInteractOutside={() => false}\n triggerRef={buttonRef}\n >\n <FocusScope contain={!isPointerDownOutside}>\n <Menu\n aria-label={menuLabel}\n // eslint-disable-next-line jsx-a11y/no-autofocus -- a menu opened by its button must move focus into the menu\n autoFocus=\"first\"\n disallowEmptySelection\n items={options}\n onClose={() => setOpen(false)}\n onSelectionChange={handleSelectionChange}\n selectedKeys={selected ? [selected.id] : []}\n selectionMode=\"single\"\n >\n {(option) => (\n <MenuItem className=\"tds-dropdown-item\" textValue={option.name}>\n {({ isSelected }) => (\n <>\n <span slot=\"prefix\">\n <Icon\n aria-hidden\n style={{ visibility: isSelected ? \"visible\" : \"hidden\" }}\n symbol=\"general#check\"\n />\n </span>\n <span slot=\"label\">{option.name}</span>\n </>\n )}\n </MenuItem>\n )}\n </Menu>\n </FocusScope>\n </Popover>\n )\n\n return { button, popover }\n}\n"],"names":["React","AriaButton"],"mappings":";;;;;;;AAiCA;;;;AAIG;AACG,SAAU,UAAU,CAAC,EACzB,WAAW,EACX,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,GACM,EAAA;IAClB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACzC,IAAA,MAAM,SAAS,GAAG,MAAM,CAA2B,IAAI,CAAC;AACxD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAc,IAAI,CAAC;IAC5C,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACvE,IAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC;IAEvE,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,MAAM;YAAE,uBAAuB,CAAC,KAAK,CAAC;AAC7C,IAAA,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAEZ,IAAA,kBAAkB,CAAC;QACjB,UAAU,EAAE,CAAC,MAAM;AACnB,QAAA,iBAAiB,EAAE,CAAC,KAAK,KAAI;YAC3B,IAAI,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC;gBAAE;YACvD,OAAO,CAAC,KAAK,CAAC;QAChB,CAAC;AACD,QAAA,sBAAsB,EAAE,MAAM,uBAAuB,CAAC,I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