@postenbring/hedwig-react 4.6.0 → 4.7.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 (43) hide show
  1. package/dist/chip/chip-group.d.ts +26 -0
  2. package/dist/chip/chip-group.d.ts.map +1 -0
  3. package/dist/chip/chip-group.js +79 -0
  4. package/dist/chip/chip-group.js.map +1 -0
  5. package/dist/chip/chip-group.mjs +8 -0
  6. package/dist/chip/chip-group.mjs.map +1 -0
  7. package/dist/chip/chip.d.ts +108 -0
  8. package/dist/chip/chip.d.ts.map +1 -0
  9. package/dist/chip/chip.js +189 -0
  10. package/dist/chip/chip.js.map +1 -0
  11. package/dist/chip/chip.mjs +8 -0
  12. package/dist/chip/chip.mjs.map +1 -0
  13. package/dist/chip/index.d.ts +5 -0
  14. package/dist/chip/index.d.ts.map +1 -0
  15. package/dist/chip/index.js +215 -0
  16. package/dist/chip/index.js.map +1 -0
  17. package/dist/chip/index.mjs +13 -0
  18. package/dist/chip/index.mjs.map +1 -0
  19. package/dist/chunk-KQPAJB4B.mjs +145 -0
  20. package/dist/chunk-KQPAJB4B.mjs.map +1 -0
  21. package/dist/chunk-PNYTWKKD.mjs +1 -0
  22. package/dist/chunk-PNYTWKKD.mjs.map +1 -0
  23. package/dist/chunk-VQPQ7RLE.mjs +32 -0
  24. package/dist/chunk-VQPQ7RLE.mjs.map +1 -0
  25. package/dist/form/error-summary/error-summary.mjs +1 -1
  26. package/dist/form/error-summary/index.mjs +1 -1
  27. package/dist/form/index.mjs +17 -17
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +632 -474
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +93 -84
  33. package/dist/layout/index.mjs +6 -6
  34. package/dist/navbar/icons.d.ts +2 -2
  35. package/dist/navbar/icons.d.ts.map +1 -1
  36. package/dist/navbar/navbar-expandable-menu.d.ts +1 -1
  37. package/dist/navbar/navbar-expandable-menu.d.ts.map +1 -1
  38. package/package.json +4 -4
  39. package/src/chip/chip-group.tsx +45 -0
  40. package/src/chip/chip.stories.tsx +197 -0
  41. package/src/chip/chip.tsx +266 -0
  42. package/src/chip/index.tsx +4 -0
  43. package/src/index.ts +1 -0
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
35
+ var __export = (target, all) => {
36
+ for (var name in all)
37
+ __defProp(target, name, { get: all[name], enumerable: true });
38
+ };
39
+ var __copyProps = (to, from, except, desc) => {
40
+ if (from && typeof from === "object" || typeof from === "function") {
41
+ for (let key of __getOwnPropNames(from))
42
+ if (!__hasOwnProp.call(to, key) && key !== except)
43
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
44
+ }
45
+ return to;
46
+ };
47
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
+
49
+ // src/chip/index.tsx
50
+ var chip_exports = {};
51
+ __export(chip_exports, {
52
+ Chip: () => Chip,
53
+ ChipGroup: () => ChipGroup
54
+ });
55
+ module.exports = __toCommonJS(chip_exports);
56
+
57
+ // src/chip/chip.tsx
58
+ var import_react = require("react");
59
+ var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
60
+ var import_react_slot = require("@radix-ui/react-slot");
61
+ var import_jsx_runtime = require("react/jsx-runtime");
62
+ function chipClassName(type, variant, className) {
63
+ return (0, import_typed_classname.clsx)(
64
+ "hds-chip",
65
+ // The button type has no type-specific styles, so it has no modifier class
66
+ type !== "button" && `hds-chip--${type}`,
67
+ { "hds-chip--secondary": variant === "secondary" },
68
+ className
69
+ );
70
+ }
71
+ var InputChip = (0, import_react.forwardRef)(
72
+ function InputChip2(_a, ref) {
73
+ var _b = _a, { type, variant = "primary", className, style, children } = _b, inputProps = __objRest(_b, ["type", "variant", "className", "style", "children"]);
74
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: chipClassName(type, variant, className), style, children: [
75
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", __spreadProps(__spreadValues({}, inputProps), { ref, type, className: "hds-chip__input" })),
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "hds-chip__indicator", "aria-hidden": "true" }),
77
+ children
78
+ ] });
79
+ }
80
+ );
81
+ var RemovableChip = (0, import_react.forwardRef)(function RemovableChip2(_a, ref) {
82
+ var _b = _a, {
83
+ type,
84
+ variant = "primary",
85
+ className,
86
+ onRemove,
87
+ removeLabel = "Fjern",
88
+ onClick,
89
+ children
90
+ } = _b, buttonProps = __objRest(_b, [
91
+ "type",
92
+ "variant",
93
+ "className",
94
+ "onRemove",
95
+ "removeLabel",
96
+ "onClick",
97
+ "children"
98
+ ]);
99
+ const ariaLabel = typeof children === "string" || typeof children === "number" ? `${removeLabel} ${children}` : void 0;
100
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
101
+ "button",
102
+ __spreadProps(__spreadValues({
103
+ "aria-label": ariaLabel
104
+ }, buttonProps), {
105
+ ref,
106
+ type: "button",
107
+ className: chipClassName(type, variant, className),
108
+ onClick: (event) => {
109
+ onClick == null ? void 0 : onClick(event);
110
+ if (!event.defaultPrevented) onRemove == null ? void 0 : onRemove(event);
111
+ },
112
+ children: [
113
+ children,
114
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "hds-chip__remove", "aria-hidden": "true" })
115
+ ]
116
+ })
117
+ );
118
+ });
119
+ var ButtonChip = (0, import_react.forwardRef)(function ButtonChip2(_a, ref) {
120
+ var _b = _a, { type, variant = "primary", className, asChild } = _b, buttonProps = __objRest(_b, ["type", "variant", "className", "asChild"]);
121
+ const classNames = chipClassName(type, variant, className);
122
+ if (asChild) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_slot.Slot, __spreadProps(__spreadValues({}, buttonProps), { ref, className: classNames }));
123
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", __spreadProps(__spreadValues({}, buttonProps), { ref, type: "button", className: classNames }));
124
+ });
125
+ var ToggleChip = (0, import_react.forwardRef)(function ToggleChip2(_a, ref) {
126
+ var _b = _a, {
127
+ type,
128
+ variant = "primary",
129
+ className,
130
+ icon,
131
+ pressedIcon,
132
+ pressed: pressedProp,
133
+ defaultPressed = false,
134
+ onPressedChange,
135
+ onClick,
136
+ children
137
+ } = _b, buttonProps = __objRest(_b, [
138
+ "type",
139
+ "variant",
140
+ "className",
141
+ "icon",
142
+ "pressedIcon",
143
+ "pressed",
144
+ "defaultPressed",
145
+ "onPressedChange",
146
+ "onClick",
147
+ "children"
148
+ ]);
149
+ const [pressedState, setPressedState] = (0, import_react.useState)(defaultPressed);
150
+ const isControlled = pressedProp !== void 0;
151
+ const pressed = isControlled ? pressedProp : pressedState;
152
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
153
+ "button",
154
+ __spreadProps(__spreadValues({}, buttonProps), {
155
+ ref,
156
+ type: "button",
157
+ "aria-pressed": pressed,
158
+ className: chipClassName(type, variant, className),
159
+ onClick: (event) => {
160
+ onClick == null ? void 0 : onClick(event);
161
+ if (event.defaultPrevented) return;
162
+ if (!isControlled) setPressedState(!pressed);
163
+ onPressedChange == null ? void 0 : onPressedChange(!pressed);
164
+ },
165
+ children: [
166
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "hds-chip__icon", "aria-hidden": "true", children: pressed && pressedIcon ? pressedIcon : icon }),
167
+ children
168
+ ]
169
+ })
170
+ );
171
+ });
172
+ var Chip = (0, import_react.forwardRef)((props, ref) => {
173
+ const inputRef = ref;
174
+ const buttonRef = ref;
175
+ switch (props.type) {
176
+ case "radio":
177
+ case "checkbox":
178
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InputChip, __spreadProps(__spreadValues({}, props), { ref: inputRef }));
179
+ case "removable":
180
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RemovableChip, __spreadProps(__spreadValues({}, props), { ref: buttonRef }));
181
+ case "button":
182
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonChip, __spreadProps(__spreadValues({}, props), { ref: buttonRef }));
183
+ case "toggle":
184
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleChip, __spreadProps(__spreadValues({}, props), { ref: buttonRef }));
185
+ }
186
+ });
187
+ Chip.displayName = "Chip";
188
+
189
+ // src/chip/chip-group.tsx
190
+ var import_react2 = require("react");
191
+ var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
192
+ var import_react_slot2 = require("@radix-ui/react-slot");
193
+ var import_jsx_runtime2 = require("react/jsx-runtime");
194
+ var ChipGroup = (0, import_react2.forwardRef)(
195
+ (_a, ref) => {
196
+ var _b = _a, { layout = "wrap", asChild, className, children } = _b, rest = __objRest(_b, ["layout", "asChild", "className", "children"]);
197
+ const Component = asChild ? import_react_slot2.Slot : "div";
198
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
199
+ Component,
200
+ __spreadProps(__spreadValues({
201
+ className: (0, import_typed_classname2.clsx)("hds-chip-group", `hds-chip-group--${layout}`, className),
202
+ ref
203
+ }, rest), {
204
+ children
205
+ })
206
+ );
207
+ }
208
+ );
209
+ ChipGroup.displayName = "ChipGroup";
210
+ // Annotate the CommonJS export names for ESM import in node:
211
+ 0 && (module.exports = {
212
+ Chip,
213
+ ChipGroup
214
+ });
215
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/chip/index.tsx","../../src/chip/chip.tsx","../../src/chip/chip-group.tsx"],"sourcesContent":["export { Chip } from \"./chip\";\nexport type * from \"./chip\";\nexport { ChipGroup } from \"./chip-group\";\nexport type * from \"./chip-group\";\n","import {\n forwardRef,\n useState,\n type ButtonHTMLAttributes,\n type InputHTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\ninterface ChipBaseProps {\n /**\n * `primary`: Colored by the inherited brand theme.\n * `secondary`: White/grey chip, the checked indicator keeps the brand color.\n *\n * @default \"primary\"\n */\n variant?: \"primary\" | \"secondary\";\n children: ReactNode;\n}\n\n/**\n * Native button props, without `type`.\n * The `type` prop of the Chip selects the kind of chip, so the native button `type` can not be set.\n * Buttons are always rendered with `type=\"button\"` to avoid accidentally submitting forms.\n */\ntype NativeButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"children\">;\n\ntype NativeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, \"type\" | \"children\" | \"size\">;\n\nexport type ChipRadioProps = ChipBaseProps & NativeInputProps & { type: \"radio\" };\n\nexport type ChipCheckboxProps = ChipBaseProps & NativeInputProps & { type: \"checkbox\" };\n\nexport type ChipRemovableProps = ChipBaseProps &\n NativeButtonProps & {\n type: \"removable\";\n /**\n * Called when the chip is clicked, i.e. the user wants to remove it.\n * A `onClick` handler is also called, if provided.\n */\n onRemove?: (event: MouseEvent<HTMLButtonElement>) => void;\n /**\n * Text prepended to the label to form the accessible name, e.g. \"Fjern Oslo\".\n * Only used when `children` is a string or number, otherwise provide an `aria-label`.\n *\n * @default \"Fjern\"\n */\n removeLabel?: string;\n };\n\nexport type ChipButtonProps = ChipBaseProps &\n NativeButtonProps & {\n type: \"button\";\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n };\n\nexport type ChipToggleProps = ChipBaseProps &\n NativeButtonProps & {\n type: \"toggle\";\n /** Icon shown in the chip. Should be an `svg`, it is hidden from assistive technology. */\n icon: ReactNode;\n /** Icon shown instead of `icon` when pressed. */\n pressedIcon?: ReactNode;\n /** Controlled pressed state. */\n pressed?: boolean;\n /** Initial pressed state when uncontrolled. */\n defaultPressed?: boolean;\n /** Called when the user toggles the chip. */\n onPressedChange?: (pressed: boolean) => void;\n };\n\nexport type ChipProps =\n ChipRadioProps | ChipCheckboxProps | ChipRemovableProps | ChipButtonProps | ChipToggleProps;\n\nfunction chipClassName(type: ChipProps[\"type\"], variant: ChipProps[\"variant\"], className?: string) {\n return clsx(\n \"hds-chip\",\n // The button type has no type-specific styles, so it has no modifier class\n type !== \"button\" && `hds-chip--${type}`,\n { \"hds-chip--secondary\": variant === \"secondary\" },\n className as undefined,\n );\n}\n\n/**\n * One component per type of chip, `Chip` picks the right one\n */\n\nconst InputChip = forwardRef<HTMLInputElement, ChipRadioProps | ChipCheckboxProps>(\n function InputChip(\n { type, variant = \"primary\", className, style, children, ...inputProps },\n ref,\n ) {\n return (\n <label className={chipClassName(type, variant, className)} style={style}>\n <input {...inputProps} ref={ref} type={type} className=\"hds-chip__input\" />\n <span className=\"hds-chip__indicator\" aria-hidden=\"true\" />\n {children}\n </label>\n );\n },\n);\n\nconst RemovableChip = forwardRef<HTMLButtonElement, ChipRemovableProps>(function RemovableChip(\n {\n type,\n variant = \"primary\",\n className,\n onRemove,\n removeLabel = \"Fjern\",\n onClick,\n children,\n ...buttonProps\n },\n ref,\n) {\n // E.g. \"Fjern Oslo\". For other children than text the consumer must provide an `aria-label`\n const ariaLabel =\n typeof children === \"string\" || typeof children === \"number\"\n ? `${removeLabel} ${children}`\n : undefined;\n\n return (\n <button\n aria-label={ariaLabel}\n {...buttonProps}\n ref={ref}\n type=\"button\"\n className={chipClassName(type, variant, className)}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) onRemove?.(event);\n }}\n >\n {children}\n <span className=\"hds-chip__remove\" aria-hidden=\"true\" />\n </button>\n );\n});\n\nconst ButtonChip = forwardRef<HTMLButtonElement, ChipButtonProps>(function ButtonChip(\n { type, variant = \"primary\", className, asChild, ...buttonProps },\n ref,\n) {\n const classNames = chipClassName(type, variant, className);\n\n // With `asChild` the child decides the element, e.g. an anchor, so no `type=\"button\"`\n if (asChild) return <Slot {...buttonProps} ref={ref} className={classNames} />;\n\n return <button {...buttonProps} ref={ref} type=\"button\" className={classNames} />;\n});\n\nconst ToggleChip = forwardRef<HTMLButtonElement, ChipToggleProps>(function ToggleChip(\n {\n type,\n variant = \"primary\",\n className,\n icon,\n pressedIcon,\n pressed: pressedProp,\n defaultPressed = false,\n onPressedChange,\n onClick,\n children,\n ...buttonProps\n },\n ref,\n) {\n const [pressedState, setPressedState] = useState(defaultPressed);\n const isControlled = pressedProp !== undefined;\n const pressed = isControlled ? pressedProp : pressedState;\n\n return (\n <button\n {...buttonProps}\n ref={ref}\n type=\"button\"\n aria-pressed={pressed}\n className={chipClassName(type, variant, className)}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (!isControlled) setPressedState(!pressed);\n onPressedChange?.(!pressed);\n }}\n >\n <span className=\"hds-chip__icon\" aria-hidden=\"true\">\n {pressed && pressedIcon ? pressedIcon : icon}\n </span>\n {children}\n </button>\n );\n});\n\n/**\n * Gives `ref` the right element type for each chip type:\n * `HTMLInputElement` for radio and checkbox, `HTMLButtonElement` for the rest.\n */\ninterface ChipComponent {\n (\n props:\n | ((ChipRadioProps | ChipCheckboxProps) & { ref?: Ref<HTMLInputElement> })\n | ((ChipRemovableProps | ChipButtonProps | ChipToggleProps) & {\n ref?: Ref<HTMLButtonElement>;\n }),\n ): ReactElement | null;\n displayName?: string;\n}\n\n/**\n * Chips let the user select one or more options, toggle something, or remove an item.\n *\n * Choose the kind of chip with the `type` prop:\n * - `radio`: Select one among several options. Use the same `name` for the options.\n * - `checkbox`: Select one or more among several options.\n * - `removable`: Represents a selected value the user can remove.\n * - `button`: Triggers an action. Use `asChild` with an anchor for navigation.\n * - `toggle`: A pressable chip with an icon, e.g. to mark something as favorite.\n *\n * Note that the `type` prop is the chip type, not the native button `type`.\n * Buttons are always rendered with `type=\"button\"`.\n *\n * For `radio` and `checkbox` `className` and `style` are set on the root `label`,\n * all other props are set on the `input`.\n *\n * Wrap multiple chips in a `ChipGroup`.\n *\n * @example\n * <Chip type=\"radio\" name=\"weight\" value=\"0-2\">0-2 kg</Chip>\n * <Chip type=\"checkbox\" defaultChecked>Sporing</Chip>\n * <Chip type=\"removable\" onRemove={() => removeCity(\"oslo\")}>Oslo</Chip>\n * <Chip type=\"button\" onClick={openFilter}>Filter</Chip>\n * <Chip variant=\"secondary\" type=\"toggle\" icon={<StarOutline />} pressedIcon={<StarSolid />}>\n * Favoritt\n * </Chip>\n *\n * @example\n * // For navigation use `asChild` with an anchor element.\n * <Chip type=\"button\" asChild><a href=\"/tracking\">Sporing</a></Chip>\n */\nexport const Chip = forwardRef<HTMLInputElement | HTMLButtonElement, ChipProps>((props, ref) => {\n const inputRef = ref as Ref<HTMLInputElement>;\n const buttonRef = ref as Ref<HTMLButtonElement>;\n\n switch (props.type) {\n case \"radio\":\n case \"checkbox\":\n return <InputChip {...props} ref={inputRef} />;\n case \"removable\":\n return <RemovableChip {...props} ref={buttonRef} />;\n case \"button\":\n return <ButtonChip {...props} ref={buttonRef} />;\n case \"toggle\":\n return <ToggleChip {...props} ref={buttonRef} />;\n }\n}) as ChipComponent;\nChip.displayName = \"Chip\";\n","import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface ChipGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * `inline`: A single row, scrolls horizontally when the chips do not fit.\n * `wrap`: Chips wrap onto multiple rows.\n *\n * @default \"wrap\"\n */\n layout?: \"inline\" | \"wrap\";\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * Groups multiple `Chip`s with correct spacing.\n *\n * @example\n * <ChipGroup layout=\"wrap\">\n * <Chip type=\"checkbox\">Sporing</Chip>\n * <Chip type=\"checkbox\">Hente i butikk</Chip>\n * </ChipGroup>\n */\nexport const ChipGroup = forwardRef<HTMLDivElement, ChipGroupProps>(\n ({ layout = \"wrap\", asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-chip-group\", `hds-chip-group--${layout}`, className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nChipGroup.displayName = \"ChipGroup\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBASO;AACP,6BAAqB;AACrB,wBAAqB;AA4Ff;AApBN,SAAS,cAAc,MAAyB,SAA+B,WAAoB;AACjG,aAAO;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;AACjB,QAAM,YAAY;AAElB,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AACH,aAAO,4CAAC,4CAAc,QAAd,EAAqB,KAAK,WAAU;AAAA,IAC9C,KAAK;AACH,aAAO,4CAAC,gDAAkB,QAAlB,EAAyB,KAAK,YAAW;AAAA,IACnD,KAAK;AACH,aAAO,4CAAC,6CAAe,QAAf,EAAsB,KAAK,YAAW;AAAA,IAChD,KAAK;AACH,aAAO,4CAAC,6CAAe,QAAf,EAAsB,KAAK,YAAW;AAAA,EAClD;AACF,CAAC;AACD,KAAK,cAAc;;;ACzQnB,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;AAgCf,IAAAC,sBAAA;AAJC,IAAM,gBAAY;AAAA,EACvB,CAAC,IAA4D,QAAQ;AAApE,iBAAE,WAAS,QAAQ,SAAS,WAAW,SA/B1C,IA+BG,IAAoD,iBAApD,IAAoD,CAAlD,UAAiB,WAAS,aAAW;AACtC,UAAM,YAAY,UAAU,0BAAO;AACnC,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,kBAAkB,mBAAmB,MAAM,IAAI,SAAsB;AAAA,QACrF;AAAA,SACI,OAHL;AAAA,QAKE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,UAAU,cAAc;","names":["InputChip","RemovableChip","ButtonChip","ToggleChip","import_react","import_typed_classname","import_react_slot","import_jsx_runtime"]}
@@ -0,0 +1,13 @@
1
+ import "../chunk-PNYTWKKD.mjs";
2
+ import {
3
+ Chip
4
+ } from "../chunk-KQPAJB4B.mjs";
5
+ import {
6
+ ChipGroup
7
+ } from "../chunk-VQPQ7RLE.mjs";
8
+ import "../chunk-YOSPWY5K.mjs";
9
+ export {
10
+ Chip,
11
+ ChipGroup
12
+ };
13
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,145 @@
1
+ import {
2
+ __objRest,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-YOSPWY5K.mjs";
6
+
7
+ // src/chip/chip.tsx
8
+ import {
9
+ forwardRef,
10
+ useState
11
+ } from "react";
12
+ import { clsx } from "@postenbring/hedwig-css/typed-classname";
13
+ import { Slot } from "@radix-ui/react-slot";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ function chipClassName(type, variant, className) {
16
+ return clsx(
17
+ "hds-chip",
18
+ // The button type has no type-specific styles, so it has no modifier class
19
+ type !== "button" && `hds-chip--${type}`,
20
+ { "hds-chip--secondary": variant === "secondary" },
21
+ className
22
+ );
23
+ }
24
+ var InputChip = forwardRef(
25
+ function InputChip2(_a, ref) {
26
+ var _b = _a, { type, variant = "primary", className, style, children } = _b, inputProps = __objRest(_b, ["type", "variant", "className", "style", "children"]);
27
+ return /* @__PURE__ */ jsxs("label", { className: chipClassName(type, variant, className), style, children: [
28
+ /* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({}, inputProps), { ref, type, className: "hds-chip__input" })),
29
+ /* @__PURE__ */ jsx("span", { className: "hds-chip__indicator", "aria-hidden": "true" }),
30
+ children
31
+ ] });
32
+ }
33
+ );
34
+ var RemovableChip = forwardRef(function RemovableChip2(_a, ref) {
35
+ var _b = _a, {
36
+ type,
37
+ variant = "primary",
38
+ className,
39
+ onRemove,
40
+ removeLabel = "Fjern",
41
+ onClick,
42
+ children
43
+ } = _b, buttonProps = __objRest(_b, [
44
+ "type",
45
+ "variant",
46
+ "className",
47
+ "onRemove",
48
+ "removeLabel",
49
+ "onClick",
50
+ "children"
51
+ ]);
52
+ const ariaLabel = typeof children === "string" || typeof children === "number" ? `${removeLabel} ${children}` : void 0;
53
+ return /* @__PURE__ */ jsxs(
54
+ "button",
55
+ __spreadProps(__spreadValues({
56
+ "aria-label": ariaLabel
57
+ }, buttonProps), {
58
+ ref,
59
+ type: "button",
60
+ className: chipClassName(type, variant, className),
61
+ onClick: (event) => {
62
+ onClick == null ? void 0 : onClick(event);
63
+ if (!event.defaultPrevented) onRemove == null ? void 0 : onRemove(event);
64
+ },
65
+ children: [
66
+ children,
67
+ /* @__PURE__ */ jsx("span", { className: "hds-chip__remove", "aria-hidden": "true" })
68
+ ]
69
+ })
70
+ );
71
+ });
72
+ var ButtonChip = forwardRef(function ButtonChip2(_a, ref) {
73
+ var _b = _a, { type, variant = "primary", className, asChild } = _b, buttonProps = __objRest(_b, ["type", "variant", "className", "asChild"]);
74
+ const classNames = chipClassName(type, variant, className);
75
+ if (asChild) return /* @__PURE__ */ jsx(Slot, __spreadProps(__spreadValues({}, buttonProps), { ref, className: classNames }));
76
+ return /* @__PURE__ */ jsx("button", __spreadProps(__spreadValues({}, buttonProps), { ref, type: "button", className: classNames }));
77
+ });
78
+ var ToggleChip = forwardRef(function ToggleChip2(_a, ref) {
79
+ var _b = _a, {
80
+ type,
81
+ variant = "primary",
82
+ className,
83
+ icon,
84
+ pressedIcon,
85
+ pressed: pressedProp,
86
+ defaultPressed = false,
87
+ onPressedChange,
88
+ onClick,
89
+ children
90
+ } = _b, buttonProps = __objRest(_b, [
91
+ "type",
92
+ "variant",
93
+ "className",
94
+ "icon",
95
+ "pressedIcon",
96
+ "pressed",
97
+ "defaultPressed",
98
+ "onPressedChange",
99
+ "onClick",
100
+ "children"
101
+ ]);
102
+ const [pressedState, setPressedState] = useState(defaultPressed);
103
+ const isControlled = pressedProp !== void 0;
104
+ const pressed = isControlled ? pressedProp : pressedState;
105
+ return /* @__PURE__ */ jsxs(
106
+ "button",
107
+ __spreadProps(__spreadValues({}, buttonProps), {
108
+ ref,
109
+ type: "button",
110
+ "aria-pressed": pressed,
111
+ className: chipClassName(type, variant, className),
112
+ onClick: (event) => {
113
+ onClick == null ? void 0 : onClick(event);
114
+ if (event.defaultPrevented) return;
115
+ if (!isControlled) setPressedState(!pressed);
116
+ onPressedChange == null ? void 0 : onPressedChange(!pressed);
117
+ },
118
+ children: [
119
+ /* @__PURE__ */ jsx("span", { className: "hds-chip__icon", "aria-hidden": "true", children: pressed && pressedIcon ? pressedIcon : icon }),
120
+ children
121
+ ]
122
+ })
123
+ );
124
+ });
125
+ var Chip = forwardRef((props, ref) => {
126
+ const inputRef = ref;
127
+ const buttonRef = ref;
128
+ switch (props.type) {
129
+ case "radio":
130
+ case "checkbox":
131
+ return /* @__PURE__ */ jsx(InputChip, __spreadProps(__spreadValues({}, props), { ref: inputRef }));
132
+ case "removable":
133
+ return /* @__PURE__ */ jsx(RemovableChip, __spreadProps(__spreadValues({}, props), { ref: buttonRef }));
134
+ case "button":
135
+ return /* @__PURE__ */ jsx(ButtonChip, __spreadProps(__spreadValues({}, props), { ref: buttonRef }));
136
+ case "toggle":
137
+ return /* @__PURE__ */ jsx(ToggleChip, __spreadProps(__spreadValues({}, props), { ref: buttonRef }));
138
+ }
139
+ });
140
+ Chip.displayName = "Chip";
141
+
142
+ export {
143
+ Chip
144
+ };
145
+ //# sourceMappingURL=chunk-KQPAJB4B.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/chip/chip.tsx"],"sourcesContent":["import {\n forwardRef,\n useState,\n type ButtonHTMLAttributes,\n type InputHTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\ninterface ChipBaseProps {\n /**\n * `primary`: Colored by the inherited brand theme.\n * `secondary`: White/grey chip, the checked indicator keeps the brand color.\n *\n * @default \"primary\"\n */\n variant?: \"primary\" | \"secondary\";\n children: ReactNode;\n}\n\n/**\n * Native button props, without `type`.\n * The `type` prop of the Chip selects the kind of chip, so the native button `type` can not be set.\n * Buttons are always rendered with `type=\"button\"` to avoid accidentally submitting forms.\n */\ntype NativeButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"children\">;\n\ntype NativeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, \"type\" | \"children\" | \"size\">;\n\nexport type ChipRadioProps = ChipBaseProps & NativeInputProps & { type: \"radio\" };\n\nexport type ChipCheckboxProps = ChipBaseProps & NativeInputProps & { type: \"checkbox\" };\n\nexport type ChipRemovableProps = ChipBaseProps &\n NativeButtonProps & {\n type: \"removable\";\n /**\n * Called when the chip is clicked, i.e. the user wants to remove it.\n * A `onClick` handler is also called, if provided.\n */\n onRemove?: (event: MouseEvent<HTMLButtonElement>) => void;\n /**\n * Text prepended to the label to form the accessible name, e.g. \"Fjern Oslo\".\n * Only used when `children` is a string or number, otherwise provide an `aria-label`.\n *\n * @default \"Fjern\"\n */\n removeLabel?: string;\n };\n\nexport type ChipButtonProps = ChipBaseProps &\n NativeButtonProps & {\n type: \"button\";\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n };\n\nexport type ChipToggleProps = ChipBaseProps &\n NativeButtonProps & {\n type: \"toggle\";\n /** Icon shown in the chip. Should be an `svg`, it is hidden from assistive technology. */\n icon: ReactNode;\n /** Icon shown instead of `icon` when pressed. */\n pressedIcon?: ReactNode;\n /** Controlled pressed state. */\n pressed?: boolean;\n /** Initial pressed state when uncontrolled. */\n defaultPressed?: boolean;\n /** Called when the user toggles the chip. */\n onPressedChange?: (pressed: boolean) => void;\n };\n\nexport type ChipProps =\n ChipRadioProps | ChipCheckboxProps | ChipRemovableProps | ChipButtonProps | ChipToggleProps;\n\nfunction chipClassName(type: ChipProps[\"type\"], variant: ChipProps[\"variant\"], className?: string) {\n return clsx(\n \"hds-chip\",\n // The button type has no type-specific styles, so it has no modifier class\n type !== \"button\" && `hds-chip--${type}`,\n { \"hds-chip--secondary\": variant === \"secondary\" },\n className as undefined,\n );\n}\n\n/**\n * One component per type of chip, `Chip` picks the right one\n */\n\nconst InputChip = forwardRef<HTMLInputElement, ChipRadioProps | ChipCheckboxProps>(\n function InputChip(\n { type, variant = \"primary\", className, style, children, ...inputProps },\n ref,\n ) {\n return (\n <label className={chipClassName(type, variant, className)} style={style}>\n <input {...inputProps} ref={ref} type={type} className=\"hds-chip__input\" />\n <span className=\"hds-chip__indicator\" aria-hidden=\"true\" />\n {children}\n </label>\n );\n },\n);\n\nconst RemovableChip = forwardRef<HTMLButtonElement, ChipRemovableProps>(function RemovableChip(\n {\n type,\n variant = \"primary\",\n className,\n onRemove,\n removeLabel = \"Fjern\",\n onClick,\n children,\n ...buttonProps\n },\n ref,\n) {\n // E.g. \"Fjern Oslo\". For other children than text the consumer must provide an `aria-label`\n const ariaLabel =\n typeof children === \"string\" || typeof children === \"number\"\n ? `${removeLabel} ${children}`\n : undefined;\n\n return (\n <button\n aria-label={ariaLabel}\n {...buttonProps}\n ref={ref}\n type=\"button\"\n className={chipClassName(type, variant, className)}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) onRemove?.(event);\n }}\n >\n {children}\n <span className=\"hds-chip__remove\" aria-hidden=\"true\" />\n </button>\n );\n});\n\nconst ButtonChip = forwardRef<HTMLButtonElement, ChipButtonProps>(function ButtonChip(\n { type, variant = \"primary\", className, asChild, ...buttonProps },\n ref,\n) {\n const classNames = chipClassName(type, variant, className);\n\n // With `asChild` the child decides the element, e.g. an anchor, so no `type=\"button\"`\n if (asChild) return <Slot {...buttonProps} ref={ref} className={classNames} />;\n\n return <button {...buttonProps} ref={ref} type=\"button\" className={classNames} />;\n});\n\nconst ToggleChip = forwardRef<HTMLButtonElement, ChipToggleProps>(function ToggleChip(\n {\n type,\n variant = \"primary\",\n className,\n icon,\n pressedIcon,\n pressed: pressedProp,\n defaultPressed = false,\n onPressedChange,\n onClick,\n children,\n ...buttonProps\n },\n ref,\n) {\n const [pressedState, setPressedState] = useState(defaultPressed);\n const isControlled = pressedProp !== undefined;\n const pressed = isControlled ? pressedProp : pressedState;\n\n return (\n <button\n {...buttonProps}\n ref={ref}\n type=\"button\"\n aria-pressed={pressed}\n className={chipClassName(type, variant, className)}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (!isControlled) setPressedState(!pressed);\n onPressedChange?.(!pressed);\n }}\n >\n <span className=\"hds-chip__icon\" aria-hidden=\"true\">\n {pressed && pressedIcon ? pressedIcon : icon}\n </span>\n {children}\n </button>\n );\n});\n\n/**\n * Gives `ref` the right element type for each chip type:\n * `HTMLInputElement` for radio and checkbox, `HTMLButtonElement` for the rest.\n */\ninterface ChipComponent {\n (\n props:\n | ((ChipRadioProps | ChipCheckboxProps) & { ref?: Ref<HTMLInputElement> })\n | ((ChipRemovableProps | ChipButtonProps | ChipToggleProps) & {\n ref?: Ref<HTMLButtonElement>;\n }),\n ): ReactElement | null;\n displayName?: string;\n}\n\n/**\n * Chips let the user select one or more options, toggle something, or remove an item.\n *\n * Choose the kind of chip with the `type` prop:\n * - `radio`: Select one among several options. Use the same `name` for the options.\n * - `checkbox`: Select one or more among several options.\n * - `removable`: Represents a selected value the user can remove.\n * - `button`: Triggers an action. Use `asChild` with an anchor for navigation.\n * - `toggle`: A pressable chip with an icon, e.g. to mark something as favorite.\n *\n * Note that the `type` prop is the chip type, not the native button `type`.\n * Buttons are always rendered with `type=\"button\"`.\n *\n * For `radio` and `checkbox` `className` and `style` are set on the root `label`,\n * all other props are set on the `input`.\n *\n * Wrap multiple chips in a `ChipGroup`.\n *\n * @example\n * <Chip type=\"radio\" name=\"weight\" value=\"0-2\">0-2 kg</Chip>\n * <Chip type=\"checkbox\" defaultChecked>Sporing</Chip>\n * <Chip type=\"removable\" onRemove={() => removeCity(\"oslo\")}>Oslo</Chip>\n * <Chip type=\"button\" onClick={openFilter}>Filter</Chip>\n * <Chip variant=\"secondary\" type=\"toggle\" icon={<StarOutline />} pressedIcon={<StarSolid />}>\n * Favoritt\n * </Chip>\n *\n * @example\n * // For navigation use `asChild` with an anchor element.\n * <Chip type=\"button\" asChild><a href=\"/tracking\">Sporing</a></Chip>\n */\nexport const Chip = forwardRef<HTMLInputElement | HTMLButtonElement, ChipProps>((props, ref) => {\n const inputRef = ref as Ref<HTMLInputElement>;\n const buttonRef = ref as Ref<HTMLButtonElement>;\n\n switch (props.type) {\n case \"radio\":\n case \"checkbox\":\n return <InputChip {...props} ref={inputRef} />;\n case \"removable\":\n return <RemovableChip {...props} ref={buttonRef} />;\n case \"button\":\n return <ButtonChip {...props} ref={buttonRef} />;\n case \"toggle\":\n return <ToggleChip {...props} ref={buttonRef} />;\n }\n}) as ChipComponent;\nChip.displayName = \"Chip\";\n"],"mappings":";;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAOK;AACP,SAAS,YAAY;AACrB,SAAS,YAAY;AA4Ff,SACE,KADF;AApBN,SAAS,cAAc,MAAyB,SAA+B,WAAoB;AACjG,SAAO;AAAA,IACL;AAAA;AAAA,IAEA,SAAS,YAAY,aAAa,IAAI;AAAA,IACtC,EAAE,uBAAuB,YAAY,YAAY;AAAA,IACjD;AAAA,EACF;AACF;AAMA,IAAM,YAAY;AAAA,EAChB,SAASA,WACP,IACA,KACA;AAFA,iBAAE,QAAM,UAAU,WAAW,WAAW,OAAO,SAnGnD,IAmGI,IAA4D,uBAA5D,IAA4D,CAA1D,QAAM,WAAqB,aAAW,SAAO;AAG/C,WACE,qBAAC,WAAM,WAAW,cAAc,MAAM,SAAS,SAAS,GAAG,OACzD;AAAA,0BAAC,0CAAU,aAAV,EAAsB,KAAU,MAAY,WAAU,oBAAkB;AAAA,MACzE,oBAAC,UAAK,WAAU,uBAAsB,eAAY,QAAO;AAAA,MACxD;AAAA,OACH;AAAA,EAEJ;AACF;AAEA,IAAM,gBAAgB,WAAkD,SAASC,eAC/E,IAUA,KACA;AAXA,eACE;AAAA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EAxHJ,IAiHE,IAQK,wBARL,IAQK;AAAA,IAPH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAMF,QAAM,YAC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ADL;AAAA,MAEC;AAAA,MACA,MAAK;AAAA,MACL,gBAAc;AAAA,MACd,WAAW,cAAc,MAAM,SAAS,SAAS;AAAA,MACjD,SAAS,CAAC,UAAU;AAClB,2CAAU;AACV,YAAI,MAAM,iBAAkB;AAC5B,YAAI,CAAC,aAAc,iBAAgB,CAAC,OAAO;AAC3C,2DAAkB,CAAC;AAAA,MACrB;AAAA,MAEA;AAAA,4BAAC,UAAK,WAAU,kBAAiB,eAAY,QAC1C,qBAAW,cAAc,cAAc,MAC1C;AAAA,QACC;AAAA;AAAA;AAAA,EACH;AAEJ,CAAC;AAgDM,IAAM,OAAO,WAA4D,CAAC,OAAO,QAAQ;AAC9F,QAAM,WAAW;AACjB,QAAM,YAAY;AAElB,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AACH,aAAO,oBAAC,4CAAc,QAAd,EAAqB,KAAK,WAAU;AAAA,IAC9C,KAAK;AACH,aAAO,oBAAC,gDAAkB,QAAlB,EAAyB,KAAK,YAAW;AAAA,IACnD,KAAK;AACH,aAAO,oBAAC,6CAAe,QAAf,EAAsB,KAAK,YAAW;AAAA,IAChD,KAAK;AACH,aAAO,oBAAC,6CAAe,QAAf,EAAsB,KAAK,YAAW;AAAA,EAClD;AACF,CAAC;AACD,KAAK,cAAc;","names":["InputChip","RemovableChip","ButtonChip","ToggleChip"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-PNYTWKKD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,32 @@
1
+ import {
2
+ __objRest,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-YOSPWY5K.mjs";
6
+
7
+ // src/chip/chip-group.tsx
8
+ import { forwardRef } from "react";
9
+ import { clsx } from "@postenbring/hedwig-css/typed-classname";
10
+ import { Slot } from "@radix-ui/react-slot";
11
+ import { jsx } from "react/jsx-runtime";
12
+ var ChipGroup = forwardRef(
13
+ (_a, ref) => {
14
+ var _b = _a, { layout = "wrap", asChild, className, children } = _b, rest = __objRest(_b, ["layout", "asChild", "className", "children"]);
15
+ const Component = asChild ? Slot : "div";
16
+ return /* @__PURE__ */ jsx(
17
+ Component,
18
+ __spreadProps(__spreadValues({
19
+ className: clsx("hds-chip-group", `hds-chip-group--${layout}`, className),
20
+ ref
21
+ }, rest), {
22
+ children
23
+ })
24
+ );
25
+ }
26
+ );
27
+ ChipGroup.displayName = "ChipGroup";
28
+
29
+ export {
30
+ ChipGroup
31
+ };
32
+ //# sourceMappingURL=chunk-VQPQ7RLE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/chip/chip-group.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface ChipGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * `inline`: A single row, scrolls horizontally when the chips do not fit.\n * `wrap`: Chips wrap onto multiple rows.\n *\n * @default \"wrap\"\n */\n layout?: \"inline\" | \"wrap\";\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * Groups multiple `Chip`s with correct spacing.\n *\n * @example\n * <ChipGroup layout=\"wrap\">\n * <Chip type=\"checkbox\">Sporing</Chip>\n * <Chip type=\"checkbox\">Hente i butikk</Chip>\n * </ChipGroup>\n */\nexport const ChipGroup = forwardRef<HTMLDivElement, ChipGroupProps>(\n ({ layout = \"wrap\", asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-chip-group\", `hds-chip-group--${layout}`, className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nChipGroup.displayName = \"ChipGroup\";\n"],"mappings":";;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,YAAY;AAgCf;AAJC,IAAM,YAAY;AAAA,EACvB,CAAC,IAA4D,QAAQ;AAApE,iBAAE,WAAS,QAAQ,SAAS,WAAW,SA/B1C,IA+BG,IAAoD,iBAApD,IAAoD,CAAlD,UAAiB,WAAS,aAAW;AACtC,UAAM,YAAY,UAAU,OAAO;AACnC,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,KAAK,kBAAkB,mBAAmB,MAAM,IAAI,SAAsB;AAAA,QACrF;AAAA,SACI,OAHL;AAAA,QAKE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,UAAU,cAAc;","names":[]}
@@ -5,9 +5,9 @@ import {
5
5
  ErrorSummaryList
6
6
  } from "../../chunk-PKEPSKTZ.mjs";
7
7
  import "../../chunk-CKAL5ZJZ.mjs";
8
+ import "../../chunk-6QV3OV66.mjs";
8
9
  import "../../chunk-XLLYMQLW.mjs";
9
10
  import "../../chunk-QE2ZES72.mjs";
10
- import "../../chunk-6QV3OV66.mjs";
11
11
  import "../../chunk-OS24UCTD.mjs";
12
12
  import "../../chunk-3QHKPEXO.mjs";
13
13
  import "../../chunk-BCFV6VOE.mjs";
@@ -3,9 +3,9 @@ import {
3
3
  ErrorSummary
4
4
  } from "../../chunk-PKEPSKTZ.mjs";
5
5
  import "../../chunk-CKAL5ZJZ.mjs";
6
+ import "../../chunk-6QV3OV66.mjs";
6
7
  import "../../chunk-XLLYMQLW.mjs";
7
8
  import "../../chunk-QE2ZES72.mjs";
8
- import "../../chunk-6QV3OV66.mjs";
9
9
  import "../../chunk-OS24UCTD.mjs";
10
10
  import "../../chunk-3QHKPEXO.mjs";
11
11
  import "../../chunk-BCFV6VOE.mjs";
@@ -1,8 +1,16 @@
1
1
  import "../chunk-5J5LYE6Z.mjs";
2
+ import "../chunk-AGZHQDCQ.mjs";
3
+ import {
4
+ Textarea
5
+ } from "../chunk-OQD4GKOS.mjs";
2
6
  import "../chunk-BYEJZSG5.mjs";
3
7
  import {
4
8
  Select
5
9
  } from "../chunk-JGQTAIEP.mjs";
10
+ import "../chunk-CAIGPMDS.mjs";
11
+ import {
12
+ SearchWrapper
13
+ } from "../chunk-RJ763KDH.mjs";
6
14
  import "../chunk-XSID7YR7.mjs";
7
15
  import {
8
16
  Suggestions
@@ -14,10 +22,10 @@ import {
14
22
  import {
15
23
  SuggestionsWrapper
16
24
  } from "../chunk-HA3LRSDK.mjs";
17
- import "../chunk-AGZHQDCQ.mjs";
25
+ import "../chunk-7LPYJC6S.mjs";
18
26
  import {
19
- Textarea
20
- } from "../chunk-OQD4GKOS.mjs";
27
+ Input
28
+ } from "../chunk-62VLFCXX.mjs";
21
29
  import "../chunk-XAFNJELJ.mjs";
22
30
  import {
23
31
  RadioButton
@@ -26,11 +34,12 @@ import {
26
34
  RadioGroup,
27
35
  useRadioGroupContext
28
36
  } from "../chunk-QER35NXN.mjs";
29
- import "../chunk-CAIGPMDS.mjs";
30
- import {
31
- SearchWrapper
32
- } from "../chunk-RJ763KDH.mjs";
37
+ import "../chunk-TDLSHJ4Z.mjs";
33
38
  import "../chunk-KPPLVGZ3.mjs";
39
+ import {
40
+ ErrorSummary
41
+ } from "../chunk-PKEPSKTZ.mjs";
42
+ import "../chunk-CKAL5ZJZ.mjs";
34
43
  import "../chunk-YJOOSTJC.mjs";
35
44
  import {
36
45
  Checkbox
@@ -46,11 +55,6 @@ import {
46
55
  import {
47
56
  FieldsetLegend
48
57
  } from "../chunk-CD4LCDK3.mjs";
49
- import "../chunk-7LPYJC6S.mjs";
50
- import {
51
- Input
52
- } from "../chunk-62VLFCXX.mjs";
53
- import "../chunk-TDLSHJ4Z.mjs";
54
58
  import {
55
59
  DatePicker
56
60
  } from "../chunk-RGZSYJFL.mjs";
@@ -64,13 +68,9 @@ import "../chunk-5M6MEYM7.mjs";
64
68
  import {
65
69
  ValidationMessage
66
70
  } from "../chunk-F23MNQCK.mjs";
67
- import {
68
- ErrorSummary
69
- } from "../chunk-PKEPSKTZ.mjs";
70
- import "../chunk-CKAL5ZJZ.mjs";
71
+ import "../chunk-6QV3OV66.mjs";
71
72
  import "../chunk-XLLYMQLW.mjs";
72
73
  import "../chunk-QE2ZES72.mjs";
73
- import "../chunk-6QV3OV66.mjs";
74
74
  import "../chunk-OS24UCTD.mjs";
75
75
  import "../chunk-3QHKPEXO.mjs";
76
76
  import "../chunk-BCFV6VOE.mjs";
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./breadcrumbs";
7
7
  export * from "./button";
8
8
  export * from "./button-list";
9
9
  export * from "./card";
10
+ export * from "./chip";
10
11
  export * from "./description-list";
11
12
  export * from "./figure";
12
13
  export * from "./form";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,c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