@revikornmann/muka-ui 0.30.0 → 0.31.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.
- package/dist/cjs/components/Chip/Chip.css +75 -23
- package/dist/cjs/components/Chip/Chip.js +18 -8
- package/dist/cjs/components/Chip/Chip.js.map +1 -1
- package/dist/esm/components/Chip/Chip.css +75 -23
- package/dist/esm/components/Chip/Chip.js +16 -8
- package/dist/esm/components/Chip/Chip.js.map +1 -1
- package/dist/styles/components/Chip.css +75 -23
- package/dist/styles/index.css +1053 -1001
- package/dist/styles/muka-dark.css +1053 -1001
- package/dist/styles/muka-light.css +1053 -1001
- package/dist/styles/wireframe-dark.css +1053 -1001
- package/dist/styles/wireframe-light.css +1053 -1001
- package/dist/types/components/Chip/Chip.d.ts +13 -3
- package/dist/types/components/Chip/Chip.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -58,13 +58,16 @@
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/* Tighter trailing padding when the dismiss button is present */
|
|
61
|
-
.muka-chip--sm.muka-chip--dismissible
|
|
61
|
+
.muka-chip--sm.muka-chip--dismissible,
|
|
62
|
+
.muka-chip--sm.muka-chip--expandable {
|
|
62
63
|
padding-right: var(--chip-padding-trailing-sm);
|
|
63
64
|
}
|
|
64
|
-
.muka-chip--md.muka-chip--dismissible
|
|
65
|
+
.muka-chip--md.muka-chip--dismissible,
|
|
66
|
+
.muka-chip--md.muka-chip--expandable {
|
|
65
67
|
padding-right: var(--chip-padding-trailing-md);
|
|
66
68
|
}
|
|
67
|
-
.muka-chip--lg.muka-chip--dismissible
|
|
69
|
+
.muka-chip--lg.muka-chip--dismissible,
|
|
70
|
+
.muka-chip--lg.muka-chip--expandable {
|
|
68
71
|
padding-right: var(--chip-padding-trailing-lg);
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -112,8 +115,9 @@
|
|
|
112
115
|
line-height: normal;
|
|
113
116
|
}
|
|
114
117
|
|
|
115
|
-
/*
|
|
116
|
-
.muka-chip__remove
|
|
118
|
+
/* Trailing button (dismiss or expand) — circular. Figma circle sizes: sm 20, md 24, lg 32 */
|
|
119
|
+
.muka-chip__remove,
|
|
120
|
+
.muka-chip__expand {
|
|
117
121
|
display: inline-flex;
|
|
118
122
|
align-items: center;
|
|
119
123
|
justify-content: center;
|
|
@@ -126,15 +130,18 @@
|
|
|
126
130
|
transition: background-color 0.15s ease, color 0.15s ease;
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
.muka-chip--sm .muka-chip__remove
|
|
133
|
+
.muka-chip--sm .muka-chip__remove,
|
|
134
|
+
.muka-chip--sm .muka-chip__expand {
|
|
130
135
|
width: var(--icon-size-sm);
|
|
131
136
|
height: var(--icon-size-sm);
|
|
132
137
|
}
|
|
133
|
-
.muka-chip--md .muka-chip__remove
|
|
138
|
+
.muka-chip--md .muka-chip__remove,
|
|
139
|
+
.muka-chip--md .muka-chip__expand {
|
|
134
140
|
width: var(--icon-size-default);
|
|
135
141
|
height: var(--icon-size-default);
|
|
136
142
|
}
|
|
137
|
-
.muka-chip--lg .muka-chip__remove
|
|
143
|
+
.muka-chip--lg .muka-chip__remove,
|
|
144
|
+
.muka-chip--lg .muka-chip__expand {
|
|
138
145
|
width: var(--icon-size-lg);
|
|
139
146
|
height: var(--icon-size-lg);
|
|
140
147
|
}
|
|
@@ -144,72 +151,117 @@
|
|
|
144
151
|
outline-offset: 2px;
|
|
145
152
|
}
|
|
146
153
|
|
|
154
|
+
/*
|
|
155
|
+
* Expandable chip (Figma "Chip/Trailing Expand"): the whole chip is one button,
|
|
156
|
+
* typically a menu trigger. Hovering or pressing anywhere on it drives the
|
|
157
|
+
* chevron's hover / pressed steps; an open menu (aria-expanded) shows pressed,
|
|
158
|
+
* like Button's open state.
|
|
159
|
+
*/
|
|
160
|
+
.muka-chip--expandable {
|
|
161
|
+
margin: 0;
|
|
162
|
+
text-align: inherit;
|
|
163
|
+
cursor: pointer;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.muka-chip--expandable:focus-visible {
|
|
167
|
+
outline: 2px solid var(--color-border-focus);
|
|
168
|
+
outline-offset: 2px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.muka-chip--expandable:disabled {
|
|
172
|
+
cursor: not-allowed;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.muka-chip__expand {
|
|
176
|
+
pointer-events: none;
|
|
177
|
+
}
|
|
178
|
+
|
|
147
179
|
/*
|
|
148
180
|
* Dismiss button colors — state-tinted per chip variant, with default / hover /
|
|
149
181
|
* pressed steps. Values come from T4 chip.dismiss.* tokens, which reference the
|
|
150
182
|
* brand-specific alias state-surface ramp. The ✕ (.muka-icon) inherits `color`.
|
|
151
183
|
*/
|
|
152
|
-
.muka-chip--default .muka-chip__remove
|
|
184
|
+
.muka-chip--default .muka-chip__remove,
|
|
185
|
+
.muka-chip--default .muka-chip__expand {
|
|
153
186
|
background-color: var(--chip-dismiss-default-background-default);
|
|
154
187
|
color: var(--chip-dismiss-default-foreground-default);
|
|
155
188
|
}
|
|
156
|
-
.muka-chip--default .muka-chip__remove:hover
|
|
189
|
+
.muka-chip--default .muka-chip__remove:hover,
|
|
190
|
+
.muka-chip--default.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
157
191
|
background-color: var(--chip-dismiss-default-background-hover);
|
|
158
192
|
color: var(--chip-dismiss-default-foreground-hover);
|
|
159
193
|
}
|
|
160
|
-
.muka-chip--default .muka-chip__remove:active
|
|
194
|
+
.muka-chip--default .muka-chip__remove:active,
|
|
195
|
+
.muka-chip--default.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
196
|
+
.muka-chip--default.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
161
197
|
background-color: var(--chip-dismiss-default-background-pressed);
|
|
162
198
|
color: var(--chip-dismiss-default-foreground-pressed);
|
|
163
199
|
}
|
|
164
200
|
|
|
165
|
-
.muka-chip--success .muka-chip__remove
|
|
201
|
+
.muka-chip--success .muka-chip__remove,
|
|
202
|
+
.muka-chip--success .muka-chip__expand {
|
|
166
203
|
background-color: var(--chip-dismiss-success-background-default);
|
|
167
204
|
color: var(--chip-dismiss-success-foreground-default);
|
|
168
205
|
}
|
|
169
|
-
.muka-chip--success .muka-chip__remove:hover
|
|
206
|
+
.muka-chip--success .muka-chip__remove:hover,
|
|
207
|
+
.muka-chip--success.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
170
208
|
background-color: var(--chip-dismiss-success-background-hover);
|
|
171
209
|
color: var(--chip-dismiss-success-foreground-hover);
|
|
172
210
|
}
|
|
173
|
-
.muka-chip--success .muka-chip__remove:active
|
|
211
|
+
.muka-chip--success .muka-chip__remove:active,
|
|
212
|
+
.muka-chip--success.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
213
|
+
.muka-chip--success.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
174
214
|
background-color: var(--chip-dismiss-success-background-pressed);
|
|
175
215
|
color: var(--chip-dismiss-success-foreground-pressed);
|
|
176
216
|
}
|
|
177
217
|
|
|
178
|
-
.muka-chip--warning .muka-chip__remove
|
|
218
|
+
.muka-chip--warning .muka-chip__remove,
|
|
219
|
+
.muka-chip--warning .muka-chip__expand {
|
|
179
220
|
background-color: var(--chip-dismiss-warning-background-default);
|
|
180
221
|
color: var(--chip-dismiss-warning-foreground-default);
|
|
181
222
|
}
|
|
182
|
-
.muka-chip--warning .muka-chip__remove:hover
|
|
223
|
+
.muka-chip--warning .muka-chip__remove:hover,
|
|
224
|
+
.muka-chip--warning.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
183
225
|
background-color: var(--chip-dismiss-warning-background-hover);
|
|
184
226
|
color: var(--chip-dismiss-warning-foreground-hover);
|
|
185
227
|
}
|
|
186
|
-
.muka-chip--warning .muka-chip__remove:active
|
|
228
|
+
.muka-chip--warning .muka-chip__remove:active,
|
|
229
|
+
.muka-chip--warning.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
230
|
+
.muka-chip--warning.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
187
231
|
background-color: var(--chip-dismiss-warning-background-pressed);
|
|
188
232
|
color: var(--chip-dismiss-warning-foreground-pressed);
|
|
189
233
|
}
|
|
190
234
|
|
|
191
|
-
.muka-chip--error .muka-chip__remove
|
|
235
|
+
.muka-chip--error .muka-chip__remove,
|
|
236
|
+
.muka-chip--error .muka-chip__expand {
|
|
192
237
|
background-color: var(--chip-dismiss-error-background-default);
|
|
193
238
|
color: var(--chip-dismiss-error-foreground-default);
|
|
194
239
|
}
|
|
195
|
-
.muka-chip--error .muka-chip__remove:hover
|
|
240
|
+
.muka-chip--error .muka-chip__remove:hover,
|
|
241
|
+
.muka-chip--error.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
196
242
|
background-color: var(--chip-dismiss-error-background-hover);
|
|
197
243
|
color: var(--chip-dismiss-error-foreground-hover);
|
|
198
244
|
}
|
|
199
|
-
.muka-chip--error .muka-chip__remove:active
|
|
245
|
+
.muka-chip--error .muka-chip__remove:active,
|
|
246
|
+
.muka-chip--error.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
247
|
+
.muka-chip--error.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
200
248
|
background-color: var(--chip-dismiss-error-background-pressed);
|
|
201
249
|
color: var(--chip-dismiss-error-foreground-pressed);
|
|
202
250
|
}
|
|
203
251
|
|
|
204
|
-
.muka-chip--info .muka-chip__remove
|
|
252
|
+
.muka-chip--info .muka-chip__remove,
|
|
253
|
+
.muka-chip--info .muka-chip__expand {
|
|
205
254
|
background-color: var(--chip-dismiss-info-background-default);
|
|
206
255
|
color: var(--chip-dismiss-info-foreground-default);
|
|
207
256
|
}
|
|
208
|
-
.muka-chip--info .muka-chip__remove:hover
|
|
257
|
+
.muka-chip--info .muka-chip__remove:hover,
|
|
258
|
+
.muka-chip--info.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
209
259
|
background-color: var(--chip-dismiss-info-background-hover);
|
|
210
260
|
color: var(--chip-dismiss-info-foreground-hover);
|
|
211
261
|
}
|
|
212
|
-
.muka-chip--info .muka-chip__remove:active
|
|
262
|
+
.muka-chip--info .muka-chip__remove:active,
|
|
263
|
+
.muka-chip--info.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
264
|
+
.muka-chip--info.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
213
265
|
background-color: var(--chip-dismiss-info-background-pressed);
|
|
214
266
|
color: var(--chip-dismiss-info-foreground-pressed);
|
|
215
267
|
}
|
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Chip = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
5
9
|
require("./Chip.css");
|
|
6
10
|
const Icon_1 = require("../Icon");
|
|
7
11
|
/**
|
|
8
12
|
* Chip Component
|
|
9
13
|
*
|
|
10
14
|
* Compact pill-shaped control for labels, tags, and removable selections.
|
|
11
|
-
* Matches Muka Figma Chip: optional icon, label, optional
|
|
15
|
+
* Matches Muka Figma Chip: optional icon, label, and an optional trailing
|
|
16
|
+
* button: dismiss (`onRemove`) or expand (`expandable`).
|
|
12
17
|
*
|
|
13
18
|
* Variants: default (gray), success, warning, error, info
|
|
14
19
|
*/
|
|
15
|
-
|
|
20
|
+
exports.Chip = react_1.default.forwardRef(function Chip({ children, variant = 'default', size = 'sm', icon, onRemove, expandable = false, disabled, className = '', 'aria-label': ariaLabel, removeButtonLabel = 'Remove', ...props }, ref) {
|
|
21
|
+
const dismissible = Boolean(onRemove) && !expandable;
|
|
16
22
|
const chipClasses = [
|
|
17
23
|
'muka-chip',
|
|
18
24
|
`muka-chip--${variant}`,
|
|
19
25
|
`muka-chip--${size}`,
|
|
20
26
|
icon && 'muka-chip--has-icon',
|
|
21
|
-
|
|
27
|
+
dismissible && 'muka-chip--dismissible',
|
|
28
|
+
expandable && 'muka-chip--expandable',
|
|
22
29
|
className,
|
|
23
30
|
].filter(Boolean).join(' ');
|
|
24
|
-
//
|
|
25
|
-
const
|
|
31
|
+
// Trailing glyph tracks the chip size (Figma: sm 16, md 20, lg 24)
|
|
32
|
+
const trailingIconSize = { sm: 'xs', md: 'sm', lg: 'md' }[size];
|
|
26
33
|
const handleRemoveClick = (e) => {
|
|
27
34
|
e.preventDefault();
|
|
28
35
|
e.stopPropagation();
|
|
29
36
|
onRemove?.(e);
|
|
30
37
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon && (0, jsx_runtime_1.jsx)("span", { className: "muka-chip__icon", "aria-hidden": "true", children: icon }), (0, jsx_runtime_1.jsx)("span", { className: "muka-chip__label", children: children })] }));
|
|
39
|
+
if (expandable) {
|
|
40
|
+
return ((0, jsx_runtime_1.jsxs)("button", { ref: ref, type: "button", className: chipClasses, "aria-label": ariaLabel, disabled: disabled, ...props, children: [content, (0, jsx_runtime_1.jsx)("span", { className: "muka-chip__expand", "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "arrow-down-s", variant: "line", size: trailingIconSize }) })] }));
|
|
41
|
+
}
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)("span", { ref: ref, className: chipClasses, role: dismissible ? undefined : 'status', "aria-label": ariaLabel, ...props, children: [content, dismissible && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "muka-chip__remove", onClick: handleRemoveClick, "aria-label": removeButtonLabel, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "close", variant: "line", size: trailingIconSize }) }))] }));
|
|
43
|
+
});
|
|
34
44
|
exports.default = exports.Chip;
|
|
35
45
|
//# sourceMappingURL=Chip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../../components/Chip/Chip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../../components/Chip/Chip.tsx"],"names":[],"mappings":";;;;;;;AAAA,kDAA0B;AAC1B,sBAAoB;AACpB,kCAA+B;AAwC/B;;;;;;;;GAQG;AACU,QAAA,IAAI,GAAG,eAAK,CAAC,UAAU,CAAyB,SAAS,IAAI,CACxE,EACE,QAAQ,EACR,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,IAAI,EACJ,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,YAAY,EAAE,SAAS,EACvB,iBAAiB,GAAG,QAAQ,EAC5B,GAAG,KAAK,EACT,EACD,GAAG;IAEH,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;IAErD,MAAM,WAAW,GAAG;QAClB,WAAW;QACX,cAAc,OAAO,EAAE;QACvB,cAAc,IAAI,EAAE;QACpB,IAAI,IAAI,qBAAqB;QAC7B,WAAW,IAAI,wBAAwB;QACvC,UAAU,IAAI,uBAAuB;QACrC,SAAS;KACV,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE5B,mEAAmE;IACnE,MAAM,gBAAgB,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,CAAuB,CAAC;IAEtF,MAAM,iBAAiB,GAAG,CAAC,CAAmB,EAAE,EAAE;QAChD,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,CAAC,CA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|
+
.muka-chip--sm.muka-chip--dismissible,
|
|
62
|
+
.muka-chip--sm.muka-chip--expandable {
|
|
62
63
|
padding-right: var(--chip-padding-trailing-sm);
|
|
63
64
|
}
|
|
64
|
-
.muka-chip--md.muka-chip--dismissible
|
|
65
|
+
.muka-chip--md.muka-chip--dismissible,
|
|
66
|
+
.muka-chip--md.muka-chip--expandable {
|
|
65
67
|
padding-right: var(--chip-padding-trailing-md);
|
|
66
68
|
}
|
|
67
|
-
.muka-chip--lg.muka-chip--dismissible
|
|
69
|
+
.muka-chip--lg.muka-chip--dismissible,
|
|
70
|
+
.muka-chip--lg.muka-chip--expandable {
|
|
68
71
|
padding-right: var(--chip-padding-trailing-lg);
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -112,8 +115,9 @@
|
|
|
112
115
|
line-height: normal;
|
|
113
116
|
}
|
|
114
117
|
|
|
115
|
-
/*
|
|
116
|
-
.muka-chip__remove
|
|
118
|
+
/* Trailing button (dismiss or expand) — circular. Figma circle sizes: sm 20, md 24, lg 32 */
|
|
119
|
+
.muka-chip__remove,
|
|
120
|
+
.muka-chip__expand {
|
|
117
121
|
display: inline-flex;
|
|
118
122
|
align-items: center;
|
|
119
123
|
justify-content: center;
|
|
@@ -126,15 +130,18 @@
|
|
|
126
130
|
transition: background-color 0.15s ease, color 0.15s ease;
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
.muka-chip--sm .muka-chip__remove
|
|
133
|
+
.muka-chip--sm .muka-chip__remove,
|
|
134
|
+
.muka-chip--sm .muka-chip__expand {
|
|
130
135
|
width: var(--icon-size-sm);
|
|
131
136
|
height: var(--icon-size-sm);
|
|
132
137
|
}
|
|
133
|
-
.muka-chip--md .muka-chip__remove
|
|
138
|
+
.muka-chip--md .muka-chip__remove,
|
|
139
|
+
.muka-chip--md .muka-chip__expand {
|
|
134
140
|
width: var(--icon-size-default);
|
|
135
141
|
height: var(--icon-size-default);
|
|
136
142
|
}
|
|
137
|
-
.muka-chip--lg .muka-chip__remove
|
|
143
|
+
.muka-chip--lg .muka-chip__remove,
|
|
144
|
+
.muka-chip--lg .muka-chip__expand {
|
|
138
145
|
width: var(--icon-size-lg);
|
|
139
146
|
height: var(--icon-size-lg);
|
|
140
147
|
}
|
|
@@ -144,72 +151,117 @@
|
|
|
144
151
|
outline-offset: 2px;
|
|
145
152
|
}
|
|
146
153
|
|
|
154
|
+
/*
|
|
155
|
+
* Expandable chip (Figma "Chip/Trailing Expand"): the whole chip is one button,
|
|
156
|
+
* typically a menu trigger. Hovering or pressing anywhere on it drives the
|
|
157
|
+
* chevron's hover / pressed steps; an open menu (aria-expanded) shows pressed,
|
|
158
|
+
* like Button's open state.
|
|
159
|
+
*/
|
|
160
|
+
.muka-chip--expandable {
|
|
161
|
+
margin: 0;
|
|
162
|
+
text-align: inherit;
|
|
163
|
+
cursor: pointer;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.muka-chip--expandable:focus-visible {
|
|
167
|
+
outline: 2px solid var(--color-border-focus);
|
|
168
|
+
outline-offset: 2px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.muka-chip--expandable:disabled {
|
|
172
|
+
cursor: not-allowed;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.muka-chip__expand {
|
|
176
|
+
pointer-events: none;
|
|
177
|
+
}
|
|
178
|
+
|
|
147
179
|
/*
|
|
148
180
|
* Dismiss button colors — state-tinted per chip variant, with default / hover /
|
|
149
181
|
* pressed steps. Values come from T4 chip.dismiss.* tokens, which reference the
|
|
150
182
|
* brand-specific alias state-surface ramp. The ✕ (.muka-icon) inherits `color`.
|
|
151
183
|
*/
|
|
152
|
-
.muka-chip--default .muka-chip__remove
|
|
184
|
+
.muka-chip--default .muka-chip__remove,
|
|
185
|
+
.muka-chip--default .muka-chip__expand {
|
|
153
186
|
background-color: var(--chip-dismiss-default-background-default);
|
|
154
187
|
color: var(--chip-dismiss-default-foreground-default);
|
|
155
188
|
}
|
|
156
|
-
.muka-chip--default .muka-chip__remove:hover
|
|
189
|
+
.muka-chip--default .muka-chip__remove:hover,
|
|
190
|
+
.muka-chip--default.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
157
191
|
background-color: var(--chip-dismiss-default-background-hover);
|
|
158
192
|
color: var(--chip-dismiss-default-foreground-hover);
|
|
159
193
|
}
|
|
160
|
-
.muka-chip--default .muka-chip__remove:active
|
|
194
|
+
.muka-chip--default .muka-chip__remove:active,
|
|
195
|
+
.muka-chip--default.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
196
|
+
.muka-chip--default.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
161
197
|
background-color: var(--chip-dismiss-default-background-pressed);
|
|
162
198
|
color: var(--chip-dismiss-default-foreground-pressed);
|
|
163
199
|
}
|
|
164
200
|
|
|
165
|
-
.muka-chip--success .muka-chip__remove
|
|
201
|
+
.muka-chip--success .muka-chip__remove,
|
|
202
|
+
.muka-chip--success .muka-chip__expand {
|
|
166
203
|
background-color: var(--chip-dismiss-success-background-default);
|
|
167
204
|
color: var(--chip-dismiss-success-foreground-default);
|
|
168
205
|
}
|
|
169
|
-
.muka-chip--success .muka-chip__remove:hover
|
|
206
|
+
.muka-chip--success .muka-chip__remove:hover,
|
|
207
|
+
.muka-chip--success.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
170
208
|
background-color: var(--chip-dismiss-success-background-hover);
|
|
171
209
|
color: var(--chip-dismiss-success-foreground-hover);
|
|
172
210
|
}
|
|
173
|
-
.muka-chip--success .muka-chip__remove:active
|
|
211
|
+
.muka-chip--success .muka-chip__remove:active,
|
|
212
|
+
.muka-chip--success.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
213
|
+
.muka-chip--success.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
174
214
|
background-color: var(--chip-dismiss-success-background-pressed);
|
|
175
215
|
color: var(--chip-dismiss-success-foreground-pressed);
|
|
176
216
|
}
|
|
177
217
|
|
|
178
|
-
.muka-chip--warning .muka-chip__remove
|
|
218
|
+
.muka-chip--warning .muka-chip__remove,
|
|
219
|
+
.muka-chip--warning .muka-chip__expand {
|
|
179
220
|
background-color: var(--chip-dismiss-warning-background-default);
|
|
180
221
|
color: var(--chip-dismiss-warning-foreground-default);
|
|
181
222
|
}
|
|
182
|
-
.muka-chip--warning .muka-chip__remove:hover
|
|
223
|
+
.muka-chip--warning .muka-chip__remove:hover,
|
|
224
|
+
.muka-chip--warning.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
183
225
|
background-color: var(--chip-dismiss-warning-background-hover);
|
|
184
226
|
color: var(--chip-dismiss-warning-foreground-hover);
|
|
185
227
|
}
|
|
186
|
-
.muka-chip--warning .muka-chip__remove:active
|
|
228
|
+
.muka-chip--warning .muka-chip__remove:active,
|
|
229
|
+
.muka-chip--warning.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
230
|
+
.muka-chip--warning.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
187
231
|
background-color: var(--chip-dismiss-warning-background-pressed);
|
|
188
232
|
color: var(--chip-dismiss-warning-foreground-pressed);
|
|
189
233
|
}
|
|
190
234
|
|
|
191
|
-
.muka-chip--error .muka-chip__remove
|
|
235
|
+
.muka-chip--error .muka-chip__remove,
|
|
236
|
+
.muka-chip--error .muka-chip__expand {
|
|
192
237
|
background-color: var(--chip-dismiss-error-background-default);
|
|
193
238
|
color: var(--chip-dismiss-error-foreground-default);
|
|
194
239
|
}
|
|
195
|
-
.muka-chip--error .muka-chip__remove:hover
|
|
240
|
+
.muka-chip--error .muka-chip__remove:hover,
|
|
241
|
+
.muka-chip--error.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
196
242
|
background-color: var(--chip-dismiss-error-background-hover);
|
|
197
243
|
color: var(--chip-dismiss-error-foreground-hover);
|
|
198
244
|
}
|
|
199
|
-
.muka-chip--error .muka-chip__remove:active
|
|
245
|
+
.muka-chip--error .muka-chip__remove:active,
|
|
246
|
+
.muka-chip--error.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
247
|
+
.muka-chip--error.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
200
248
|
background-color: var(--chip-dismiss-error-background-pressed);
|
|
201
249
|
color: var(--chip-dismiss-error-foreground-pressed);
|
|
202
250
|
}
|
|
203
251
|
|
|
204
|
-
.muka-chip--info .muka-chip__remove
|
|
252
|
+
.muka-chip--info .muka-chip__remove,
|
|
253
|
+
.muka-chip--info .muka-chip__expand {
|
|
205
254
|
background-color: var(--chip-dismiss-info-background-default);
|
|
206
255
|
color: var(--chip-dismiss-info-foreground-default);
|
|
207
256
|
}
|
|
208
|
-
.muka-chip--info .muka-chip__remove:hover
|
|
257
|
+
.muka-chip--info .muka-chip__remove:hover,
|
|
258
|
+
.muka-chip--info.muka-chip--expandable:hover:not(:disabled) .muka-chip__expand {
|
|
209
259
|
background-color: var(--chip-dismiss-info-background-hover);
|
|
210
260
|
color: var(--chip-dismiss-info-foreground-hover);
|
|
211
261
|
}
|
|
212
|
-
.muka-chip--info .muka-chip__remove:active
|
|
262
|
+
.muka-chip--info .muka-chip__remove:active,
|
|
263
|
+
.muka-chip--info.muka-chip--expandable:active:not(:disabled) .muka-chip__expand,
|
|
264
|
+
.muka-chip--info.muka-chip--expandable[aria-expanded='true'] .muka-chip__expand {
|
|
213
265
|
background-color: var(--chip-dismiss-info-background-pressed);
|
|
214
266
|
color: var(--chip-dismiss-info-foreground-pressed);
|
|
215
267
|
}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import './Chip.css';
|
|
3
4
|
import { Icon } from '../Icon';
|
|
4
5
|
/**
|
|
5
6
|
* Chip Component
|
|
6
7
|
*
|
|
7
8
|
* Compact pill-shaped control for labels, tags, and removable selections.
|
|
8
|
-
* Matches Muka Figma Chip: optional icon, label, optional
|
|
9
|
+
* Matches Muka Figma Chip: optional icon, label, and an optional trailing
|
|
10
|
+
* button: dismiss (`onRemove`) or expand (`expandable`).
|
|
9
11
|
*
|
|
10
12
|
* Variants: default (gray), success, warning, error, info
|
|
11
13
|
*/
|
|
12
|
-
export const Chip = ({ children, variant = 'default', size = 'sm', icon, onRemove, className = '', 'aria-label': ariaLabel, removeButtonLabel = 'Remove', ...props })
|
|
14
|
+
export const Chip = React.forwardRef(function Chip({ children, variant = 'default', size = 'sm', icon, onRemove, expandable = false, disabled, className = '', 'aria-label': ariaLabel, removeButtonLabel = 'Remove', ...props }, ref) {
|
|
15
|
+
const dismissible = Boolean(onRemove) && !expandable;
|
|
13
16
|
const chipClasses = [
|
|
14
17
|
'muka-chip',
|
|
15
18
|
`muka-chip--${variant}`,
|
|
16
19
|
`muka-chip--${size}`,
|
|
17
20
|
icon && 'muka-chip--has-icon',
|
|
18
|
-
|
|
21
|
+
dismissible && 'muka-chip--dismissible',
|
|
22
|
+
expandable && 'muka-chip--expandable',
|
|
19
23
|
className,
|
|
20
24
|
].filter(Boolean).join(' ');
|
|
21
|
-
//
|
|
22
|
-
const
|
|
25
|
+
// Trailing glyph tracks the chip size (Figma: sm 16, md 20, lg 24)
|
|
26
|
+
const trailingIconSize = { sm: 'xs', md: 'sm', lg: 'md' }[size];
|
|
23
27
|
const handleRemoveClick = (e) => {
|
|
24
28
|
e.preventDefault();
|
|
25
29
|
e.stopPropagation();
|
|
26
30
|
onRemove?.(e);
|
|
27
31
|
};
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
const content = (_jsxs(_Fragment, { children: [icon && _jsx("span", { className: "muka-chip__icon", "aria-hidden": "true", children: icon }), _jsx("span", { className: "muka-chip__label", children: children })] }));
|
|
33
|
+
if (expandable) {
|
|
34
|
+
return (_jsxs("button", { ref: ref, type: "button", className: chipClasses, "aria-label": ariaLabel, disabled: disabled, ...props, children: [content, _jsx("span", { className: "muka-chip__expand", "aria-hidden": "true", children: _jsx(Icon, { name: "arrow-down-s", variant: "line", size: trailingIconSize }) })] }));
|
|
35
|
+
}
|
|
36
|
+
return (_jsxs("span", { ref: ref, className: chipClasses, role: dismissible ? undefined : 'status', "aria-label": ariaLabel, ...props, children: [content, dismissible && (_jsx("button", { type: "button", className: "muka-chip__remove", onClick: handleRemoveClick, "aria-label": removeButtonLabel, children: _jsx(Icon, { name: "close", variant: "line", size: trailingIconSize }) }))] }));
|
|
37
|
+
});
|
|
30
38
|
export default Chip;
|
|
31
39
|
//# sourceMappingURL=Chip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../../components/Chip/Chip.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../../components/Chip/Chip.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAwC/B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAyB,SAAS,IAAI,CACxE,EACE,QAAQ,EACR,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,IAAI,EACJ,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,YAAY,EAAE,SAAS,EACvB,iBAAiB,GAAG,QAAQ,EAC5B,GAAG,KAAK,EACT,EACD,GAAG;IAEH,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;IAErD,MAAM,WAAW,GAAG;QAClB,WAAW;QACX,cAAc,OAAO,EAAE;QACvB,cAAc,IAAI,EAAE;QACpB,IAAI,IAAI,qBAAqB;QAC7B,WAAW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