@rcarls/rc-chip 0.0.0-next-20260921045401
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 +98 -0
- package/README.md +52 -0
- package/dist/custom-elements.json +626 -0
- package/dist/rc-chip-DTfbSSwo.js +455 -0
- package/dist/rc-chip-DTfbSSwo.js.map +1 -0
- package/dist/rc-chip-define.js +3 -0
- package/dist/rc-chip-define.js.map +1 -0
- package/dist/rc-chip.js +5 -0
- package/dist/rc-chip.js.map +1 -0
- package/dist/types/packages/rc-chip/src/define.d.ts +1 -0
- package/dist/types/packages/rc-chip/src/index.d.ts +2 -0
- package/dist/types/packages/rc-chip/src/rc-chip.d.ts +156 -0
- package/dist/types/packages/rc-chip/src/rc-chip.styles.d.ts +2 -0
- package/package.json +62 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'rc-chip': RCChip;
|
|
5
|
+
}
|
|
6
|
+
interface HTMLElementEventMap {
|
|
7
|
+
'rc-chip-change': CustomEvent<RCChipChangeDetail>;
|
|
8
|
+
'rc-chip-remove': CustomEvent<RCChipRemoveDetail>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Supported chip variants. */
|
|
12
|
+
export type RCChipVariant = 'assist' | 'filter' | 'input' | 'suggestion';
|
|
13
|
+
/** Detail payload for `rc-chip-change`. */
|
|
14
|
+
export interface RCChipChangeDetail {
|
|
15
|
+
/** Selected state after user interaction. */
|
|
16
|
+
selected: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Detail payload for `rc-chip-remove`. */
|
|
19
|
+
export interface RCChipRemoveDetail {
|
|
20
|
+
/** The host chip requesting removal. */
|
|
21
|
+
chip: RCChip;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Chip wrapper that preserves a direct native `<button>` child for action chips,
|
|
25
|
+
* a direct `<a href>` for navigation chips, or a direct `<label>` containing a
|
|
26
|
+
* native checkbox/radio for filter chips. Read-only chips accept a direct
|
|
27
|
+
* `[data-rc-chip-label]` child.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-chip rc-chip docs}
|
|
30
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/button/ WAI-ARIA button pattern}
|
|
31
|
+
*
|
|
32
|
+
* @slot - A direct native `<button>` child, `<a href>`, native-backed filter
|
|
33
|
+
* `<label>`, or `[data-rc-chip-label]` when `readonly`.
|
|
34
|
+
* @slot remove-icon - Optional presentational remove icon.
|
|
35
|
+
*
|
|
36
|
+
* @fires rc-chip-change - Fired when a user toggles a filter chip.
|
|
37
|
+
* @fires rc-chip-remove - Fired when a user activates a removable chip's native button.
|
|
38
|
+
*
|
|
39
|
+
* @csspart state-layer - Overlay layer for hover, focus, pressed, ripple, or design-system effects.
|
|
40
|
+
* @csspart remove - Presentational trailing remove indicator.
|
|
41
|
+
*
|
|
42
|
+
* @cssprop [--rc-chip-gap=0px] - Gap between the slotted button/anchor/label's content.
|
|
43
|
+
* @cssprop [--rc-chip-block-size] - Minimum chip block size (defers to native button/anchor
|
|
44
|
+
* sizing when unset).
|
|
45
|
+
* @cssprop [--rc-chip-touch-target-block-size=3rem] - Minimum interactive touch target size.
|
|
46
|
+
* @cssprop [--rc-chip-touch-target-overlap-block-start=0px] - Zero by default. A theme or
|
|
47
|
+
* consumer sets this on a chip that sits at a real block-axis leading edge (no neighbor on
|
|
48
|
+
* that side), such as inside a height-constrained field, to let its touch-target inflation
|
|
49
|
+
* overlap into whatever sits just outside the host instead of also reserving layout space
|
|
50
|
+
* there.
|
|
51
|
+
* @cssprop [--rc-chip-touch-target-overlap-block-end=0px] - The block-axis trailing-edge
|
|
52
|
+
* counterpart to `--rc-chip-touch-target-overlap-block-start`.
|
|
53
|
+
* @cssprop [--rc-chip-padding-block] - Block-axis padding of the slotted button, anchor, or
|
|
54
|
+
* label (defers to native padding when unset).
|
|
55
|
+
* @cssprop [--rc-chip-padding-inline] - Inline-axis padding of the slotted button, anchor, or
|
|
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.
|
|
61
|
+
* @cssprop [--rc-chip-border] - Border of the slotted button, anchor, or label (defers to
|
|
62
|
+
* native border when unset).
|
|
63
|
+
* @cssprop [--rc-chip-radius] - Border radius of the slotted button/anchor/label and the
|
|
64
|
+
* state-layer overlay (defers to native border-radius when unset; the state-layer overlay
|
|
65
|
+
* falls back to 0).
|
|
66
|
+
* @cssprop [--rc-chip-bg] - Background of the slotted button, anchor, or label (defers to
|
|
67
|
+
* native background when unset).
|
|
68
|
+
* @cssprop [--rc-chip-color] - Text color of the slotted button, anchor, or label (defers to
|
|
69
|
+
* native color when unset).
|
|
70
|
+
* @cssprop [--rc-chip-font] - Font shorthand for the slotted button, anchor, or label (defers
|
|
71
|
+
* to native font when unset).
|
|
72
|
+
* @cssprop [--rc-chip-text-decoration] - Text decoration for the slotted anchor (defers to
|
|
73
|
+
* native text-decoration when unset).
|
|
74
|
+
* @cssprop [--rc-chip-selected-border-color] - Border color when `selected` (defers to native
|
|
75
|
+
* styling when unset).
|
|
76
|
+
* @cssprop [--rc-chip-selected-bg] - Background when `selected` (defers to native styling when
|
|
77
|
+
* unset).
|
|
78
|
+
* @cssprop [--rc-chip-selected-color] - Text color when `selected` (defers to native styling
|
|
79
|
+
* when unset).
|
|
80
|
+
* @cssprop [--rc-chip-disabled-opacity] - Opacity of the slotted button when `disabled` (defers
|
|
81
|
+
* to native disabled styling when unset).
|
|
82
|
+
* @cssprop [--rc-chip-focus-ring] - Outline shown while focus-within (defers to native focus
|
|
83
|
+
* styling when unset).
|
|
84
|
+
* @cssprop [--rc-chip-focus-ring-offset] - Outline offset while focus-within (defers to native
|
|
85
|
+
* focus styling when unset).
|
|
86
|
+
* @cssprop [--rc-chip-state-layer-color=currentColor] - Hover/focus/pressed state-layer color.
|
|
87
|
+
* @cssprop [--rc-chip-selected-state-layer-color=var(--rc-chip-state-layer-color, currentColor)] - Selected chip state-layer color.
|
|
88
|
+
* @cssprop [--rc-chip-hover-state-layer-opacity=0.08] - Hover state-layer opacity.
|
|
89
|
+
* @cssprop [--rc-chip-focus-state-layer-opacity=0.12] - Focus state-layer opacity.
|
|
90
|
+
* @cssprop [--rc-chip-pressed-state-layer-opacity=0.12] - Pressed state-layer opacity.
|
|
91
|
+
* @cssprop [--rc-chip-state-layer-transition-duration=var(--rc-motion-effects-duration-fast,80ms)] - State-layer effects duration.
|
|
92
|
+
* @cssprop [--rc-chip-state-layer-transition-easing=var(--rc-motion-effects-easing-fast,ease-out)] - State-layer effects easing.
|
|
93
|
+
* @cssprop [--rc-chip-remove-offset-inline=0.125rem] - Inline offset of the remove indicator
|
|
94
|
+
* from the chip edge.
|
|
95
|
+
* @cssprop [--rc-chip-remove-target-size=1.5rem] - Minimum inline and block size of the remove
|
|
96
|
+
* indicator's hit target.
|
|
97
|
+
* @cssprop [--rc-chip-remove-radius=9999px] - Border radius of the remove indicator.
|
|
98
|
+
* @cssprop [--rc-chip-remove-icon-size=smaller] - Font size for a slotted remove icon.
|
|
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.
|
|
100
|
+
*
|
|
101
|
+
* @attr variant - Chip variant: `assist`, `filter`, `input`, or `suggestion`.
|
|
102
|
+
* @attr selected - Declarative selected state for filter/input chips.
|
|
103
|
+
* @attr default-selected - Initial selected state for uncontrolled usage.
|
|
104
|
+
* @attr disabled - Mirrors disabled state to the native child button.
|
|
105
|
+
* @attr readonly - Marks the chip as non-interactive display content.
|
|
106
|
+
* @attr removable - Shows a trailing remove affordance.
|
|
107
|
+
*/
|
|
108
|
+
export declare class RCChip extends LitElement {
|
|
109
|
+
static styles: import('lit').CSSResult;
|
|
110
|
+
private static readonly _styledRoots;
|
|
111
|
+
private static _ensureBaseStyles;
|
|
112
|
+
private _selected;
|
|
113
|
+
private _defaultSelected;
|
|
114
|
+
private _uncontrolledSelected;
|
|
115
|
+
private _selectedInitialized;
|
|
116
|
+
private _$button;
|
|
117
|
+
private _$input;
|
|
118
|
+
private _$form;
|
|
119
|
+
private _controlObserver;
|
|
120
|
+
private _disabledOwned;
|
|
121
|
+
private _pressedOwned;
|
|
122
|
+
private _slotMicrotaskQueued;
|
|
123
|
+
private _lastChildWarning;
|
|
124
|
+
/** Chip variant. */
|
|
125
|
+
variant: RCChipVariant;
|
|
126
|
+
/** Current selected state. Host writes are silent. */
|
|
127
|
+
get selected(): boolean;
|
|
128
|
+
set selected(value: boolean | undefined);
|
|
129
|
+
/** Initial selected state for uncontrolled usage. */
|
|
130
|
+
get defaultSelected(): boolean;
|
|
131
|
+
set defaultSelected(value: boolean);
|
|
132
|
+
/** Mirror disabled state to the native child button. */
|
|
133
|
+
disabled: boolean;
|
|
134
|
+
/** Mark this chip as non-interactive display content. */
|
|
135
|
+
readonly: boolean;
|
|
136
|
+
/** Show a trailing remove affordance. */
|
|
137
|
+
removable: boolean;
|
|
138
|
+
connectedCallback(): void;
|
|
139
|
+
disconnectedCallback(): void;
|
|
140
|
+
/** Synchronizes uncontrolled filter state from the direct native input. @internal */
|
|
141
|
+
syncNativeSelection(): void;
|
|
142
|
+
protected firstUpdated(): void;
|
|
143
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
144
|
+
protected render(): import('lit').TemplateResult<1>;
|
|
145
|
+
private _handleSlotChange;
|
|
146
|
+
private _syncSlottedButton;
|
|
147
|
+
private readonly _handleNativeChange;
|
|
148
|
+
private readonly _handleButtonClick;
|
|
149
|
+
private _dispatchRemove;
|
|
150
|
+
private _syncDisabled;
|
|
151
|
+
private _syncCheckedState;
|
|
152
|
+
private _syncCheckedFromNative;
|
|
153
|
+
private readonly _handleFormReset;
|
|
154
|
+
private _syncPressedState;
|
|
155
|
+
}
|
|
156
|
+
export default RCChip;
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rcarls/rc-chip",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.0.0-next-20260921045401",
|
|
7
|
+
"description": "Chip wrapper for native actions, links, filters, and inputs.",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/richardcarls/rc-webcomponents.git",
|
|
11
|
+
"directory": "packages/rc-chip"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://richardcarls.github.io/rc-webcomponents/components/rc-chip",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"module": "./dist/rc-chip.js",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/types/packages/rc-chip/src/index.d.ts",
|
|
24
|
+
"default": "./dist/rc-chip.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./define": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/types/packages/rc-chip/src/define.d.ts",
|
|
30
|
+
"default": "./dist/rc-chip-define.js"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"types": "./dist/types/packages/rc-chip/src/index.d.ts",
|
|
35
|
+
"sideEffects": [
|
|
36
|
+
"./dist/rc-chip-define.js"
|
|
37
|
+
],
|
|
38
|
+
"customElements": "dist/custom-elements.json",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc && vite build && cem analyze",
|
|
41
|
+
"cem:analyze": "cem analyze",
|
|
42
|
+
"preview": "vite preview",
|
|
43
|
+
"test:browser": "vitest --run",
|
|
44
|
+
"test:browser:chrome": "vitest --run --project=chromium",
|
|
45
|
+
"test:browser:firefox": "vitest --run --project=firefox"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@custom-elements-manifest/analyzer": "0.11.0",
|
|
49
|
+
"@vitest/browser-playwright": "4.1.5",
|
|
50
|
+
"lit": "^3.0.0",
|
|
51
|
+
"playwright": "^1.56.0",
|
|
52
|
+
"rollup": "^4.60.2",
|
|
53
|
+
"typescript": "~5.9.3",
|
|
54
|
+
"vite": "^7.1.7",
|
|
55
|
+
"vite-plugin-dts": "^4.5.4",
|
|
56
|
+
"vitest": "^4.0.6",
|
|
57
|
+
"vitest-browser-lit": "^1.0.1"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"lit": "^3.0.0"
|
|
61
|
+
}
|
|
62
|
+
}
|