@rcarls/rc-chip 0.6.0 → 0.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.
- package/CHANGELOG.md +85 -0
- package/README.md +6 -0
- package/dist/custom-elements.json +11 -1
- package/dist/rc-chip-D2kF8iCM.js +185 -0
- package/dist/rc-chip-D2kF8iCM.js.map +1 -0
- package/dist/rc-chip-define.js +1 -1
- package/dist/rc-chip.js +1 -1
- package/dist/types/packages/rc-chip/src/rc-chip.d.ts +6 -2
- package/package.json +4 -1
- package/dist/rc-chip-B71-Icgf.js +0 -440
- package/dist/rc-chip-B71-Icgf.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
# @rcarls/rc-chip
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 079e025: Standardize component styling contracts for the breaking 0.7 release.
|
|
8
|
+
|
|
9
|
+
BREAKING CHANGE: Rename the Markdown editor's `--rme-*` properties to
|
|
10
|
+
`--rc-markdown-editor-*`, `--rc-app-bar-background` to `--rc-app-bar-bg`,
|
|
11
|
+
`--rc-textarea-radius` to `--rc-textarea-border-radius`, the transfer-list
|
|
12
|
+
`--rc-transfer-list-panel-*` properties to `--rc-transfer-list-listbox-*`,
|
|
13
|
+
`--rc-chip-group-webkit-scrollbar-display` to
|
|
14
|
+
`--rc-chip-group-scrollbar-display`, and `--rc-text` to `--rc-field-text`.
|
|
15
|
+
Compatibility aliases are intentionally not provided.
|
|
16
|
+
|
|
17
|
+
BREAKING CHANGE: Replace `--rc-select-chip-padding-inline` and
|
|
18
|
+
`--rc-combobox-chip-padding-inline` with explicit `*-padding-inline-start` and
|
|
19
|
+
`*-padding-inline-end` tokens. Generated removable chips now reserve the full
|
|
20
|
+
remove target and its edge offset, so their indicator cannot overlap label text.
|
|
21
|
+
|
|
22
|
+
Add canonical app-bar elevation, transfer-list listbox radius, and textarea
|
|
23
|
+
line-action tokens. Add logical `rc-chip` inline-padding properties so themes
|
|
24
|
+
can implement Material's icon-aware spacing without overriding authored child
|
|
25
|
+
styles. Make `rc-field` consume the shared semantic token layer,
|
|
26
|
+
and place the `rc-chip` and `rc-search-bar` light-DOM structural styles in the
|
|
27
|
+
`rc-base` cascade layer so normal consumer rules override them.
|
|
28
|
+
|
|
29
|
+
Prevent decorative, `aria-hidden` trailing list content from intercepting a
|
|
30
|
+
whole-row action target, and keep segmented-list item geometry from leaking
|
|
31
|
+
into nested standard lists.
|
|
32
|
+
|
|
33
|
+
Remove unused Material navigation-rail toggle tokens and obsolete list-item
|
|
34
|
+
theme tokens. Register the segmented-button private theme seam and enforce
|
|
35
|
+
token ownership, documentation, removed-name, selector-budget, and cascade
|
|
36
|
+
layer contracts through the component architecture audit.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 3d050f1: Keep wrapped chip rows evenly spaced. Readonly chips in an `rc-chip-group`
|
|
41
|
+
keep the touch-target block size, so expanded rows share the disclosure
|
|
42
|
+
toggle's pitch. `rc-combobox` and `rc-select` return the chip touch-target
|
|
43
|
+
overlap tokens as row gap, so interior chip rows no longer collapse onto each
|
|
44
|
+
other inside a field. Material combobox and select input chips drop their
|
|
45
|
+
extra block padding to render at the 2rem chip height.
|
|
46
|
+
- 5c006de: Ship component CSS minified. Package builds now run the CSS in Lit `css` styles
|
|
47
|
+
and light-DOM structural styles through Lightning CSS, removing comments and
|
|
48
|
+
whitespace while keeping source maps that resolve to each template. Rendered
|
|
49
|
+
styles are unchanged.
|
|
50
|
+
|
|
51
|
+
`@rcarls/rc-common` adds `cssText`, an identity tag that marks a plain CSS
|
|
52
|
+
string for minification. `rc-chip`, `rc-disclosure`, and `rc-accordion` now
|
|
53
|
+
depend on `@rcarls/rc-common` for it.
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [e3dfa59]
|
|
56
|
+
- Updated dependencies [50d5610]
|
|
57
|
+
- Updated dependencies [9ee769c]
|
|
58
|
+
- Updated dependencies [1179f24]
|
|
59
|
+
- Updated dependencies [595fe37]
|
|
60
|
+
- Updated dependencies [38cd00c]
|
|
61
|
+
- Updated dependencies [5c006de]
|
|
62
|
+
- Updated dependencies [a6553ff]
|
|
63
|
+
- Updated dependencies [2205478]
|
|
64
|
+
- Updated dependencies [4341311]
|
|
65
|
+
- Updated dependencies [899bb5e]
|
|
66
|
+
- Updated dependencies [25fcfe0]
|
|
67
|
+
- Updated dependencies [51f6403]
|
|
68
|
+
- Updated dependencies [9caca6b]
|
|
69
|
+
- Updated dependencies [b764a3c]
|
|
70
|
+
- Updated dependencies [54d9ead]
|
|
71
|
+
- Updated dependencies [b9175e9]
|
|
72
|
+
- Updated dependencies [c8b762b]
|
|
73
|
+
- Updated dependencies [55e1e7f]
|
|
74
|
+
- Updated dependencies [f1ca82d]
|
|
75
|
+
- Updated dependencies [b87f27b]
|
|
76
|
+
- Updated dependencies [32ebead]
|
|
77
|
+
- Updated dependencies [bfefedd]
|
|
78
|
+
- Updated dependencies [c130173]
|
|
79
|
+
- Updated dependencies [11680b6]
|
|
80
|
+
- Updated dependencies [223d36c]
|
|
81
|
+
- Updated dependencies [7b91a44]
|
|
82
|
+
- Updated dependencies [aa04ead]
|
|
83
|
+
- Updated dependencies [ac65b5b]
|
|
84
|
+
- Updated dependencies [afcfef8]
|
|
85
|
+
- Updated dependencies [11ef1ad]
|
|
86
|
+
- @rcarls/rc-common@0.7.0
|
|
87
|
+
|
|
3
88
|
## 0.6.0
|
|
4
89
|
|
|
5
90
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -11,6 +11,12 @@ Chip wrapper for native actions, links, filters, and inputs.
|
|
|
11
11
|
The native button remains connected for keyboard behavior and progressive enhancement.
|
|
12
12
|
Native tap highlighting is suppressed because the component's clipped state layer
|
|
13
13
|
provides hover, focus, and pressed feedback within the chip shape.
|
|
14
|
+
Structural styles for the native child are installed in the `rc-base` cascade
|
|
15
|
+
layer, so normal author rules outside a layer remain the final styling authority.
|
|
16
|
+
|
|
17
|
+
Themes may use `--rc-chip-padding-inline-start` and
|
|
18
|
+
`--rc-chip-padding-inline-end` for icon-aware logical padding. Both fall back
|
|
19
|
+
to `--rc-chip-padding-inline`, so existing symmetric padding remains compatible.
|
|
14
20
|
|
|
15
21
|
Navigation chips preserve the same native-link behavior:
|
|
16
22
|
|
|
@@ -97,6 +97,16 @@
|
|
|
97
97
|
"description": "Inline-axis padding of the slotted button, anchor, or label (defers to native padding when unset).",
|
|
98
98
|
"name": "--rc-chip-padding-inline"
|
|
99
99
|
},
|
|
100
|
+
{
|
|
101
|
+
"description": "Logical leading padding of the slotted button, anchor, or label.",
|
|
102
|
+
"name": "--rc-chip-padding-inline-start",
|
|
103
|
+
"default": "var(--rc-chip-padding-inline)"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"description": "Logical trailing padding of the slotted button, anchor, or label.",
|
|
107
|
+
"name": "--rc-chip-padding-inline-end",
|
|
108
|
+
"default": "var(--rc-chip-padding-inline)"
|
|
109
|
+
},
|
|
100
110
|
{
|
|
101
111
|
"description": "Border of the slotted button, anchor, or label (defers to native border when unset).",
|
|
102
112
|
"name": "--rc-chip-border"
|
|
@@ -203,7 +213,7 @@
|
|
|
203
213
|
{
|
|
204
214
|
"description": "Override for removable chip content end padding.",
|
|
205
215
|
"name": "--rc-chip-removable-padding-inline-end",
|
|
206
|
-
"default": "calc(var(--rc-chip-remove-target-size, 1.5rem)
|
|
216
|
+
"default": "calc(var(--rc-chip-remove-target-size, 1.5rem) + var(--rc-chip-remove-offset-inline, 0.125rem))"
|
|
207
217
|
}
|
|
208
218
|
],
|
|
209
219
|
"cssParts": [
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { css as p, LitElement as u, html as h } from "lit";
|
|
2
|
+
import { property as l } from "lit/decorators.js";
|
|
3
|
+
import { cssText as b } from "@rcarls/rc-common";
|
|
4
|
+
const v = p`:host{min-block-size:var(--rc-chip-touch-target-block-size,3rem);color-scheme:inherit;vertical-align:middle;place-items:center;margin-block-start:calc(-1 * var(--rc-chip-touch-target-overlap-block-start,0px));margin-block-end:calc(-1 * var(--rc-chip-touch-target-overlap-block-end,0px));display:inline-grid;position:relative}:host([readonly]){min-block-size:var(--_rc-chip-group-readonly-min-block-size,var(--rc-chip-block-size,auto))}:host([hidden]){display:none}::slotted(button),::slotted(a),::slotted(label),::slotted([data-rc-chip-label]){justify-content:center;align-items:center;gap:var(--rc-chip-gap,0px);min-block-size:var(--rc-chip-block-size);padding-block:var(--rc-chip-padding-block,revert);border:var(--rc-chip-border,revert);border-radius:var(--rc-chip-radius,revert);background:var(--rc-chip-bg,revert);color:var(--rc-chip-color,revert);font:var(--rc-chip-font,revert);text-decoration:var(--rc-chip-text-decoration,revert);white-space:nowrap;-webkit-tap-highlight-color:transparent;padding-inline-start:var(--rc-chip-padding-inline-start,var(--rc-chip-padding-inline,revert));padding-inline-end:var(--rc-chip-padding-inline-end,var(--rc-chip-padding-inline,revert));display:inline-flex}:host([selected]) ::slotted(button),:host([selected]) ::slotted(a),:host([selected]) ::slotted(label),:host([selected]) ::slotted([data-rc-chip-label]){border-color:var(--rc-chip-selected-border-color,revert);background:var(--rc-chip-selected-bg,revert);color:var(--rc-chip-selected-color,revert)}:host([disabled]) ::slotted(button){opacity:var(--rc-chip-disabled-opacity,revert)}:host(:focus-within) ::slotted(button),:host(:focus-within) ::slotted(a),:host(:focus-within) ::slotted(label){outline:var(--rc-chip-focus-ring,revert);outline-offset:var(--rc-chip-focus-ring-offset,revert)}[part=state-layer]{pointer-events:none;z-index:2;block-size:var(--rc-chip-block-size,100%);border-radius:var(--rc-chip-radius,0);background:var(--rc-chip-state-layer-color,currentColor);opacity:0;transition:opacity var(--rc-chip-state-layer-transition-duration,var(--rc-motion-effects-duration-fast,80ms)) var(--rc-chip-state-layer-transition-easing,var(--rc-motion-effects-easing-fast,ease-out));position:absolute;inset-block-start:50%;inset-inline:0;translate:0 -50%}:host([selected]) [part=state-layer]{background:var(--rc-chip-selected-state-layer-color,var(--rc-chip-state-layer-color,currentColor))}@media (hover:hover){:host(:not([disabled],[readonly]):hover) [part=state-layer]{opacity:var(--rc-chip-hover-state-layer-opacity,.08)}}:host(:not([disabled],[readonly]):focus-within) [part=state-layer]{opacity:var(--rc-chip-focus-state-layer-opacity,.12)}:host(:not([disabled],[readonly]):active) [part=state-layer]{opacity:var(--rc-chip-pressed-state-layer-opacity,.12)}[part=remove]{z-index:3;pointer-events:none;min-inline-size:var(--rc-chip-remove-target-size,1.5rem);min-block-size:var(--rc-chip-remove-target-size,1.5rem);border-radius:var(--rc-chip-remove-radius,9999px);color:inherit;font:inherit;background:0 0;border:0;place-items:center;display:none;position:absolute;inset-block-start:50%;inset-inline-end:var(--rc-chip-remove-offset-inline,.125rem);translate:0 -50%}:host([removable]) [part=remove]{display:inline-grid}::slotted([slot=remove-icon]){font-size:var(--rc-chip-remove-icon-size,smaller)!important}:host([removable]) ::slotted(button),:host([removable]) ::slotted(a),:host([removable]) ::slotted(label),:host([removable]) ::slotted([data-rc-chip-label]){padding-inline-end:var(--rc-chip-removable-padding-inline-end,calc(var(--rc-chip-remove-target-size,1.5rem) + var(--rc-chip-remove-offset-inline,.125rem)))}@media (forced-colors:active){[part=state-layer]{display:none}::slotted(button),::slotted(a),::slotted(label),::slotted([data-rc-chip-label]){color:buttontext;background:buttonface;border-color:buttonborder}:host([selected]) ::slotted(button),:host([selected]) ::slotted(a),:host([selected]) ::slotted(label),:host([selected]) ::slotted([data-rc-chip-label]){color:highlighttext;background:highlight;border-color:highlight}}`;
|
|
5
|
+
var f = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, n = (d, e, t, r) => {
|
|
6
|
+
for (var i = r > 1 ? void 0 : r ? _(e, t) : e, a = d.length - 1, o; a >= 0; a--)
|
|
7
|
+
(o = d[a]) && (i = (r ? o(e, t, i) : o(i)) || i);
|
|
8
|
+
return r && i && f(e, t, i), i;
|
|
9
|
+
};
|
|
10
|
+
const y = /* @__PURE__ */ new Set(["checkbox", "menuitemcheckbox", "menuitemradio", "radio", "switch"]), m = b`@layer rc-base{rc-chip>:is(button,a,label,[data-rc-chip-label]){box-sizing:border-box;justify-content:center;align-items:center;gap:var(--rc-chip-gap,0px);min-block-size:var(--rc-chip-block-size,revert);padding-block:var(--rc-chip-padding-block,revert);border:var(--rc-chip-border,revert);border-radius:var(--rc-chip-radius,revert);background:var(--rc-chip-bg,revert);color:var(--rc-chip-color,revert);font:var(--rc-chip-font,revert);text-decoration:var(--rc-chip-text-decoration,revert);white-space:nowrap;-webkit-tap-highlight-color:transparent;margin:0;padding-inline-start:var(--rc-chip-padding-inline-start,var(--rc-chip-padding-inline,revert));padding-inline-end:var(--rc-chip-padding-inline-end,var(--rc-chip-padding-inline,revert));display:inline-flex;position:relative}rc-chip:not([readonly])>:is(button,a,label):before{content:"";z-index:1;inset-block:calc((var(--rc-chip-touch-target-block-size,3rem) - max(100%, var(--rc-chip-block-size,0px))) / -2);border-radius:inherit;position:absolute;inset-inline:0}rc-chip[selected]>:is(button,a,label,[data-rc-chip-label]),rc-chip>label:has(>input:is([type=checkbox],[type=radio]):checked){border-color:var(--rc-chip-selected-border-color,revert);background:var(--rc-chip-selected-bg,revert);color:var(--rc-chip-selected-color,revert)}rc-chip[disabled]>:is(button,label),rc-chip>label:has(>input:is([type=checkbox],[type=radio]):disabled){opacity:var(--rc-chip-disabled-opacity,revert)}rc-chip>:is(button,a):focus-visible,rc-chip>label:has(>input:is([type=checkbox],[type=radio]):focus-visible){outline:var(--rc-chip-focus-ring,revert);outline-offset:var(--rc-chip-focus-ring-offset,revert)}rc-chip>label>input:is([type=checkbox],[type=radio]){clip-path:inset(50%);white-space:nowrap;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}rc-chip[removable]>:is(button,a,label,[data-rc-chip-label]){padding-inline-end:var(--rc-chip-removable-padding-inline-end,calc(var(--rc-chip-remove-target-size,1.5rem) + var(--rc-chip-remove-offset-inline,.125rem)))}@media (forced-colors:active){rc-chip>:is(button,a,label,[data-rc-chip-label]){color:buttontext;background:buttonface;border-color:buttonborder}rc-chip[selected]>:is(button,a,label,[data-rc-chip-label]),rc-chip>label:has(>input:is([type=checkbox],[type=radio]):checked){color:highlighttext;background:highlight;border-color:highlight}}}`;
|
|
11
|
+
var s;
|
|
12
|
+
const c = (s = class extends u {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this._defaultSelected = !1, this._selectedInitialized = !1, this._$button = null, this._$input = null, this._$form = null, this._controlObserver = null, this._disabledOwned = !1, this._pressedOwned = !1, this._slotMicrotaskQueued = !1, this._lastChildWarning = null, this.variant = "assist", this.disabled = !1, this.readonly = !1, this.removable = !1, this._handleNativeChange = () => {
|
|
15
|
+
const e = this._$input;
|
|
16
|
+
if (!e || this.disabled || this.readonly)
|
|
17
|
+
return;
|
|
18
|
+
const t = this.selected, r = e.checked;
|
|
19
|
+
this._selected === void 0 ? (this._uncontrolledSelected = r, this._selectedInitialized = !0, this.requestUpdate("selected", t)) : this._syncCheckedState(), this.dispatchEvent(
|
|
20
|
+
new CustomEvent("rc-chip-change", {
|
|
21
|
+
bubbles: !0,
|
|
22
|
+
composed: !0,
|
|
23
|
+
detail: { selected: r }
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
}, this._handleButtonClick = () => {
|
|
27
|
+
if (this.disabled || this.readonly)
|
|
28
|
+
return;
|
|
29
|
+
if (this.removable) {
|
|
30
|
+
this._dispatchRemove();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (this.variant !== "filter")
|
|
34
|
+
return;
|
|
35
|
+
const e = this._$button?.getAttribute("aria-haspopup");
|
|
36
|
+
if (e && e !== "false")
|
|
37
|
+
return;
|
|
38
|
+
const t = this.selected, r = !t;
|
|
39
|
+
this._selected === void 0 && (this._uncontrolledSelected = r, this._selectedInitialized = !0, this._syncPressedState(), this.requestUpdate("selected", t)), this.dispatchEvent(
|
|
40
|
+
new CustomEvent("rc-chip-change", {
|
|
41
|
+
bubbles: !0,
|
|
42
|
+
composed: !0,
|
|
43
|
+
detail: { selected: r }
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
}, this._handleFormReset = () => {
|
|
47
|
+
queueMicrotask(() => this._syncCheckedFromNative());
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
static _ensureBaseStyles(e) {
|
|
51
|
+
if (s._styledRoots.has(e))
|
|
52
|
+
return;
|
|
53
|
+
s._styledRoots.add(e);
|
|
54
|
+
const t = (e instanceof Document ? e : e.ownerDocument).createElement("style");
|
|
55
|
+
t.setAttribute("data-rc-light-dom-base", "rc-chip"), t.textContent = m, e instanceof Document ? e.head.append(t) : e.append(t);
|
|
56
|
+
}
|
|
57
|
+
get selected() {
|
|
58
|
+
return this._selected ?? this._uncontrolledSelected ?? this._defaultSelected;
|
|
59
|
+
}
|
|
60
|
+
set selected(e) {
|
|
61
|
+
const t = this.selected;
|
|
62
|
+
this._selected = e, this._selectedInitialized = !0, this._syncCheckedState(), this._syncPressedState(), this.requestUpdate("selected", t);
|
|
63
|
+
}
|
|
64
|
+
get defaultSelected() {
|
|
65
|
+
return this._defaultSelected;
|
|
66
|
+
}
|
|
67
|
+
set defaultSelected(e) {
|
|
68
|
+
const t = this._defaultSelected;
|
|
69
|
+
this._defaultSelected = e, !this._selectedInitialized && this._selected === void 0 && this._uncontrolledSelected === void 0 && (this._syncPressedState(), this.requestUpdate("selected", t)), this.requestUpdate("defaultSelected", t);
|
|
70
|
+
}
|
|
71
|
+
connectedCallback() {
|
|
72
|
+
super.connectedCallback(), s._ensureBaseStyles(this.getRootNode());
|
|
73
|
+
}
|
|
74
|
+
disconnectedCallback() {
|
|
75
|
+
this._$button?.removeEventListener("click", this._handleButtonClick), this._$input?.removeEventListener("change", this._handleNativeChange), this._$form?.removeEventListener("reset", this._handleFormReset), this._controlObserver?.disconnect(), this._controlObserver = null, super.disconnectedCallback();
|
|
76
|
+
}
|
|
77
|
+
/** Synchronizes uncontrolled filter state from the direct native input. @internal */
|
|
78
|
+
syncNativeSelection() {
|
|
79
|
+
this._syncCheckedFromNative();
|
|
80
|
+
}
|
|
81
|
+
firstUpdated() {
|
|
82
|
+
this._syncSlottedButton(!0);
|
|
83
|
+
}
|
|
84
|
+
updated(e) {
|
|
85
|
+
(e.has("disabled") || e.has("readonly")) && this._syncDisabled(), (e.has("variant") || e.has("selected") || e.has("readonly") || e.has("removable")) && this._syncPressedState(), e.has("selected") && this._syncCheckedState();
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
return h`
|
|
89
|
+
<slot @slotchange=${this._handleSlotChange}></slot>
|
|
90
|
+
<span part="state-layer" aria-hidden="true"></span>
|
|
91
|
+
${this.removable ? h`
|
|
92
|
+
<span part="remove" aria-hidden="true">
|
|
93
|
+
<slot name="remove-icon">×</slot>
|
|
94
|
+
</span>
|
|
95
|
+
` : ""}
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
_handleSlotChange() {
|
|
99
|
+
this._slotMicrotaskQueued || (this._slotMicrotaskQueued = !0, queueMicrotask(() => {
|
|
100
|
+
this._slotMicrotaskQueued = !1, this.isConnected && this._syncSlottedButton();
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
_syncSlottedButton(e = !1) {
|
|
104
|
+
const t = this.querySelector(":scope > button");
|
|
105
|
+
this.querySelector(":scope > a[href]");
|
|
106
|
+
const i = this.querySelector(":scope > label")?.querySelector(
|
|
107
|
+
':scope > input:is([type="checkbox"], [type="radio"])'
|
|
108
|
+
) ?? null;
|
|
109
|
+
if (t === this._$button && i === this._$input) {
|
|
110
|
+
this._syncDisabled(), this._syncCheckedState(), this._syncPressedState();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (this._$button?.removeEventListener("click", this._handleButtonClick), this._$input?.removeEventListener("change", this._handleNativeChange), this._$form?.removeEventListener("reset", this._handleFormReset), this._controlObserver?.disconnect(), this._controlObserver = null, this._$button = t, this._$input = i, this._$form = i?.form ?? null, this._disabledOwned = !1, this._pressedOwned = !1, t && t.addEventListener("click", this._handleButtonClick), i) {
|
|
114
|
+
if (this._selected === void 0 && this._uncontrolledSelected === void 0) {
|
|
115
|
+
const o = this.selected;
|
|
116
|
+
this._uncontrolledSelected = i.checked, this._selectedInitialized = !0, e ? queueMicrotask(() => this.requestUpdate("selected", o)) : this.requestUpdate("selected", o);
|
|
117
|
+
} else
|
|
118
|
+
this._syncCheckedState();
|
|
119
|
+
i.addEventListener("change", this._handleNativeChange), this._$form?.addEventListener("reset", this._handleFormReset);
|
|
120
|
+
}
|
|
121
|
+
const a = i ?? t;
|
|
122
|
+
a && (this._controlObserver = new MutationObserver(() => {
|
|
123
|
+
this._syncDisabled(), this._syncCheckedFromNative(), this._syncPressedState();
|
|
124
|
+
}), this._controlObserver.observe(a, {
|
|
125
|
+
attributeFilter: ["aria-pressed", "role", "disabled", "checked"]
|
|
126
|
+
})), this._syncDisabled(), this._syncCheckedState(), this._syncPressedState();
|
|
127
|
+
}
|
|
128
|
+
_dispatchRemove() {
|
|
129
|
+
this.dispatchEvent(
|
|
130
|
+
new CustomEvent("rc-chip-remove", {
|
|
131
|
+
bubbles: !0,
|
|
132
|
+
composed: !0,
|
|
133
|
+
detail: { chip: this }
|
|
134
|
+
})
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
_syncDisabled() {
|
|
138
|
+
const e = this._$input ?? this._$button;
|
|
139
|
+
e && (this.disabled || this.readonly ? (e.disabled || (this._disabledOwned = !0), e.disabled = !0) : this._disabledOwned && (e.disabled = !1, this._disabledOwned = !1));
|
|
140
|
+
}
|
|
141
|
+
_syncCheckedState() {
|
|
142
|
+
const e = this._$input;
|
|
143
|
+
e && e.checked !== this.selected && (e.checked = this.selected);
|
|
144
|
+
}
|
|
145
|
+
_syncCheckedFromNative() {
|
|
146
|
+
const e = this._$input;
|
|
147
|
+
if (!e || e.checked === this.selected)
|
|
148
|
+
return;
|
|
149
|
+
const t = this.selected;
|
|
150
|
+
this._selected === void 0 ? (this._uncontrolledSelected = e.checked, this._selectedInitialized = !0, this.requestUpdate("selected", t)) : this._syncCheckedState();
|
|
151
|
+
}
|
|
152
|
+
_syncPressedState() {
|
|
153
|
+
const e = this._$button;
|
|
154
|
+
if (!e)
|
|
155
|
+
return;
|
|
156
|
+
const t = e.getAttribute("role"), r = e.hasAttribute("aria-pressed") && !this._pressedOwned || (t ? y.has(t) : !1);
|
|
157
|
+
if (!this.readonly && !this.removable && this.variant === "filter" && !r) {
|
|
158
|
+
const i = this.selected ? "true" : "false";
|
|
159
|
+
e.getAttribute("aria-pressed") !== i && e.setAttribute("aria-pressed", i), this._pressedOwned = !0;
|
|
160
|
+
} else this._pressedOwned && (e.removeAttribute("aria-pressed"), this._pressedOwned = !1);
|
|
161
|
+
}
|
|
162
|
+
}, s.styles = v, s._styledRoots = /* @__PURE__ */ new WeakSet(), s);
|
|
163
|
+
n([
|
|
164
|
+
l({ type: String, reflect: !0 })
|
|
165
|
+
], c.prototype, "variant", 2);
|
|
166
|
+
n([
|
|
167
|
+
l({ type: Boolean, reflect: !0 })
|
|
168
|
+
], c.prototype, "selected", 1);
|
|
169
|
+
n([
|
|
170
|
+
l({ type: Boolean, attribute: "default-selected" })
|
|
171
|
+
], c.prototype, "defaultSelected", 1);
|
|
172
|
+
n([
|
|
173
|
+
l({ type: Boolean, reflect: !0 })
|
|
174
|
+
], c.prototype, "disabled", 2);
|
|
175
|
+
n([
|
|
176
|
+
l({ type: Boolean, reflect: !0 })
|
|
177
|
+
], c.prototype, "readonly", 2);
|
|
178
|
+
n([
|
|
179
|
+
l({ type: Boolean, reflect: !0 })
|
|
180
|
+
], c.prototype, "removable", 2);
|
|
181
|
+
let x = c;
|
|
182
|
+
export {
|
|
183
|
+
x as R
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=rc-chip-D2kF8iCM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rc-chip-D2kF8iCM.js","sources":["../src/rc-chip.styles.ts","../src/rc-chip.ts"],"sourcesContent":["import { css } from 'lit';\n\nexport const chipStyles = css`\n :host {\n display: inline-grid;\n position: relative;\n place-items: center;\n min-block-size: var(--rc-chip-touch-target-block-size, 3rem);\n color-scheme: inherit;\n vertical-align: middle;\n /*\n * Zero by default. Unlike rc-button's touch-target inflation (opt-in via\n * icon-only), a chip's accessible touch-target minimum applies\n * unconditionally, so it's a common fit inside a height-constrained\n * field -- rc-search-bar's or rc-combobox's multi-select value area, say\n * -- where 3rem per chip would force the field taller than its own\n * content needs. A theme or consumer sets one of these on a chip that\n * sits at a real block-axis edge (no neighbor on that side within the\n * field) to let the touch target overlap into the field's own block\n * padding instead of also reserving layout space there. The same\n * pattern as rc-button's, rc-menu-button's, and rc-adaptive-menu's own\n * touch-target overlap tokens, but on the block axis: a chip's own\n * touch-target inflation is vertical, not horizontal.\n */\n margin-block-start: calc(-1 * var(--rc-chip-touch-target-overlap-block-start, 0px));\n margin-block-end: calc(-1 * var(--rc-chip-touch-target-overlap-block-end, 0px));\n }\n\n :host([readonly]) {\n min-block-size: var(--_rc-chip-group-readonly-min-block-size, var(--rc-chip-block-size, auto));\n }\n\n :host([hidden]) {\n display: none;\n }\n\n ::slotted(button),\n ::slotted(a),\n ::slotted(label),\n ::slotted([data-rc-chip-label]) {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--rc-chip-gap, 0px);\n min-block-size: var(--rc-chip-block-size);\n padding-block: var(--rc-chip-padding-block, revert);\n padding-inline-start: var(\n --rc-chip-padding-inline-start,\n var(--rc-chip-padding-inline, revert)\n );\n padding-inline-end: var(--rc-chip-padding-inline-end, var(--rc-chip-padding-inline, revert));\n border: var(--rc-chip-border, revert);\n border-radius: var(--rc-chip-radius, revert);\n background: var(--rc-chip-bg, revert);\n color: var(--rc-chip-color, revert);\n font: var(--rc-chip-font, revert);\n text-decoration: var(--rc-chip-text-decoration, revert);\n white-space: nowrap;\n -webkit-tap-highlight-color: transparent;\n }\n\n :host([selected]) ::slotted(button),\n :host([selected]) ::slotted(a),\n :host([selected]) ::slotted(label),\n :host([selected]) ::slotted([data-rc-chip-label]) {\n border-color: var(--rc-chip-selected-border-color, revert);\n background: var(--rc-chip-selected-bg, revert);\n color: var(--rc-chip-selected-color, revert);\n }\n\n :host([disabled]) ::slotted(button) {\n opacity: var(--rc-chip-disabled-opacity, revert);\n }\n\n :host(:focus-within) ::slotted(button),\n :host(:focus-within) ::slotted(a),\n :host(:focus-within) ::slotted(label) {\n outline: var(--rc-chip-focus-ring, revert);\n outline-offset: var(--rc-chip-focus-ring-offset, revert);\n }\n\n [part='state-layer'] {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n inset-inline: 0;\n inset-block-start: 50%;\n block-size: var(--rc-chip-block-size, 100%);\n translate: 0 -50%;\n border-radius: var(--rc-chip-radius, 0);\n background: var(--rc-chip-state-layer-color, currentColor);\n opacity: 0;\n transition: opacity\n var(--rc-chip-state-layer-transition-duration, var(--rc-motion-effects-duration-fast, 80ms))\n var(--rc-chip-state-layer-transition-easing, var(--rc-motion-effects-easing-fast, ease-out));\n }\n\n :host([selected]) [part='state-layer'] {\n background: var(\n --rc-chip-selected-state-layer-color,\n var(--rc-chip-state-layer-color, currentColor)\n );\n }\n\n @media (hover: hover) {\n :host(:not([disabled], [readonly]):hover) [part='state-layer'] {\n opacity: var(--rc-chip-hover-state-layer-opacity, 0.08);\n }\n }\n\n :host(:not([disabled], [readonly]):focus-within) [part='state-layer'] {\n opacity: var(--rc-chip-focus-state-layer-opacity, 0.12);\n }\n\n :host(:not([disabled], [readonly]):active) [part='state-layer'] {\n opacity: var(--rc-chip-pressed-state-layer-opacity, 0.12);\n }\n\n [part='remove'] {\n position: absolute;\n z-index: 3;\n pointer-events: none;\n inset-block-start: 50%;\n inset-inline-end: var(--rc-chip-remove-offset-inline, 0.125rem);\n display: none;\n place-items: center;\n min-inline-size: var(--rc-chip-remove-target-size, 1.5rem);\n min-block-size: var(--rc-chip-remove-target-size, 1.5rem);\n translate: 0 -50%;\n border: 0;\n border-radius: var(--rc-chip-remove-radius, 9999px);\n background: transparent;\n color: inherit;\n font: inherit;\n }\n\n :host([removable]) [part='remove'] {\n display: inline-grid;\n }\n\n ::slotted([slot='remove-icon']) {\n /* Keep icon-font utility classes from overriding the chip's compact icon size. */\n font-size: var(--rc-chip-remove-icon-size, smaller) !important;\n }\n\n :host([removable]) ::slotted(button),\n :host([removable]) ::slotted(a),\n :host([removable]) ::slotted(label),\n :host([removable]) ::slotted([data-rc-chip-label]) {\n padding-inline-end: var(\n --rc-chip-removable-padding-inline-end,\n calc(\n var(--rc-chip-remove-target-size, 1.5rem) + var(--rc-chip-remove-offset-inline, 0.125rem)\n )\n );\n }\n\n @media (forced-colors: active) {\n [part='state-layer'] {\n display: none;\n }\n\n ::slotted(button),\n ::slotted(a),\n ::slotted(label),\n ::slotted([data-rc-chip-label]) {\n border-color: ButtonBorder;\n background: ButtonFace;\n color: ButtonText;\n }\n\n :host([selected]) ::slotted(button),\n :host([selected]) ::slotted(a),\n :host([selected]) ::slotted(label),\n :host([selected]) ::slotted([data-rc-chip-label]) {\n border-color: Highlight;\n background: Highlight;\n color: HighlightText;\n }\n }\n`;\n\nexport default chipStyles;\n","import { LitElement, html } from 'lit';\nimport type { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { cssText } from '@rcarls/rc-common';\n\nimport chipStyles from './rc-chip.styles.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'rc-chip': RCChip;\n }\n\n interface HTMLElementEventMap {\n 'rc-chip-change': CustomEvent<RCChipChangeDetail>;\n 'rc-chip-remove': CustomEvent<RCChipRemoveDetail>;\n }\n}\n\nconst TOGGLE_ROLES = new Set(['checkbox', 'menuitemcheckbox', 'menuitemradio', 'radio', 'switch']);\n\nconst LIGHT_DOM_CSS = cssText`\n@layer rc-base {\n rc-chip > :is(button, a, label, [data-rc-chip-label]) {\n position: relative;\n display: inline-flex;\n box-sizing: border-box;\n align-items: center;\n justify-content: center;\n gap: var(--rc-chip-gap, 0px);\n min-block-size: var(--rc-chip-block-size, revert);\n margin: 0;\n padding-block: var(--rc-chip-padding-block, revert);\n padding-inline-start: var(\n --rc-chip-padding-inline-start,\n var(--rc-chip-padding-inline, revert)\n );\n padding-inline-end: var(--rc-chip-padding-inline-end, var(--rc-chip-padding-inline, revert));\n border: var(--rc-chip-border, revert);\n border-radius: var(--rc-chip-radius, revert);\n background: var(--rc-chip-bg, revert);\n color: var(--rc-chip-color, revert);\n font: var(--rc-chip-font, revert);\n text-decoration: var(--rc-chip-text-decoration, revert);\n white-space: nowrap;\n -webkit-tap-highlight-color: transparent;\n }\n\n rc-chip:not([readonly]) > :is(button, a, label)::before {\n content: '';\n position: absolute;\n z-index: 1;\n inset-block: calc(\n (var(--rc-chip-touch-target-block-size, 3rem) - max(100%, var(--rc-chip-block-size, 0px))) /\n -2\n );\n inset-inline: 0;\n border-radius: inherit;\n }\n\n rc-chip[selected] > :is(button, a, label, [data-rc-chip-label]),\n rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):checked) {\n border-color: var(--rc-chip-selected-border-color, revert);\n background: var(--rc-chip-selected-bg, revert);\n color: var(--rc-chip-selected-color, revert);\n }\n\n rc-chip[disabled] > :is(button, label),\n rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):disabled) {\n opacity: var(--rc-chip-disabled-opacity, revert);\n }\n\n rc-chip > :is(button, a):focus-visible,\n rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):focus-visible) {\n outline: var(--rc-chip-focus-ring, revert);\n outline-offset: var(--rc-chip-focus-ring-offset, revert);\n }\n\n rc-chip > label > input:is([type='checkbox'], [type='radio']) {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n\n rc-chip[removable] > :is(button, a, label, [data-rc-chip-label]) {\n padding-inline-end: var(\n --rc-chip-removable-padding-inline-end,\n calc(\n var(--rc-chip-remove-target-size, 1.5rem) +\n var(--rc-chip-remove-offset-inline, 0.125rem)\n )\n );\n }\n\n @media (forced-colors: active) {\n rc-chip > :is(button, a, label, [data-rc-chip-label]) {\n border-color: ButtonBorder;\n background: ButtonFace;\n color: ButtonText;\n }\n\n rc-chip[selected] > :is(button, a, label, [data-rc-chip-label]),\n rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):checked) {\n border-color: Highlight;\n background: Highlight;\n color: HighlightText;\n }\n }\n}\n`;\n\n/** Supported chip variants. */\nexport type RCChipVariant = 'assist' | 'filter' | 'input' | 'suggestion';\n\n/** Detail payload for `rc-chip-change`. */\nexport interface RCChipChangeDetail {\n /** Selected state after user interaction. */\n selected: boolean;\n}\n\n/** Detail payload for `rc-chip-remove`. */\nexport interface RCChipRemoveDetail {\n /** The host chip requesting removal. */\n chip: RCChip;\n}\n\n/**\n * Chip wrapper that preserves a direct native `<button>` child for action chips,\n * a direct `<a href>` for navigation chips, or a direct `<label>` containing a\n * native checkbox/radio for filter chips. Read-only chips accept a direct\n * `[data-rc-chip-label]` child.\n *\n * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-chip rc-chip docs}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/button/ WAI-ARIA button pattern}\n *\n * @slot - A direct native `<button>` child, `<a href>`, native-backed filter\n * `<label>`, or `[data-rc-chip-label]` when `readonly`.\n * @slot remove-icon - Optional presentational remove icon.\n *\n * @fires rc-chip-change - Fired when a user toggles a filter chip.\n * @fires rc-chip-remove - Fired when a user activates a removable chip's native button.\n *\n * @csspart state-layer - Overlay layer for hover, focus, pressed, ripple, or design-system effects.\n * @csspart remove - Presentational trailing remove indicator.\n *\n * @cssprop [--rc-chip-gap=0px] - Gap between the slotted button/anchor/label's content.\n * @cssprop [--rc-chip-block-size] - Minimum chip block size (defers to native button/anchor\n * sizing when unset).\n * @cssprop [--rc-chip-touch-target-block-size=3rem] - Minimum interactive touch target size.\n * @cssprop [--rc-chip-touch-target-overlap-block-start=0px] - Zero by default. A theme or\n * consumer sets this on a chip that sits at a real block-axis leading edge (no neighbor on\n * that side), such as inside a height-constrained field, to let its touch-target inflation\n * overlap into whatever sits just outside the host instead of also reserving layout space\n * there.\n * @cssprop [--rc-chip-touch-target-overlap-block-end=0px] - The block-axis trailing-edge\n * counterpart to `--rc-chip-touch-target-overlap-block-start`.\n * @cssprop [--rc-chip-padding-block] - Block-axis padding of the slotted button, anchor, or\n * label (defers to native padding when unset).\n * @cssprop [--rc-chip-padding-inline] - Inline-axis padding of the slotted button, anchor, or\n * label (defers to native padding when unset).\n * @cssprop [--rc-chip-padding-inline-start=var(--rc-chip-padding-inline)] - Logical leading\n * padding of the slotted button, anchor, or label.\n * @cssprop [--rc-chip-padding-inline-end=var(--rc-chip-padding-inline)] - Logical trailing\n * padding of the slotted button, anchor, or label.\n * @cssprop [--rc-chip-border] - Border of the slotted button, anchor, or label (defers to\n * native border when unset).\n * @cssprop [--rc-chip-radius] - Border radius of the slotted button/anchor/label and the\n * state-layer overlay (defers to native border-radius when unset; the state-layer overlay\n * falls back to 0).\n * @cssprop [--rc-chip-bg] - Background of the slotted button, anchor, or label (defers to\n * native background when unset).\n * @cssprop [--rc-chip-color] - Text color of the slotted button, anchor, or label (defers to\n * native color when unset).\n * @cssprop [--rc-chip-font] - Font shorthand for the slotted button, anchor, or label (defers\n * to native font when unset).\n * @cssprop [--rc-chip-text-decoration] - Text decoration for the slotted anchor (defers to\n * native text-decoration when unset).\n * @cssprop [--rc-chip-selected-border-color] - Border color when `selected` (defers to native\n * styling when unset).\n * @cssprop [--rc-chip-selected-bg] - Background when `selected` (defers to native styling when\n * unset).\n * @cssprop [--rc-chip-selected-color] - Text color when `selected` (defers to native styling\n * when unset).\n * @cssprop [--rc-chip-disabled-opacity] - Opacity of the slotted button when `disabled` (defers\n * to native disabled styling when unset).\n * @cssprop [--rc-chip-focus-ring] - Outline shown while focus-within (defers to native focus\n * styling when unset).\n * @cssprop [--rc-chip-focus-ring-offset] - Outline offset while focus-within (defers to native\n * focus styling when unset).\n * @cssprop [--rc-chip-state-layer-color=currentColor] - Hover/focus/pressed state-layer color.\n * @cssprop [--rc-chip-selected-state-layer-color=var(--rc-chip-state-layer-color, currentColor)] - Selected chip state-layer color.\n * @cssprop [--rc-chip-hover-state-layer-opacity=0.08] - Hover state-layer opacity.\n * @cssprop [--rc-chip-focus-state-layer-opacity=0.12] - Focus state-layer opacity.\n * @cssprop [--rc-chip-pressed-state-layer-opacity=0.12] - Pressed state-layer opacity.\n * @cssprop [--rc-chip-state-layer-transition-duration=var(--rc-motion-effects-duration-fast,80ms)] - State-layer effects duration.\n * @cssprop [--rc-chip-state-layer-transition-easing=var(--rc-motion-effects-easing-fast,ease-out)] - State-layer effects easing.\n * @cssprop [--rc-chip-remove-offset-inline=0.125rem] - Inline offset of the remove indicator\n * from the chip edge.\n * @cssprop [--rc-chip-remove-target-size=1.5rem] - Minimum inline and block size of the remove\n * indicator's hit target.\n * @cssprop [--rc-chip-remove-radius=9999px] - Border radius of the remove indicator.\n * @cssprop [--rc-chip-remove-icon-size=smaller] - Font size for a slotted remove icon.\n * @cssprop [--rc-chip-removable-padding-inline-end=calc(var(--rc-chip-remove-target-size, 1.5rem) + var(--rc-chip-remove-offset-inline, 0.125rem))] - Override for removable chip content end padding.\n *\n * @attr variant - Chip variant: `assist`, `filter`, `input`, or `suggestion`.\n * @attr selected - Declarative selected state for filter/input chips.\n * @attr default-selected - Initial selected state for uncontrolled usage.\n * @attr disabled - Mirrors disabled state to the native child button.\n * @attr readonly - Marks the chip as non-interactive display content.\n * @attr removable - Shows a trailing remove affordance.\n */\nexport class RCChip extends LitElement {\n static override styles = chipStyles;\n\n private static readonly _styledRoots = new WeakSet<Document | ShadowRoot>();\n\n private static _ensureBaseStyles(root: Document | ShadowRoot): void {\n if (RCChip._styledRoots.has(root)) {\n return;\n }\n\n RCChip._styledRoots.add(root);\n\n const $style = (root instanceof Document ? root : root.ownerDocument).createElement('style');\n\n $style.setAttribute('data-rc-light-dom-base', 'rc-chip');\n $style.textContent = LIGHT_DOM_CSS;\n\n if (root instanceof Document) {\n root.head.append($style);\n } else {\n root.append($style);\n }\n }\n\n private _selected: boolean | undefined;\n private _defaultSelected = false;\n private _uncontrolledSelected: boolean | undefined;\n private _selectedInitialized = false;\n private _$button: HTMLButtonElement | null = null;\n private _$input: HTMLInputElement | null = null;\n private _$form: HTMLFormElement | null = null;\n private _controlObserver: MutationObserver | null = null;\n private _disabledOwned = false;\n private _pressedOwned = false;\n private _slotMicrotaskQueued = false;\n private _lastChildWarning: string | null = null;\n\n /** Chip variant. */\n @property({ type: String, reflect: true })\n variant: RCChipVariant = 'assist';\n\n /** Current selected state. Host writes are silent. */\n @property({ type: Boolean, reflect: true })\n get selected(): boolean {\n return this._selected ?? this._uncontrolledSelected ?? this._defaultSelected;\n }\n\n set selected(value: boolean | undefined) {\n const oldValue = this.selected;\n\n this._selected = value;\n this._selectedInitialized = true;\n this._syncCheckedState();\n this._syncPressedState();\n this.requestUpdate('selected', oldValue);\n }\n\n /** Initial selected state for uncontrolled usage. */\n @property({ type: Boolean, attribute: 'default-selected' })\n get defaultSelected(): boolean {\n return this._defaultSelected;\n }\n\n set defaultSelected(value: boolean) {\n const oldValue = this._defaultSelected;\n\n this._defaultSelected = value;\n\n if (\n !this._selectedInitialized &&\n this._selected === undefined &&\n this._uncontrolledSelected === undefined\n ) {\n this._syncPressedState();\n this.requestUpdate('selected', oldValue);\n }\n\n this.requestUpdate('defaultSelected', oldValue);\n }\n\n /** Mirror disabled state to the native child button. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Mark this chip as non-interactive display content. */\n @property({ type: Boolean, reflect: true })\n readonly = false;\n\n /** Show a trailing remove affordance. */\n @property({ type: Boolean, reflect: true })\n removable = false;\n\n override connectedCallback(): void {\n super.connectedCallback();\n RCChip._ensureBaseStyles(this.getRootNode() as Document | ShadowRoot);\n }\n\n override disconnectedCallback(): void {\n this._$button?.removeEventListener('click', this._handleButtonClick);\n this._$input?.removeEventListener('change', this._handleNativeChange);\n this._$form?.removeEventListener('reset', this._handleFormReset);\n this._controlObserver?.disconnect();\n this._controlObserver = null;\n super.disconnectedCallback();\n }\n\n /** Synchronizes uncontrolled filter state from the direct native input. @internal */\n syncNativeSelection(): void {\n this._syncCheckedFromNative();\n }\n\n protected override firstUpdated(): void {\n this._syncSlottedButton(true);\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n if (changed.has('disabled') || changed.has('readonly')) {\n this._syncDisabled();\n }\n\n if (\n changed.has('variant') ||\n changed.has('selected') ||\n changed.has('readonly') ||\n changed.has('removable')\n ) {\n this._syncPressedState();\n }\n\n if (changed.has('selected')) {\n this._syncCheckedState();\n }\n }\n\n protected override render() {\n return html`\n <slot @slotchange=${this._handleSlotChange}></slot>\n <span part=\"state-layer\" aria-hidden=\"true\"></span>\n ${this.removable\n ? html`\n <span part=\"remove\" aria-hidden=\"true\">\n <slot name=\"remove-icon\">×</slot>\n </span>\n `\n : ''}\n `;\n }\n\n private _handleSlotChange(): void {\n if (this._slotMicrotaskQueued) {\n return;\n }\n\n this._slotMicrotaskQueued = true;\n\n queueMicrotask(() => {\n this._slotMicrotaskQueued = false;\n\n if (this.isConnected) {\n this._syncSlottedButton();\n }\n });\n }\n\n private _syncSlottedButton(deferInitialSelectionUpdate = false): void {\n const $nextButton = this.querySelector<HTMLButtonElement>(':scope > button');\n const $anchor = this.querySelector<HTMLAnchorElement>(':scope > a[href]');\n const $label = this.querySelector<HTMLLabelElement>(':scope > label');\n const $nextInput =\n $label?.querySelector<HTMLInputElement>(\n ':scope > input:is([type=\"checkbox\"], [type=\"radio\"])',\n ) ?? null;\n\n if (import.meta.env.DEV) {\n let childWarning: string | null = null;\n\n if (!$nextButton && !$anchor && !$label && !this.readonly) {\n childWarning =\n '[rc-chip] No supported direct child found. Place a native <button>, <a href>, or a <label> containing a direct checkbox/radio inside <rc-chip>, or use readonly with a [data-rc-chip-label] child.';\n } else if ($label && !$nextInput && !this.readonly) {\n childWarning =\n '[rc-chip] A direct child <label> must contain a direct <input type=\"checkbox\"> or <input type=\"radio\">.';\n }\n\n if (childWarning && childWarning !== this._lastChildWarning) {\n console.warn(childWarning);\n }\n\n this._lastChildWarning = childWarning;\n }\n\n if ($nextButton === this._$button && $nextInput === this._$input) {\n this._syncDisabled();\n this._syncCheckedState();\n this._syncPressedState();\n\n return;\n }\n\n this._$button?.removeEventListener('click', this._handleButtonClick);\n this._$input?.removeEventListener('change', this._handleNativeChange);\n this._$form?.removeEventListener('reset', this._handleFormReset);\n this._controlObserver?.disconnect();\n this._controlObserver = null;\n this._$button = $nextButton;\n this._$input = $nextInput;\n this._$form = $nextInput?.form ?? null;\n this._disabledOwned = false;\n this._pressedOwned = false;\n\n if ($nextButton) {\n $nextButton.addEventListener('click', this._handleButtonClick);\n }\n\n if ($nextInput) {\n if (this._selected === undefined && this._uncontrolledSelected === undefined) {\n const oldValue = this.selected;\n\n this._uncontrolledSelected = $nextInput.checked;\n this._selectedInitialized = true;\n\n if (deferInitialSelectionUpdate) {\n queueMicrotask(() => this.requestUpdate('selected', oldValue));\n } else {\n this.requestUpdate('selected', oldValue);\n }\n } else {\n this._syncCheckedState();\n }\n\n $nextInput.addEventListener('change', this._handleNativeChange);\n this._$form?.addEventListener('reset', this._handleFormReset);\n }\n\n const $observedControl = $nextInput ?? $nextButton;\n\n if ($observedControl) {\n this._controlObserver = new MutationObserver(() => {\n this._syncDisabled();\n this._syncCheckedFromNative();\n this._syncPressedState();\n });\n\n this._controlObserver.observe($observedControl, {\n attributeFilter: ['aria-pressed', 'role', 'disabled', 'checked'],\n });\n }\n\n this._syncDisabled();\n this._syncCheckedState();\n this._syncPressedState();\n }\n\n private readonly _handleNativeChange = (): void => {\n const $input = this._$input;\n\n if (!$input || this.disabled || this.readonly) {\n return;\n }\n\n const oldValue = this.selected;\n const requestedSelected = $input.checked;\n\n if (this._selected === undefined) {\n this._uncontrolledSelected = requestedSelected;\n this._selectedInitialized = true;\n this.requestUpdate('selected', oldValue);\n } else {\n this._syncCheckedState();\n }\n\n this.dispatchEvent(\n new CustomEvent<RCChipChangeDetail>('rc-chip-change', {\n bubbles: true,\n composed: true,\n detail: { selected: requestedSelected },\n }),\n );\n };\n\n private readonly _handleButtonClick = (): void => {\n if (this.disabled || this.readonly) {\n return;\n }\n\n if (this.removable) {\n this._dispatchRemove();\n\n return;\n }\n\n if (this.variant !== 'filter') {\n return;\n }\n\n // Menu-backed filter chips expose filter affordance, but their menu owns\n // the eventual selected state. Preserve that author-controlled behavior.\n const hasPopup = this._$button?.getAttribute('aria-haspopup');\n\n if (hasPopup && hasPopup !== 'false') {\n return;\n }\n\n const oldValue = this.selected;\n const requestedSelected = !oldValue;\n\n if (this._selected === undefined) {\n this._uncontrolledSelected = requestedSelected;\n this._selectedInitialized = true;\n this._syncPressedState();\n this.requestUpdate('selected', oldValue);\n }\n\n this.dispatchEvent(\n new CustomEvent<RCChipChangeDetail>('rc-chip-change', {\n bubbles: true,\n composed: true,\n detail: { selected: requestedSelected },\n }),\n );\n };\n\n private _dispatchRemove(): void {\n this.dispatchEvent(\n new CustomEvent<RCChipRemoveDetail>('rc-chip-remove', {\n bubbles: true,\n composed: true,\n detail: { chip: this },\n }),\n );\n }\n\n private _syncDisabled(): void {\n const $control = this._$input ?? this._$button;\n\n if (!$control) {\n return;\n }\n\n if (this.disabled || this.readonly) {\n if (!$control.disabled) {\n this._disabledOwned = true;\n }\n\n $control.disabled = true;\n } else if (this._disabledOwned) {\n $control.disabled = false;\n this._disabledOwned = false;\n }\n }\n\n private _syncCheckedState(): void {\n const $input = this._$input;\n\n if ($input && $input.checked !== this.selected) {\n $input.checked = this.selected;\n }\n }\n\n private _syncCheckedFromNative(): void {\n const $input = this._$input;\n\n if (!$input || $input.checked === this.selected) {\n return;\n }\n\n const oldValue = this.selected;\n\n if (this._selected === undefined) {\n this._uncontrolledSelected = $input.checked;\n this._selectedInitialized = true;\n this.requestUpdate('selected', oldValue);\n } else {\n this._syncCheckedState();\n }\n }\n\n private readonly _handleFormReset = (): void => {\n queueMicrotask(() => this._syncCheckedFromNative());\n };\n\n private _syncPressedState(): void {\n const $button = this._$button;\n\n if (!$button) {\n return;\n }\n\n const role = $button.getAttribute('role');\n const authorOwnsState =\n ($button.hasAttribute('aria-pressed') && !this._pressedOwned) ||\n (role ? TOGGLE_ROLES.has(role) : false);\n\n if (!this.readonly && !this.removable && this.variant === 'filter' && !authorOwnsState) {\n const pressed = this.selected ? 'true' : 'false';\n\n if ($button.getAttribute('aria-pressed') !== pressed) {\n $button.setAttribute('aria-pressed', pressed);\n }\n\n this._pressedOwned = true;\n } else if (this._pressedOwned) {\n $button.removeAttribute('aria-pressed');\n this._pressedOwned = false;\n }\n }\n}\n\nexport default RCChip;\n"],"names":["chipStyles","css","TOGGLE_ROLES","LIGHT_DOM_CSS","cssText","_RCChip","_a","LitElement","$input","oldValue","requestedSelected","hasPopup","root","$style","value","changed","html","deferInitialSelectionUpdate","$nextButton","$nextInput","$observedControl","$control","$button","role","authorOwnsState","pressed","__decorateClass","property","RCChip"],"mappings":";;;AAEO,MAAMA,IAAaC;;;;;;ACiB1B,MAAMC,wBAAmB,IAAI,CAAC,YAAY,oBAAoB,iBAAiB,SAAS,QAAQ,CAAC,GAE3FC,IAAgBC;;AAmMf,MAAMC,KAANC,IAAA,cAAqBC,EAAW;AAAA,EAAhC,cAAA;AAAA,UAAA,GAAA,SAAA,GAyBL,KAAQ,mBAAmB,IAE3B,KAAQ,uBAAuB,IAC/B,KAAQ,WAAqC,MAC7C,KAAQ,UAAmC,MAC3C,KAAQ,SAAiC,MACzC,KAAQ,mBAA4C,MACpD,KAAQ,iBAAiB,IACzB,KAAQ,gBAAgB,IACxB,KAAQ,uBAAuB,IAC/B,KAAQ,oBAAmC,MAI3C,KAAA,UAAyB,UA2CzB,KAAA,WAAW,IAIX,KAAA,WAAW,IAIX,KAAA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A,CAAA;AAIAqB,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GArF/BtB,EAsFX,WAAA,YAAA,CAAA;AAIAqB,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAzF/BtB,EA0FX,WAAA,aAAA,CAAA;AA1FK,IAAMuB,IAANvB;"}
|
package/dist/rc-chip-define.js
CHANGED
package/dist/rc-chip.js
CHANGED
|
@@ -54,6 +54,10 @@ export interface RCChipRemoveDetail {
|
|
|
54
54
|
* label (defers to native padding when unset).
|
|
55
55
|
* @cssprop [--rc-chip-padding-inline] - Inline-axis padding of the slotted button, anchor, or
|
|
56
56
|
* label (defers to native padding when unset).
|
|
57
|
+
* @cssprop [--rc-chip-padding-inline-start=var(--rc-chip-padding-inline)] - Logical leading
|
|
58
|
+
* padding of the slotted button, anchor, or label.
|
|
59
|
+
* @cssprop [--rc-chip-padding-inline-end=var(--rc-chip-padding-inline)] - Logical trailing
|
|
60
|
+
* padding of the slotted button, anchor, or label.
|
|
57
61
|
* @cssprop [--rc-chip-border] - Border of the slotted button, anchor, or label (defers to
|
|
58
62
|
* native border when unset).
|
|
59
63
|
* @cssprop [--rc-chip-radius] - Border radius of the slotted button/anchor/label and the
|
|
@@ -92,7 +96,7 @@ export interface RCChipRemoveDetail {
|
|
|
92
96
|
* indicator's hit target.
|
|
93
97
|
* @cssprop [--rc-chip-remove-radius=9999px] - Border radius of the remove indicator.
|
|
94
98
|
* @cssprop [--rc-chip-remove-icon-size=smaller] - Font size for a slotted remove icon.
|
|
95
|
-
* @cssprop [--rc-chip-removable-padding-inline-end=calc(var(--rc-chip-remove-target-size, 1.5rem)
|
|
99
|
+
* @cssprop [--rc-chip-removable-padding-inline-end=calc(var(--rc-chip-remove-target-size, 1.5rem) + var(--rc-chip-remove-offset-inline, 0.125rem))] - Override for removable chip content end padding.
|
|
96
100
|
*
|
|
97
101
|
* @attr variant - Chip variant: `assist`, `filter`, `input`, or `suggestion`.
|
|
98
102
|
* @attr selected - Declarative selected state for filter/input chips.
|
|
@@ -137,7 +141,7 @@ export declare class RCChip extends LitElement {
|
|
|
137
141
|
syncNativeSelection(): void;
|
|
138
142
|
protected firstUpdated(): void;
|
|
139
143
|
protected updated(changed: PropertyValues<this>): void;
|
|
140
|
-
protected render(): import('lit').TemplateResult<1>;
|
|
144
|
+
protected render(): import('lit-html').TemplateResult<1>;
|
|
141
145
|
private _handleSlotChange;
|
|
142
146
|
private _syncSlottedButton;
|
|
143
147
|
private readonly _handleNativeChange;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.7.0",
|
|
7
7
|
"description": "Chip wrapper for native actions, links, filters, and inputs.",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
"test:browser:chrome": "vitest --run --project=chromium",
|
|
45
45
|
"test:browser:firefox": "vitest --run --project=firefox"
|
|
46
46
|
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@rcarls/rc-common": "0.7.0"
|
|
49
|
+
},
|
|
47
50
|
"devDependencies": {
|
|
48
51
|
"@custom-elements-manifest/analyzer": "0.11.0",
|
|
49
52
|
"@vitest/browser-playwright": "4.1.5",
|
package/dist/rc-chip-B71-Icgf.js
DELETED
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
import { css as p, LitElement as u, html as h } from "lit";
|
|
2
|
-
import { property as l } from "lit/decorators.js";
|
|
3
|
-
const b = p`
|
|
4
|
-
:host {
|
|
5
|
-
display: inline-grid;
|
|
6
|
-
position: relative;
|
|
7
|
-
place-items: center;
|
|
8
|
-
min-block-size: var(--rc-chip-touch-target-block-size, 3rem);
|
|
9
|
-
color-scheme: inherit;
|
|
10
|
-
vertical-align: middle;
|
|
11
|
-
/*
|
|
12
|
-
* Zero by default. Unlike rc-button's touch-target inflation (opt-in via
|
|
13
|
-
* icon-only), a chip's accessible touch-target minimum applies
|
|
14
|
-
* unconditionally, so it's a common fit inside a height-constrained
|
|
15
|
-
* field -- rc-search-bar's or rc-combobox's multi-select value area, say
|
|
16
|
-
* -- where 3rem per chip would force the field taller than its own
|
|
17
|
-
* content needs. A theme or consumer sets one of these on a chip that
|
|
18
|
-
* sits at a real block-axis edge (no neighbor on that side within the
|
|
19
|
-
* field) to let the touch target overlap into the field's own block
|
|
20
|
-
* padding instead of also reserving layout space there. The same
|
|
21
|
-
* pattern as rc-button's, rc-menu-button's, and rc-adaptive-menu's own
|
|
22
|
-
* touch-target overlap tokens, but on the block axis: a chip's own
|
|
23
|
-
* touch-target inflation is vertical, not horizontal.
|
|
24
|
-
*/
|
|
25
|
-
margin-block-start: calc(-1 * var(--rc-chip-touch-target-overlap-block-start, 0px));
|
|
26
|
-
margin-block-end: calc(-1 * var(--rc-chip-touch-target-overlap-block-end, 0px));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
:host([readonly]) {
|
|
30
|
-
min-block-size: var(--rc-chip-block-size, auto);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:host([hidden]) {
|
|
34
|
-
display: none;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
::slotted(button),
|
|
38
|
-
::slotted(a),
|
|
39
|
-
::slotted(label),
|
|
40
|
-
::slotted([data-rc-chip-label]) {
|
|
41
|
-
display: inline-flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
gap: var(--rc-chip-gap, 0px);
|
|
45
|
-
min-block-size: var(--rc-chip-block-size);
|
|
46
|
-
padding-block: var(--rc-chip-padding-block, revert);
|
|
47
|
-
padding-inline: var(--rc-chip-padding-inline, revert);
|
|
48
|
-
border: var(--rc-chip-border, revert);
|
|
49
|
-
border-radius: var(--rc-chip-radius, revert);
|
|
50
|
-
background: var(--rc-chip-bg, revert);
|
|
51
|
-
color: var(--rc-chip-color, revert);
|
|
52
|
-
font: var(--rc-chip-font, revert);
|
|
53
|
-
text-decoration: var(--rc-chip-text-decoration, revert);
|
|
54
|
-
white-space: nowrap;
|
|
55
|
-
-webkit-tap-highlight-color: transparent;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
:host([selected]) ::slotted(button),
|
|
59
|
-
:host([selected]) ::slotted(a),
|
|
60
|
-
:host([selected]) ::slotted(label),
|
|
61
|
-
:host([selected]) ::slotted([data-rc-chip-label]) {
|
|
62
|
-
border-color: var(--rc-chip-selected-border-color, revert);
|
|
63
|
-
background: var(--rc-chip-selected-bg, revert);
|
|
64
|
-
color: var(--rc-chip-selected-color, revert);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
:host([disabled]) ::slotted(button) {
|
|
68
|
-
opacity: var(--rc-chip-disabled-opacity, revert);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
:host(:focus-within) ::slotted(button),
|
|
72
|
-
:host(:focus-within) ::slotted(a),
|
|
73
|
-
:host(:focus-within) ::slotted(label) {
|
|
74
|
-
outline: var(--rc-chip-focus-ring, revert);
|
|
75
|
-
outline-offset: var(--rc-chip-focus-ring-offset, revert);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
[part='state-layer'] {
|
|
79
|
-
pointer-events: none;
|
|
80
|
-
position: absolute;
|
|
81
|
-
z-index: 2;
|
|
82
|
-
inset-inline: 0;
|
|
83
|
-
inset-block-start: 50%;
|
|
84
|
-
block-size: var(--rc-chip-block-size, 100%);
|
|
85
|
-
translate: 0 -50%;
|
|
86
|
-
border-radius: var(--rc-chip-radius, 0);
|
|
87
|
-
background: var(--rc-chip-state-layer-color, currentColor);
|
|
88
|
-
opacity: 0;
|
|
89
|
-
transition: opacity
|
|
90
|
-
var(--rc-chip-state-layer-transition-duration, var(--rc-motion-effects-duration-fast, 80ms))
|
|
91
|
-
var(--rc-chip-state-layer-transition-easing, var(--rc-motion-effects-easing-fast, ease-out));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
:host([selected]) [part='state-layer'] {
|
|
95
|
-
background: var(
|
|
96
|
-
--rc-chip-selected-state-layer-color,
|
|
97
|
-
var(--rc-chip-state-layer-color, currentColor)
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@media (hover: hover) {
|
|
102
|
-
:host(:not([disabled], [readonly]):hover) [part='state-layer'] {
|
|
103
|
-
opacity: var(--rc-chip-hover-state-layer-opacity, 0.08);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
:host(:not([disabled], [readonly]):focus-within) [part='state-layer'] {
|
|
108
|
-
opacity: var(--rc-chip-focus-state-layer-opacity, 0.12);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
:host(:not([disabled], [readonly]):active) [part='state-layer'] {
|
|
112
|
-
opacity: var(--rc-chip-pressed-state-layer-opacity, 0.12);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
[part='remove'] {
|
|
116
|
-
position: absolute;
|
|
117
|
-
z-index: 3;
|
|
118
|
-
pointer-events: none;
|
|
119
|
-
inset-block-start: 50%;
|
|
120
|
-
inset-inline-end: var(--rc-chip-remove-offset-inline, 0.125rem);
|
|
121
|
-
display: none;
|
|
122
|
-
place-items: center;
|
|
123
|
-
min-inline-size: var(--rc-chip-remove-target-size, 1.5rem);
|
|
124
|
-
min-block-size: var(--rc-chip-remove-target-size, 1.5rem);
|
|
125
|
-
translate: 0 -50%;
|
|
126
|
-
border: 0;
|
|
127
|
-
border-radius: var(--rc-chip-remove-radius, 9999px);
|
|
128
|
-
background: transparent;
|
|
129
|
-
color: inherit;
|
|
130
|
-
font: inherit;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
:host([removable]) [part='remove'] {
|
|
134
|
-
display: inline-grid;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
::slotted([slot='remove-icon']) {
|
|
138
|
-
/* Keep icon-font utility classes from overriding the chip's compact icon size. */
|
|
139
|
-
font-size: var(--rc-chip-remove-icon-size, smaller) !important;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
:host([removable]) ::slotted(button),
|
|
143
|
-
:host([removable]) ::slotted(a),
|
|
144
|
-
:host([removable]) ::slotted(label),
|
|
145
|
-
:host([removable]) ::slotted([data-rc-chip-label]) {
|
|
146
|
-
padding-inline-end: var(
|
|
147
|
-
--rc-chip-removable-padding-inline-end,
|
|
148
|
-
calc(var(--rc-chip-remove-target-size, 1.5rem) - var(--rc-chip-gap, 0px))
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
@media (forced-colors: active) {
|
|
153
|
-
[part='state-layer'] {
|
|
154
|
-
display: none;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
::slotted(button),
|
|
158
|
-
::slotted(a),
|
|
159
|
-
::slotted(label),
|
|
160
|
-
::slotted([data-rc-chip-label]) {
|
|
161
|
-
border-color: ButtonBorder;
|
|
162
|
-
background: ButtonFace;
|
|
163
|
-
color: ButtonText;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
:host([selected]) ::slotted(button),
|
|
167
|
-
:host([selected]) ::slotted(a),
|
|
168
|
-
:host([selected]) ::slotted(label),
|
|
169
|
-
:host([selected]) ::slotted([data-rc-chip-label]) {
|
|
170
|
-
border-color: Highlight;
|
|
171
|
-
background: Highlight;
|
|
172
|
-
color: HighlightText;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
`;
|
|
176
|
-
var v = Object.defineProperty, f = Object.getOwnPropertyDescriptor, n = (d, e, t, s) => {
|
|
177
|
-
for (var i = s > 1 ? void 0 : s ? f(e, t) : e, o = d.length - 1, c; o >= 0; o--)
|
|
178
|
-
(c = d[o]) && (i = (s ? c(e, t, i) : c(i)) || i);
|
|
179
|
-
return s && i && v(e, t, i), i;
|
|
180
|
-
};
|
|
181
|
-
const _ = /* @__PURE__ */ new Set(["checkbox", "menuitemcheckbox", "menuitemradio", "radio", "switch"]), y = `
|
|
182
|
-
rc-chip > :is(button, a, label, [data-rc-chip-label]) {
|
|
183
|
-
position: relative;
|
|
184
|
-
display: inline-flex;
|
|
185
|
-
box-sizing: border-box;
|
|
186
|
-
align-items: center;
|
|
187
|
-
justify-content: center;
|
|
188
|
-
gap: var(--rc-chip-gap, 0px);
|
|
189
|
-
min-block-size: var(--rc-chip-block-size, revert);
|
|
190
|
-
margin: 0;
|
|
191
|
-
padding-block: var(--rc-chip-padding-block, revert);
|
|
192
|
-
padding-inline: var(--rc-chip-padding-inline, revert);
|
|
193
|
-
border: var(--rc-chip-border, revert);
|
|
194
|
-
border-radius: var(--rc-chip-radius, revert);
|
|
195
|
-
background: var(--rc-chip-bg, revert);
|
|
196
|
-
color: var(--rc-chip-color, revert);
|
|
197
|
-
font: var(--rc-chip-font, revert);
|
|
198
|
-
text-decoration: var(--rc-chip-text-decoration, revert);
|
|
199
|
-
white-space: nowrap;
|
|
200
|
-
-webkit-tap-highlight-color: transparent;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
rc-chip:not([readonly]) > :is(button, a, label)::before {
|
|
204
|
-
content: '';
|
|
205
|
-
position: absolute;
|
|
206
|
-
z-index: 1;
|
|
207
|
-
inset-block: calc(
|
|
208
|
-
(var(--rc-chip-touch-target-block-size, 3rem) - max(100%, var(--rc-chip-block-size, 0px))) /
|
|
209
|
-
-2
|
|
210
|
-
);
|
|
211
|
-
inset-inline: 0;
|
|
212
|
-
border-radius: inherit;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
rc-chip[selected] > :is(button, a, label, [data-rc-chip-label]),
|
|
216
|
-
rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):checked) {
|
|
217
|
-
border-color: var(--rc-chip-selected-border-color, revert);
|
|
218
|
-
background: var(--rc-chip-selected-bg, revert);
|
|
219
|
-
color: var(--rc-chip-selected-color, revert);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
rc-chip[disabled] > :is(button, label),
|
|
223
|
-
rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):disabled) {
|
|
224
|
-
opacity: var(--rc-chip-disabled-opacity, revert);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
rc-chip > :is(button, a):focus-visible,
|
|
228
|
-
rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):focus-visible) {
|
|
229
|
-
outline: var(--rc-chip-focus-ring, revert);
|
|
230
|
-
outline-offset: var(--rc-chip-focus-ring-offset, revert);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
rc-chip > label > input:is([type='checkbox'], [type='radio']) {
|
|
234
|
-
position: absolute;
|
|
235
|
-
inline-size: 1px;
|
|
236
|
-
block-size: 1px;
|
|
237
|
-
margin: -1px;
|
|
238
|
-
padding: 0;
|
|
239
|
-
overflow: hidden;
|
|
240
|
-
clip-path: inset(50%);
|
|
241
|
-
white-space: nowrap;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
rc-chip[removable] > :is(button, a, label, [data-rc-chip-label]) {
|
|
245
|
-
padding-inline-end: var(
|
|
246
|
-
--rc-chip-removable-padding-inline-end,
|
|
247
|
-
calc(var(--rc-chip-remove-target-size, 1.5rem) - var(--rc-chip-gap, 0px))
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
@media (forced-colors: active) {
|
|
252
|
-
rc-chip > :is(button, a, label, [data-rc-chip-label]) {
|
|
253
|
-
border-color: ButtonBorder;
|
|
254
|
-
background: ButtonFace;
|
|
255
|
-
color: ButtonText;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
rc-chip[selected] > :is(button, a, label, [data-rc-chip-label]),
|
|
259
|
-
rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):checked) {
|
|
260
|
-
border-color: Highlight;
|
|
261
|
-
background: Highlight;
|
|
262
|
-
color: HighlightText;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
`;
|
|
266
|
-
var r;
|
|
267
|
-
const a = (r = class extends u {
|
|
268
|
-
constructor() {
|
|
269
|
-
super(...arguments), this._defaultSelected = !1, this._selectedInitialized = !1, this._$button = null, this._$input = null, this._$form = null, this._controlObserver = null, this._disabledOwned = !1, this._pressedOwned = !1, this._slotMicrotaskQueued = !1, this._lastChildWarning = null, this.variant = "assist", this.disabled = !1, this.readonly = !1, this.removable = !1, this._handleNativeChange = () => {
|
|
270
|
-
const e = this._$input;
|
|
271
|
-
if (!e || this.disabled || this.readonly)
|
|
272
|
-
return;
|
|
273
|
-
const t = this.selected, s = e.checked;
|
|
274
|
-
this._selected === void 0 ? (this._uncontrolledSelected = s, this._selectedInitialized = !0, this.requestUpdate("selected", t)) : this._syncCheckedState(), this.dispatchEvent(
|
|
275
|
-
new CustomEvent("rc-chip-change", {
|
|
276
|
-
bubbles: !0,
|
|
277
|
-
composed: !0,
|
|
278
|
-
detail: { selected: s }
|
|
279
|
-
})
|
|
280
|
-
);
|
|
281
|
-
}, this._handleButtonClick = () => {
|
|
282
|
-
if (this.disabled || this.readonly)
|
|
283
|
-
return;
|
|
284
|
-
if (this.removable) {
|
|
285
|
-
this._dispatchRemove();
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
if (this.variant !== "filter")
|
|
289
|
-
return;
|
|
290
|
-
const e = this._$button?.getAttribute("aria-haspopup");
|
|
291
|
-
if (e && e !== "false")
|
|
292
|
-
return;
|
|
293
|
-
const t = this.selected, s = !t;
|
|
294
|
-
this._selected === void 0 && (this._uncontrolledSelected = s, this._selectedInitialized = !0, this._syncPressedState(), this.requestUpdate("selected", t)), this.dispatchEvent(
|
|
295
|
-
new CustomEvent("rc-chip-change", {
|
|
296
|
-
bubbles: !0,
|
|
297
|
-
composed: !0,
|
|
298
|
-
detail: { selected: s }
|
|
299
|
-
})
|
|
300
|
-
);
|
|
301
|
-
}, this._handleFormReset = () => {
|
|
302
|
-
queueMicrotask(() => this._syncCheckedFromNative());
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
static _ensureBaseStyles(e) {
|
|
306
|
-
if (r._styledRoots.has(e))
|
|
307
|
-
return;
|
|
308
|
-
r._styledRoots.add(e);
|
|
309
|
-
const t = (e instanceof Document ? e : e.ownerDocument).createElement("style");
|
|
310
|
-
t.setAttribute("data-rc-light-dom-base", "rc-chip"), t.textContent = y, e instanceof Document ? e.head.append(t) : e.append(t);
|
|
311
|
-
}
|
|
312
|
-
get selected() {
|
|
313
|
-
return this._selected ?? this._uncontrolledSelected ?? this._defaultSelected;
|
|
314
|
-
}
|
|
315
|
-
set selected(e) {
|
|
316
|
-
const t = this.selected;
|
|
317
|
-
this._selected = e, this._selectedInitialized = !0, this._syncCheckedState(), this._syncPressedState(), this.requestUpdate("selected", t);
|
|
318
|
-
}
|
|
319
|
-
get defaultSelected() {
|
|
320
|
-
return this._defaultSelected;
|
|
321
|
-
}
|
|
322
|
-
set defaultSelected(e) {
|
|
323
|
-
const t = this._defaultSelected;
|
|
324
|
-
this._defaultSelected = e, !this._selectedInitialized && this._selected === void 0 && this._uncontrolledSelected === void 0 && (this._syncPressedState(), this.requestUpdate("selected", t)), this.requestUpdate("defaultSelected", t);
|
|
325
|
-
}
|
|
326
|
-
connectedCallback() {
|
|
327
|
-
super.connectedCallback(), r._ensureBaseStyles(this.getRootNode());
|
|
328
|
-
}
|
|
329
|
-
disconnectedCallback() {
|
|
330
|
-
this._$button?.removeEventListener("click", this._handleButtonClick), this._$input?.removeEventListener("change", this._handleNativeChange), this._$form?.removeEventListener("reset", this._handleFormReset), this._controlObserver?.disconnect(), this._controlObserver = null, super.disconnectedCallback();
|
|
331
|
-
}
|
|
332
|
-
/** Synchronizes uncontrolled filter state from the direct native input. @internal */
|
|
333
|
-
syncNativeSelection() {
|
|
334
|
-
this._syncCheckedFromNative();
|
|
335
|
-
}
|
|
336
|
-
firstUpdated() {
|
|
337
|
-
this._syncSlottedButton(!0);
|
|
338
|
-
}
|
|
339
|
-
updated(e) {
|
|
340
|
-
(e.has("disabled") || e.has("readonly")) && this._syncDisabled(), (e.has("variant") || e.has("selected") || e.has("readonly") || e.has("removable")) && this._syncPressedState(), e.has("selected") && this._syncCheckedState();
|
|
341
|
-
}
|
|
342
|
-
render() {
|
|
343
|
-
return h`
|
|
344
|
-
<slot @slotchange=${this._handleSlotChange}></slot>
|
|
345
|
-
<span part="state-layer" aria-hidden="true"></span>
|
|
346
|
-
${this.removable ? h`
|
|
347
|
-
<span part="remove" aria-hidden="true">
|
|
348
|
-
<slot name="remove-icon">×</slot>
|
|
349
|
-
</span>
|
|
350
|
-
` : ""}
|
|
351
|
-
`;
|
|
352
|
-
}
|
|
353
|
-
_handleSlotChange() {
|
|
354
|
-
this._slotMicrotaskQueued || (this._slotMicrotaskQueued = !0, queueMicrotask(() => {
|
|
355
|
-
this._slotMicrotaskQueued = !1, this.isConnected && this._syncSlottedButton();
|
|
356
|
-
}));
|
|
357
|
-
}
|
|
358
|
-
_syncSlottedButton(e = !1) {
|
|
359
|
-
const t = this.querySelector(":scope > button");
|
|
360
|
-
this.querySelector(":scope > a[href]");
|
|
361
|
-
const i = this.querySelector(":scope > label")?.querySelector(
|
|
362
|
-
':scope > input:is([type="checkbox"], [type="radio"])'
|
|
363
|
-
) ?? null;
|
|
364
|
-
if (t === this._$button && i === this._$input) {
|
|
365
|
-
this._syncDisabled(), this._syncCheckedState(), this._syncPressedState();
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
if (this._$button?.removeEventListener("click", this._handleButtonClick), this._$input?.removeEventListener("change", this._handleNativeChange), this._$form?.removeEventListener("reset", this._handleFormReset), this._controlObserver?.disconnect(), this._controlObserver = null, this._$button = t, this._$input = i, this._$form = i?.form ?? null, this._disabledOwned = !1, this._pressedOwned = !1, t && t.addEventListener("click", this._handleButtonClick), i) {
|
|
369
|
-
if (this._selected === void 0 && this._uncontrolledSelected === void 0) {
|
|
370
|
-
const c = this.selected;
|
|
371
|
-
this._uncontrolledSelected = i.checked, this._selectedInitialized = !0, e ? queueMicrotask(() => this.requestUpdate("selected", c)) : this.requestUpdate("selected", c);
|
|
372
|
-
} else
|
|
373
|
-
this._syncCheckedState();
|
|
374
|
-
i.addEventListener("change", this._handleNativeChange), this._$form?.addEventListener("reset", this._handleFormReset);
|
|
375
|
-
}
|
|
376
|
-
const o = i ?? t;
|
|
377
|
-
o && (this._controlObserver = new MutationObserver(() => {
|
|
378
|
-
this._syncDisabled(), this._syncCheckedFromNative(), this._syncPressedState();
|
|
379
|
-
}), this._controlObserver.observe(o, {
|
|
380
|
-
attributeFilter: ["aria-pressed", "role", "disabled", "checked"]
|
|
381
|
-
})), this._syncDisabled(), this._syncCheckedState(), this._syncPressedState();
|
|
382
|
-
}
|
|
383
|
-
_dispatchRemove() {
|
|
384
|
-
this.dispatchEvent(
|
|
385
|
-
new CustomEvent("rc-chip-remove", {
|
|
386
|
-
bubbles: !0,
|
|
387
|
-
composed: !0,
|
|
388
|
-
detail: { chip: this }
|
|
389
|
-
})
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
_syncDisabled() {
|
|
393
|
-
const e = this._$input ?? this._$button;
|
|
394
|
-
e && (this.disabled || this.readonly ? (e.disabled || (this._disabledOwned = !0), e.disabled = !0) : this._disabledOwned && (e.disabled = !1, this._disabledOwned = !1));
|
|
395
|
-
}
|
|
396
|
-
_syncCheckedState() {
|
|
397
|
-
const e = this._$input;
|
|
398
|
-
e && e.checked !== this.selected && (e.checked = this.selected);
|
|
399
|
-
}
|
|
400
|
-
_syncCheckedFromNative() {
|
|
401
|
-
const e = this._$input;
|
|
402
|
-
if (!e || e.checked === this.selected)
|
|
403
|
-
return;
|
|
404
|
-
const t = this.selected;
|
|
405
|
-
this._selected === void 0 ? (this._uncontrolledSelected = e.checked, this._selectedInitialized = !0, this.requestUpdate("selected", t)) : this._syncCheckedState();
|
|
406
|
-
}
|
|
407
|
-
_syncPressedState() {
|
|
408
|
-
const e = this._$button;
|
|
409
|
-
if (!e)
|
|
410
|
-
return;
|
|
411
|
-
const t = e.getAttribute("role"), s = e.hasAttribute("aria-pressed") && !this._pressedOwned || (t ? _.has(t) : !1);
|
|
412
|
-
if (!this.readonly && !this.removable && this.variant === "filter" && !s) {
|
|
413
|
-
const i = this.selected ? "true" : "false";
|
|
414
|
-
e.getAttribute("aria-pressed") !== i && e.setAttribute("aria-pressed", i), this._pressedOwned = !0;
|
|
415
|
-
} else this._pressedOwned && (e.removeAttribute("aria-pressed"), this._pressedOwned = !1);
|
|
416
|
-
}
|
|
417
|
-
}, r.styles = b, r._styledRoots = /* @__PURE__ */ new WeakSet(), r);
|
|
418
|
-
n([
|
|
419
|
-
l({ type: String, reflect: !0 })
|
|
420
|
-
], a.prototype, "variant", 2);
|
|
421
|
-
n([
|
|
422
|
-
l({ type: Boolean, reflect: !0 })
|
|
423
|
-
], a.prototype, "selected", 1);
|
|
424
|
-
n([
|
|
425
|
-
l({ type: Boolean, attribute: "default-selected" })
|
|
426
|
-
], a.prototype, "defaultSelected", 1);
|
|
427
|
-
n([
|
|
428
|
-
l({ type: Boolean, reflect: !0 })
|
|
429
|
-
], a.prototype, "disabled", 2);
|
|
430
|
-
n([
|
|
431
|
-
l({ type: Boolean, reflect: !0 })
|
|
432
|
-
], a.prototype, "readonly", 2);
|
|
433
|
-
n([
|
|
434
|
-
l({ type: Boolean, reflect: !0 })
|
|
435
|
-
], a.prototype, "removable", 2);
|
|
436
|
-
let k = a;
|
|
437
|
-
export {
|
|
438
|
-
k as R
|
|
439
|
-
};
|
|
440
|
-
//# sourceMappingURL=rc-chip-B71-Icgf.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rc-chip-B71-Icgf.js","sources":["../src/rc-chip.styles.ts","../src/rc-chip.ts"],"sourcesContent":["import { css } from 'lit';\n\nexport const chipStyles = css`\n :host {\n display: inline-grid;\n position: relative;\n place-items: center;\n min-block-size: var(--rc-chip-touch-target-block-size, 3rem);\n color-scheme: inherit;\n vertical-align: middle;\n /*\n * Zero by default. Unlike rc-button's touch-target inflation (opt-in via\n * icon-only), a chip's accessible touch-target minimum applies\n * unconditionally, so it's a common fit inside a height-constrained\n * field -- rc-search-bar's or rc-combobox's multi-select value area, say\n * -- where 3rem per chip would force the field taller than its own\n * content needs. A theme or consumer sets one of these on a chip that\n * sits at a real block-axis edge (no neighbor on that side within the\n * field) to let the touch target overlap into the field's own block\n * padding instead of also reserving layout space there. The same\n * pattern as rc-button's, rc-menu-button's, and rc-adaptive-menu's own\n * touch-target overlap tokens, but on the block axis: a chip's own\n * touch-target inflation is vertical, not horizontal.\n */\n margin-block-start: calc(-1 * var(--rc-chip-touch-target-overlap-block-start, 0px));\n margin-block-end: calc(-1 * var(--rc-chip-touch-target-overlap-block-end, 0px));\n }\n\n :host([readonly]) {\n min-block-size: var(--rc-chip-block-size, auto);\n }\n\n :host([hidden]) {\n display: none;\n }\n\n ::slotted(button),\n ::slotted(a),\n ::slotted(label),\n ::slotted([data-rc-chip-label]) {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--rc-chip-gap, 0px);\n min-block-size: var(--rc-chip-block-size);\n padding-block: var(--rc-chip-padding-block, revert);\n padding-inline: var(--rc-chip-padding-inline, revert);\n border: var(--rc-chip-border, revert);\n border-radius: var(--rc-chip-radius, revert);\n background: var(--rc-chip-bg, revert);\n color: var(--rc-chip-color, revert);\n font: var(--rc-chip-font, revert);\n text-decoration: var(--rc-chip-text-decoration, revert);\n white-space: nowrap;\n -webkit-tap-highlight-color: transparent;\n }\n\n :host([selected]) ::slotted(button),\n :host([selected]) ::slotted(a),\n :host([selected]) ::slotted(label),\n :host([selected]) ::slotted([data-rc-chip-label]) {\n border-color: var(--rc-chip-selected-border-color, revert);\n background: var(--rc-chip-selected-bg, revert);\n color: var(--rc-chip-selected-color, revert);\n }\n\n :host([disabled]) ::slotted(button) {\n opacity: var(--rc-chip-disabled-opacity, revert);\n }\n\n :host(:focus-within) ::slotted(button),\n :host(:focus-within) ::slotted(a),\n :host(:focus-within) ::slotted(label) {\n outline: var(--rc-chip-focus-ring, revert);\n outline-offset: var(--rc-chip-focus-ring-offset, revert);\n }\n\n [part='state-layer'] {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n inset-inline: 0;\n inset-block-start: 50%;\n block-size: var(--rc-chip-block-size, 100%);\n translate: 0 -50%;\n border-radius: var(--rc-chip-radius, 0);\n background: var(--rc-chip-state-layer-color, currentColor);\n opacity: 0;\n transition: opacity\n var(--rc-chip-state-layer-transition-duration, var(--rc-motion-effects-duration-fast, 80ms))\n var(--rc-chip-state-layer-transition-easing, var(--rc-motion-effects-easing-fast, ease-out));\n }\n\n :host([selected]) [part='state-layer'] {\n background: var(\n --rc-chip-selected-state-layer-color,\n var(--rc-chip-state-layer-color, currentColor)\n );\n }\n\n @media (hover: hover) {\n :host(:not([disabled], [readonly]):hover) [part='state-layer'] {\n opacity: var(--rc-chip-hover-state-layer-opacity, 0.08);\n }\n }\n\n :host(:not([disabled], [readonly]):focus-within) [part='state-layer'] {\n opacity: var(--rc-chip-focus-state-layer-opacity, 0.12);\n }\n\n :host(:not([disabled], [readonly]):active) [part='state-layer'] {\n opacity: var(--rc-chip-pressed-state-layer-opacity, 0.12);\n }\n\n [part='remove'] {\n position: absolute;\n z-index: 3;\n pointer-events: none;\n inset-block-start: 50%;\n inset-inline-end: var(--rc-chip-remove-offset-inline, 0.125rem);\n display: none;\n place-items: center;\n min-inline-size: var(--rc-chip-remove-target-size, 1.5rem);\n min-block-size: var(--rc-chip-remove-target-size, 1.5rem);\n translate: 0 -50%;\n border: 0;\n border-radius: var(--rc-chip-remove-radius, 9999px);\n background: transparent;\n color: inherit;\n font: inherit;\n }\n\n :host([removable]) [part='remove'] {\n display: inline-grid;\n }\n\n ::slotted([slot='remove-icon']) {\n /* Keep icon-font utility classes from overriding the chip's compact icon size. */\n font-size: var(--rc-chip-remove-icon-size, smaller) !important;\n }\n\n :host([removable]) ::slotted(button),\n :host([removable]) ::slotted(a),\n :host([removable]) ::slotted(label),\n :host([removable]) ::slotted([data-rc-chip-label]) {\n padding-inline-end: var(\n --rc-chip-removable-padding-inline-end,\n calc(var(--rc-chip-remove-target-size, 1.5rem) - var(--rc-chip-gap, 0px))\n );\n }\n\n @media (forced-colors: active) {\n [part='state-layer'] {\n display: none;\n }\n\n ::slotted(button),\n ::slotted(a),\n ::slotted(label),\n ::slotted([data-rc-chip-label]) {\n border-color: ButtonBorder;\n background: ButtonFace;\n color: ButtonText;\n }\n\n :host([selected]) ::slotted(button),\n :host([selected]) ::slotted(a),\n :host([selected]) ::slotted(label),\n :host([selected]) ::slotted([data-rc-chip-label]) {\n border-color: Highlight;\n background: Highlight;\n color: HighlightText;\n }\n }\n`;\n\nexport default chipStyles;\n","import { LitElement, html } from 'lit';\nimport type { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport chipStyles from './rc-chip.styles.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'rc-chip': RCChip;\n }\n\n interface HTMLElementEventMap {\n 'rc-chip-change': CustomEvent<RCChipChangeDetail>;\n 'rc-chip-remove': CustomEvent<RCChipRemoveDetail>;\n }\n}\n\nconst TOGGLE_ROLES = new Set(['checkbox', 'menuitemcheckbox', 'menuitemradio', 'radio', 'switch']);\n\nconst LIGHT_DOM_CSS = `\nrc-chip > :is(button, a, label, [data-rc-chip-label]) {\n position: relative;\n display: inline-flex;\n box-sizing: border-box;\n align-items: center;\n justify-content: center;\n gap: var(--rc-chip-gap, 0px);\n min-block-size: var(--rc-chip-block-size, revert);\n margin: 0;\n padding-block: var(--rc-chip-padding-block, revert);\n padding-inline: var(--rc-chip-padding-inline, revert);\n border: var(--rc-chip-border, revert);\n border-radius: var(--rc-chip-radius, revert);\n background: var(--rc-chip-bg, revert);\n color: var(--rc-chip-color, revert);\n font: var(--rc-chip-font, revert);\n text-decoration: var(--rc-chip-text-decoration, revert);\n white-space: nowrap;\n -webkit-tap-highlight-color: transparent;\n}\n\nrc-chip:not([readonly]) > :is(button, a, label)::before {\n content: '';\n position: absolute;\n z-index: 1;\n inset-block: calc(\n (var(--rc-chip-touch-target-block-size, 3rem) - max(100%, var(--rc-chip-block-size, 0px))) /\n -2\n );\n inset-inline: 0;\n border-radius: inherit;\n}\n\nrc-chip[selected] > :is(button, a, label, [data-rc-chip-label]),\nrc-chip > label:has(> input:is([type='checkbox'], [type='radio']):checked) {\n border-color: var(--rc-chip-selected-border-color, revert);\n background: var(--rc-chip-selected-bg, revert);\n color: var(--rc-chip-selected-color, revert);\n}\n\nrc-chip[disabled] > :is(button, label),\nrc-chip > label:has(> input:is([type='checkbox'], [type='radio']):disabled) {\n opacity: var(--rc-chip-disabled-opacity, revert);\n}\n\nrc-chip > :is(button, a):focus-visible,\nrc-chip > label:has(> input:is([type='checkbox'], [type='radio']):focus-visible) {\n outline: var(--rc-chip-focus-ring, revert);\n outline-offset: var(--rc-chip-focus-ring-offset, revert);\n}\n\nrc-chip > label > input:is([type='checkbox'], [type='radio']) {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n}\n\nrc-chip[removable] > :is(button, a, label, [data-rc-chip-label]) {\n padding-inline-end: var(\n --rc-chip-removable-padding-inline-end,\n calc(var(--rc-chip-remove-target-size, 1.5rem) - var(--rc-chip-gap, 0px))\n );\n}\n\n@media (forced-colors: active) {\n rc-chip > :is(button, a, label, [data-rc-chip-label]) {\n border-color: ButtonBorder;\n background: ButtonFace;\n color: ButtonText;\n }\n\n rc-chip[selected] > :is(button, a, label, [data-rc-chip-label]),\n rc-chip > label:has(> input:is([type='checkbox'], [type='radio']):checked) {\n border-color: Highlight;\n background: Highlight;\n color: HighlightText;\n }\n}\n`;\n\n/** Supported chip variants. */\nexport type RCChipVariant = 'assist' | 'filter' | 'input' | 'suggestion';\n\n/** Detail payload for `rc-chip-change`. */\nexport interface RCChipChangeDetail {\n /** Selected state after user interaction. */\n selected: boolean;\n}\n\n/** Detail payload for `rc-chip-remove`. */\nexport interface RCChipRemoveDetail {\n /** The host chip requesting removal. */\n chip: RCChip;\n}\n\n/**\n * Chip wrapper that preserves a direct native `<button>` child for action chips,\n * a direct `<a href>` for navigation chips, or a direct `<label>` containing a\n * native checkbox/radio for filter chips. Read-only chips accept a direct\n * `[data-rc-chip-label]` child.\n *\n * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-chip rc-chip docs}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/button/ WAI-ARIA button pattern}\n *\n * @slot - A direct native `<button>` child, `<a href>`, native-backed filter\n * `<label>`, or `[data-rc-chip-label]` when `readonly`.\n * @slot remove-icon - Optional presentational remove icon.\n *\n * @fires rc-chip-change - Fired when a user toggles a filter chip.\n * @fires rc-chip-remove - Fired when a user activates a removable chip's native button.\n *\n * @csspart state-layer - Overlay layer for hover, focus, pressed, ripple, or design-system effects.\n * @csspart remove - Presentational trailing remove indicator.\n *\n * @cssprop [--rc-chip-gap=0px] - Gap between the slotted button/anchor/label's content.\n * @cssprop [--rc-chip-block-size] - Minimum chip block size (defers to native button/anchor\n * sizing when unset).\n * @cssprop [--rc-chip-touch-target-block-size=3rem] - Minimum interactive touch target size.\n * @cssprop [--rc-chip-touch-target-overlap-block-start=0px] - Zero by default. A theme or\n * consumer sets this on a chip that sits at a real block-axis leading edge (no neighbor on\n * that side), such as inside a height-constrained field, to let its touch-target inflation\n * overlap into whatever sits just outside the host instead of also reserving layout space\n * there.\n * @cssprop [--rc-chip-touch-target-overlap-block-end=0px] - The block-axis trailing-edge\n * counterpart to `--rc-chip-touch-target-overlap-block-start`.\n * @cssprop [--rc-chip-padding-block] - Block-axis padding of the slotted button, anchor, or\n * label (defers to native padding when unset).\n * @cssprop [--rc-chip-padding-inline] - Inline-axis padding of the slotted button, anchor, or\n * label (defers to native padding when unset).\n * @cssprop [--rc-chip-border] - Border of the slotted button, anchor, or label (defers to\n * native border when unset).\n * @cssprop [--rc-chip-radius] - Border radius of the slotted button/anchor/label and the\n * state-layer overlay (defers to native border-radius when unset; the state-layer overlay\n * falls back to 0).\n * @cssprop [--rc-chip-bg] - Background of the slotted button, anchor, or label (defers to\n * native background when unset).\n * @cssprop [--rc-chip-color] - Text color of the slotted button, anchor, or label (defers to\n * native color when unset).\n * @cssprop [--rc-chip-font] - Font shorthand for the slotted button, anchor, or label (defers\n * to native font when unset).\n * @cssprop [--rc-chip-text-decoration] - Text decoration for the slotted anchor (defers to\n * native text-decoration when unset).\n * @cssprop [--rc-chip-selected-border-color] - Border color when `selected` (defers to native\n * styling when unset).\n * @cssprop [--rc-chip-selected-bg] - Background when `selected` (defers to native styling when\n * unset).\n * @cssprop [--rc-chip-selected-color] - Text color when `selected` (defers to native styling\n * when unset).\n * @cssprop [--rc-chip-disabled-opacity] - Opacity of the slotted button when `disabled` (defers\n * to native disabled styling when unset).\n * @cssprop [--rc-chip-focus-ring] - Outline shown while focus-within (defers to native focus\n * styling when unset).\n * @cssprop [--rc-chip-focus-ring-offset] - Outline offset while focus-within (defers to native\n * focus styling when unset).\n * @cssprop [--rc-chip-state-layer-color=currentColor] - Hover/focus/pressed state-layer color.\n * @cssprop [--rc-chip-selected-state-layer-color=var(--rc-chip-state-layer-color, currentColor)] - Selected chip state-layer color.\n * @cssprop [--rc-chip-hover-state-layer-opacity=0.08] - Hover state-layer opacity.\n * @cssprop [--rc-chip-focus-state-layer-opacity=0.12] - Focus state-layer opacity.\n * @cssprop [--rc-chip-pressed-state-layer-opacity=0.12] - Pressed state-layer opacity.\n * @cssprop [--rc-chip-state-layer-transition-duration=var(--rc-motion-effects-duration-fast,80ms)] - State-layer effects duration.\n * @cssprop [--rc-chip-state-layer-transition-easing=var(--rc-motion-effects-easing-fast,ease-out)] - State-layer effects easing.\n * @cssprop [--rc-chip-remove-offset-inline=0.125rem] - Inline offset of the remove indicator\n * from the chip edge.\n * @cssprop [--rc-chip-remove-target-size=1.5rem] - Minimum inline and block size of the remove\n * indicator's hit target.\n * @cssprop [--rc-chip-remove-radius=9999px] - Border radius of the remove indicator.\n * @cssprop [--rc-chip-remove-icon-size=smaller] - Font size for a slotted remove icon.\n * @cssprop [--rc-chip-removable-padding-inline-end=calc(var(--rc-chip-remove-target-size, 1.5rem) - var(--rc-chip-gap, 0px))] - Override for removable chip content end padding.\n *\n * @attr variant - Chip variant: `assist`, `filter`, `input`, or `suggestion`.\n * @attr selected - Declarative selected state for filter/input chips.\n * @attr default-selected - Initial selected state for uncontrolled usage.\n * @attr disabled - Mirrors disabled state to the native child button.\n * @attr readonly - Marks the chip as non-interactive display content.\n * @attr removable - Shows a trailing remove affordance.\n */\nexport class RCChip extends LitElement {\n static override styles = chipStyles;\n\n private static readonly _styledRoots = new WeakSet<Document | ShadowRoot>();\n\n private static _ensureBaseStyles(root: Document | ShadowRoot): void {\n if (RCChip._styledRoots.has(root)) {\n return;\n }\n\n RCChip._styledRoots.add(root);\n\n const $style = (root instanceof Document ? root : root.ownerDocument).createElement('style');\n\n $style.setAttribute('data-rc-light-dom-base', 'rc-chip');\n $style.textContent = LIGHT_DOM_CSS;\n\n if (root instanceof Document) {\n root.head.append($style);\n } else {\n root.append($style);\n }\n }\n\n private _selected: boolean | undefined;\n private _defaultSelected = false;\n private _uncontrolledSelected: boolean | undefined;\n private _selectedInitialized = false;\n private _$button: HTMLButtonElement | null = null;\n private _$input: HTMLInputElement | null = null;\n private _$form: HTMLFormElement | null = null;\n private _controlObserver: MutationObserver | null = null;\n private _disabledOwned = false;\n private _pressedOwned = false;\n private _slotMicrotaskQueued = false;\n private _lastChildWarning: string | null = null;\n\n /** Chip variant. */\n @property({ type: String, reflect: true })\n variant: RCChipVariant = 'assist';\n\n /** Current selected state. Host writes are silent. */\n @property({ type: Boolean, reflect: true })\n get selected(): boolean {\n return this._selected ?? this._uncontrolledSelected ?? this._defaultSelected;\n }\n\n set selected(value: boolean | undefined) {\n const oldValue = this.selected;\n\n this._selected = value;\n this._selectedInitialized = true;\n this._syncCheckedState();\n this._syncPressedState();\n this.requestUpdate('selected', oldValue);\n }\n\n /** Initial selected state for uncontrolled usage. */\n @property({ type: Boolean, attribute: 'default-selected' })\n get defaultSelected(): boolean {\n return this._defaultSelected;\n }\n\n set defaultSelected(value: boolean) {\n const oldValue = this._defaultSelected;\n\n this._defaultSelected = value;\n\n if (\n !this._selectedInitialized &&\n this._selected === undefined &&\n this._uncontrolledSelected === undefined\n ) {\n this._syncPressedState();\n this.requestUpdate('selected', oldValue);\n }\n\n this.requestUpdate('defaultSelected', oldValue);\n }\n\n /** Mirror disabled state to the native child button. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Mark this chip as non-interactive display content. */\n @property({ type: Boolean, reflect: true })\n readonly = false;\n\n /** Show a trailing remove affordance. */\n @property({ type: Boolean, reflect: true })\n removable = false;\n\n override connectedCallback(): void {\n super.connectedCallback();\n RCChip._ensureBaseStyles(this.getRootNode() as Document | ShadowRoot);\n }\n\n override disconnectedCallback(): void {\n this._$button?.removeEventListener('click', this._handleButtonClick);\n this._$input?.removeEventListener('change', this._handleNativeChange);\n this._$form?.removeEventListener('reset', this._handleFormReset);\n this._controlObserver?.disconnect();\n this._controlObserver = null;\n super.disconnectedCallback();\n }\n\n /** Synchronizes uncontrolled filter state from the direct native input. @internal */\n syncNativeSelection(): void {\n this._syncCheckedFromNative();\n }\n\n protected override firstUpdated(): void {\n this._syncSlottedButton(true);\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n if (changed.has('disabled') || changed.has('readonly')) {\n this._syncDisabled();\n }\n\n if (\n changed.has('variant') ||\n changed.has('selected') ||\n changed.has('readonly') ||\n changed.has('removable')\n ) {\n this._syncPressedState();\n }\n\n if (changed.has('selected')) {\n this._syncCheckedState();\n }\n }\n\n protected override render() {\n return html`\n <slot @slotchange=${this._handleSlotChange}></slot>\n <span part=\"state-layer\" aria-hidden=\"true\"></span>\n ${this.removable\n ? html`\n <span part=\"remove\" aria-hidden=\"true\">\n <slot name=\"remove-icon\">×</slot>\n </span>\n `\n : ''}\n `;\n }\n\n private _handleSlotChange(): void {\n if (this._slotMicrotaskQueued) {\n return;\n }\n\n this._slotMicrotaskQueued = true;\n\n queueMicrotask(() => {\n this._slotMicrotaskQueued = false;\n\n if (this.isConnected) {\n this._syncSlottedButton();\n }\n });\n }\n\n private _syncSlottedButton(deferInitialSelectionUpdate = false): void {\n const $nextButton = this.querySelector<HTMLButtonElement>(':scope > button');\n const $anchor = this.querySelector<HTMLAnchorElement>(':scope > a[href]');\n const $label = this.querySelector<HTMLLabelElement>(':scope > label');\n const $nextInput =\n $label?.querySelector<HTMLInputElement>(\n ':scope > input:is([type=\"checkbox\"], [type=\"radio\"])',\n ) ?? null;\n\n if (import.meta.env.DEV) {\n let childWarning: string | null = null;\n\n if (!$nextButton && !$anchor && !$label && !this.readonly) {\n childWarning =\n '[rc-chip] No supported direct child found. Place a native <button>, <a href>, or a <label> containing a direct checkbox/radio inside <rc-chip>, or use readonly with a [data-rc-chip-label] child.';\n } else if ($label && !$nextInput && !this.readonly) {\n childWarning =\n '[rc-chip] A direct child <label> must contain a direct <input type=\"checkbox\"> or <input type=\"radio\">.';\n }\n\n if (childWarning && childWarning !== this._lastChildWarning) {\n console.warn(childWarning);\n }\n\n this._lastChildWarning = childWarning;\n }\n\n if ($nextButton === this._$button && $nextInput === this._$input) {\n this._syncDisabled();\n this._syncCheckedState();\n this._syncPressedState();\n\n return;\n }\n\n this._$button?.removeEventListener('click', this._handleButtonClick);\n this._$input?.removeEventListener('change', this._handleNativeChange);\n this._$form?.removeEventListener('reset', this._handleFormReset);\n this._controlObserver?.disconnect();\n this._controlObserver = null;\n this._$button = $nextButton;\n this._$input = $nextInput;\n this._$form = $nextInput?.form ?? null;\n this._disabledOwned = false;\n this._pressedOwned = false;\n\n if ($nextButton) {\n $nextButton.addEventListener('click', this._handleButtonClick);\n }\n\n if ($nextInput) {\n if (this._selected === undefined && this._uncontrolledSelected === undefined) {\n const oldValue = this.selected;\n\n this._uncontrolledSelected = $nextInput.checked;\n this._selectedInitialized = true;\n\n if (deferInitialSelectionUpdate) {\n queueMicrotask(() => this.requestUpdate('selected', oldValue));\n } else {\n this.requestUpdate('selected', oldValue);\n }\n } else {\n this._syncCheckedState();\n }\n\n $nextInput.addEventListener('change', this._handleNativeChange);\n this._$form?.addEventListener('reset', this._handleFormReset);\n }\n\n const $observedControl = $nextInput ?? $nextButton;\n\n if ($observedControl) {\n this._controlObserver = new MutationObserver(() => {\n this._syncDisabled();\n this._syncCheckedFromNative();\n this._syncPressedState();\n });\n\n this._controlObserver.observe($observedControl, {\n attributeFilter: ['aria-pressed', 'role', 'disabled', 'checked'],\n });\n }\n\n this._syncDisabled();\n this._syncCheckedState();\n this._syncPressedState();\n }\n\n private readonly _handleNativeChange = (): void => {\n const $input = this._$input;\n\n if (!$input || this.disabled || this.readonly) {\n return;\n }\n\n const oldValue = this.selected;\n const requestedSelected = $input.checked;\n\n if (this._selected === undefined) {\n this._uncontrolledSelected = requestedSelected;\n this._selectedInitialized = true;\n this.requestUpdate('selected', oldValue);\n } else {\n this._syncCheckedState();\n }\n\n this.dispatchEvent(\n new CustomEvent<RCChipChangeDetail>('rc-chip-change', {\n bubbles: true,\n composed: true,\n detail: { selected: requestedSelected },\n }),\n );\n };\n\n private readonly _handleButtonClick = (): void => {\n if (this.disabled || this.readonly) {\n return;\n }\n\n if (this.removable) {\n this._dispatchRemove();\n\n return;\n }\n\n if (this.variant !== 'filter') {\n return;\n }\n\n // Menu-backed filter chips expose filter affordance, but their menu owns\n // the eventual selected state. Preserve that author-controlled behavior.\n const hasPopup = this._$button?.getAttribute('aria-haspopup');\n\n if (hasPopup && hasPopup !== 'false') {\n return;\n }\n\n const oldValue = this.selected;\n const requestedSelected = !oldValue;\n\n if (this._selected === undefined) {\n this._uncontrolledSelected = requestedSelected;\n this._selectedInitialized = true;\n this._syncPressedState();\n this.requestUpdate('selected', oldValue);\n }\n\n this.dispatchEvent(\n new CustomEvent<RCChipChangeDetail>('rc-chip-change', {\n bubbles: true,\n composed: true,\n detail: { selected: requestedSelected },\n }),\n );\n };\n\n private _dispatchRemove(): void {\n this.dispatchEvent(\n new CustomEvent<RCChipRemoveDetail>('rc-chip-remove', {\n bubbles: true,\n composed: true,\n detail: { chip: this },\n }),\n );\n }\n\n private _syncDisabled(): void {\n const $control = this._$input ?? this._$button;\n\n if (!$control) {\n return;\n }\n\n if (this.disabled || this.readonly) {\n if (!$control.disabled) {\n this._disabledOwned = true;\n }\n\n $control.disabled = true;\n } else if (this._disabledOwned) {\n $control.disabled = false;\n this._disabledOwned = false;\n }\n }\n\n private _syncCheckedState(): void {\n const $input = this._$input;\n\n if ($input && $input.checked !== this.selected) {\n $input.checked = this.selected;\n }\n }\n\n private _syncCheckedFromNative(): void {\n const $input = this._$input;\n\n if (!$input || $input.checked === this.selected) {\n return;\n }\n\n const oldValue = this.selected;\n\n if (this._selected === undefined) {\n this._uncontrolledSelected = $input.checked;\n this._selectedInitialized = true;\n this.requestUpdate('selected', oldValue);\n } else {\n this._syncCheckedState();\n }\n }\n\n private readonly _handleFormReset = (): void => {\n queueMicrotask(() => this._syncCheckedFromNative());\n };\n\n private _syncPressedState(): void {\n const $button = this._$button;\n\n if (!$button) {\n return;\n }\n\n const role = $button.getAttribute('role');\n const authorOwnsState =\n ($button.hasAttribute('aria-pressed') && !this._pressedOwned) ||\n (role ? TOGGLE_ROLES.has(role) : false);\n\n if (!this.readonly && !this.removable && this.variant === 'filter' && !authorOwnsState) {\n const pressed = this.selected ? 'true' : 'false';\n\n if ($button.getAttribute('aria-pressed') !== pressed) {\n $button.setAttribute('aria-pressed', pressed);\n }\n\n this._pressedOwned = true;\n } else if (this._pressedOwned) {\n $button.removeAttribute('aria-pressed');\n this._pressedOwned = false;\n }\n }\n}\n\nexport default RCChip;\n"],"names":["chipStyles","css","TOGGLE_ROLES","LIGHT_DOM_CSS","_RCChip","_a","LitElement","$input","oldValue","requestedSelected","hasPopup","root","$style","value","changed","html","deferInitialSelectionUpdate","$nextButton","$nextInput","$observedControl","$control","$button","role","authorOwnsState","press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