@aceshooting/lyra-ui 2.8.0 → 2.10.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/README.md +3 -1
- package/custom-elements.json +1288 -62
- package/dist/components/button/button.class.d.ts +57 -0
- package/dist/components/button/button.class.d.ts.map +1 -0
- package/dist/components/button/button.class.js +108 -0
- package/dist/components/button/button.class.js.map +1 -0
- package/dist/components/button/button.d.ts +2 -0
- package/dist/components/button/button.d.ts.map +1 -0
- package/dist/components/button/button.js +5 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/button.styles.d.ts +2 -0
- package/dist/components/button/button.styles.d.ts.map +1 -0
- package/dist/components/button/button.styles.js +121 -0
- package/dist/components/button/button.styles.js.map +1 -0
- package/dist/components/heatmap/heatmap.class.d.ts +41 -6
- package/dist/components/heatmap/heatmap.class.d.ts.map +1 -1
- package/dist/components/heatmap/heatmap.class.js +132 -21
- package/dist/components/heatmap/heatmap.class.js.map +1 -1
- package/dist/components/heatmap/heatmap.styles.d.ts.map +1 -1
- package/dist/components/heatmap/heatmap.styles.js +6 -0
- package/dist/components/heatmap/heatmap.styles.js.map +1 -1
- package/dist/components/input/input.class.d.ts +109 -0
- package/dist/components/input/input.class.d.ts.map +1 -0
- package/dist/components/input/input.class.js +269 -0
- package/dist/components/input/input.class.js.map +1 -0
- package/dist/components/input/input.d.ts +2 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/input.js +5 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/input/input.styles.d.ts +2 -0
- package/dist/components/input/input.styles.d.ts.map +1 -0
- package/dist/components/input/input.styles.js +88 -0
- package/dist/components/input/input.styles.js.map +1 -0
- package/dist/components/tool-result-view/tool-result-view.class.d.ts +13 -5
- package/dist/components/tool-result-view/tool-result-view.class.d.ts.map +1 -1
- package/dist/components/tool-result-view/tool-result-view.class.js +26 -7
- package/dist/components/tool-result-view/tool-result-view.class.js.map +1 -1
- package/dist/components/tool-result-view/tool-result-view.styles.d.ts.map +1 -1
- package/dist/components/tool-result-view/tool-result-view.styles.js +11 -0
- package/dist/components/tool-result-view/tool-result-view.styles.js.map +1 -1
- package/dist/internal/icons.d.ts +6 -0
- package/dist/internal/icons.d.ts.map +1 -1
- package/dist/internal/icons.js +20 -0
- package/dist/internal/icons.js.map +1 -1
- package/dist/internal/localization.d.ts +1 -1
- package/dist/internal/localization.d.ts.map +1 -1
- package/dist/internal/localization.js +5 -0
- package/dist/internal/localization.js.map +1 -1
- package/dist/internal/root-registration-allowlist.d.ts +1 -1
- package/dist/internal/root-registration-allowlist.d.ts.map +1 -1
- package/dist/internal/root-registration-allowlist.js +2 -0
- package/dist/internal/root-registration-allowlist.js.map +1 -1
- package/dist/lyra.d.ts +7 -0
- package/dist/lyra.d.ts.map +1 -1
- package/dist/lyra.js +4 -0
- package/dist/lyra.js.map +1 -1
- package/llms-full.txt +136 -9
- package/llms.txt +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing } from 'lit';
|
|
8
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
|
+
import { FormAssociated } from '../../internal/form-associated.js';
|
|
11
|
+
import { SET_ANCHORED_VALIDITY } from '../../internal/anchored-validity.js';
|
|
12
|
+
import { eyeIcon, eyeOffIcon } from '../../internal/icons.js';
|
|
13
|
+
import { styles } from './input.styles.js';
|
|
14
|
+
class LyraInputBase extends LyraElement {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `<lyra-input>` — a single-line plain-text input primitive, the `lyra-*` equivalent of a plain
|
|
18
|
+
* `wa-input`, form-associated via the `FormAssociated` mixin (same shape as `<lyra-textarea>`).
|
|
19
|
+
*
|
|
20
|
+
* Ships the same opt-in `label`/`hint`/`errorText` form-control chrome as `<lyra-textarea>`/
|
|
21
|
+
* `<lyra-select>` (props + matching named slots + `form-control`/`form-control-label`/`hint`/`error`
|
|
22
|
+
* parts) — left unset, the chrome stays hidden. `type="password"` always renders a
|
|
23
|
+
* `password-toggle` eye-icon button that flips the internal native input between
|
|
24
|
+
* `type="password"`/`type="text"` and tracks `passwordVisible`. `type="email"`/`type="number"`
|
|
25
|
+
* (with `min`/`max`/`step`) delegate constraint validation to the internal native `<input>`'s own
|
|
26
|
+
* browser-computed `validity`, bridged into this element's `ElementInternals` by `updateValidity()`.
|
|
27
|
+
*
|
|
28
|
+
* A host `aria-label` is forwarded to the internal textbox via the typed `accessibleLabel` property;
|
|
29
|
+
* external `aria-labelledby`/`aria-describedby` idrefs are not copied across the shadow boundary.
|
|
30
|
+
*
|
|
31
|
+
* @customElement lyra-input
|
|
32
|
+
* @event lyra-input - Fired on every user-driven edit (not a programmatic `.value` assignment). `detail: { value }`.
|
|
33
|
+
* @event lyra-change - Fired on the native `change` timing (control loses focus after a committed edit). `detail: { value }`.
|
|
34
|
+
* @event blur - Re-dispatched from the internal native `<input>`'s own `blur` — bubbling and
|
|
35
|
+
* composed (unlike the native event, which is neither).
|
|
36
|
+
* @event focus - Re-dispatched from the internal native `<input>`'s own `focus`, for the same reason as `blur`.
|
|
37
|
+
* @slot label - Custom label content.
|
|
38
|
+
* @slot hint - Custom hint content.
|
|
39
|
+
* @slot error - Custom error content.
|
|
40
|
+
* @csspart form-control - The outer wrapper around label, input, error and hint.
|
|
41
|
+
* @csspart form-control-label - The `<label>` element.
|
|
42
|
+
* @csspart input-wrapper - The row wrapping the native input and the password-toggle button.
|
|
43
|
+
* @csspart input - The native `<input>` element.
|
|
44
|
+
* @csspart password-toggle - The show/hide-password button, present only when `type="password"`.
|
|
45
|
+
* @csspart hint - The hint message.
|
|
46
|
+
* @csspart error - The error message.
|
|
47
|
+
*/
|
|
48
|
+
export class LyraInput extends FormAssociated(LyraInputBase) {
|
|
49
|
+
constructor() {
|
|
50
|
+
super(...arguments);
|
|
51
|
+
this.type = 'text';
|
|
52
|
+
this.placeholder = '';
|
|
53
|
+
this.label = '';
|
|
54
|
+
this.hint = '';
|
|
55
|
+
this.errorText = '';
|
|
56
|
+
/** Accessible name overriding the label/placeholder-derived default. Takes precedence over both
|
|
57
|
+
* `label` and `placeholder` when set, matching `<lyra-textarea>`'s `accessibleLabel`. */
|
|
58
|
+
this.accessibleLabel = null;
|
|
59
|
+
this.autocomplete = '';
|
|
60
|
+
/** `type="password"` only — whether the field currently reveals its raw text. Toggled by the
|
|
61
|
+
* built-in `password-toggle` button; also settable by a consumer up front. */
|
|
62
|
+
this.passwordVisible = false;
|
|
63
|
+
this.hasHintSlot = false;
|
|
64
|
+
this.hasErrorSlot = false;
|
|
65
|
+
this.hasLabelSlot = false;
|
|
66
|
+
this.touched = false;
|
|
67
|
+
this.onInput = () => {
|
|
68
|
+
if (!this.inputEl)
|
|
69
|
+
return;
|
|
70
|
+
this.value = this.inputEl.value;
|
|
71
|
+
this.emit('lyra-input', { value: this.value });
|
|
72
|
+
};
|
|
73
|
+
this.onChange = () => {
|
|
74
|
+
if (!this.inputEl)
|
|
75
|
+
return;
|
|
76
|
+
this.value = this.inputEl.value;
|
|
77
|
+
this.emit('lyra-change', { value: this.value });
|
|
78
|
+
};
|
|
79
|
+
this.onFocus = () => {
|
|
80
|
+
this.emit('focus');
|
|
81
|
+
};
|
|
82
|
+
this.onBlur = () => {
|
|
83
|
+
this.touched = true;
|
|
84
|
+
this.emit('blur');
|
|
85
|
+
};
|
|
86
|
+
this.onTogglePasswordVisible = () => {
|
|
87
|
+
this.passwordVisible = !this.passwordVisible;
|
|
88
|
+
};
|
|
89
|
+
this.onHintSlotChange = (e) => {
|
|
90
|
+
this.hasHintSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
91
|
+
};
|
|
92
|
+
this.onErrorSlotChange = (e) => {
|
|
93
|
+
this.hasErrorSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
94
|
+
};
|
|
95
|
+
this.onLabelSlotChange = (e) => {
|
|
96
|
+
this.hasLabelSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
100
|
+
/** The internal native `<input>` element, for direct DOM access — mirrors `<lyra-textarea>`'s own `input` getter. */
|
|
101
|
+
get input() {
|
|
102
|
+
return this.inputEl ?? null;
|
|
103
|
+
}
|
|
104
|
+
focus(options) {
|
|
105
|
+
this.inputEl?.focus(options);
|
|
106
|
+
}
|
|
107
|
+
blur() {
|
|
108
|
+
this.inputEl?.blur();
|
|
109
|
+
}
|
|
110
|
+
select() {
|
|
111
|
+
this.inputEl?.select();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Bridges the internal native `<input>`'s own browser-computed constraint validation (format for
|
|
115
|
+
* `type="email"`, range/step for `type="number"`) into this element's `ElementInternals`, instead
|
|
116
|
+
* of hand-rolling a second regex-based check — a real native input of the right `type` already
|
|
117
|
+
* computes `typeMismatch`/`rangeUnderflow`/`rangeOverflow`/`stepMismatch` correctly. Falls back to
|
|
118
|
+
* the base mixin's plain required-and-empty check before the first render (`inputEl` unset).
|
|
119
|
+
*
|
|
120
|
+
* A typed native input (`number`, `email`, …) also runs its own value-sanitization algorithm on
|
|
121
|
+
* assignment, which silently rewrites an unparseable non-empty value to `''` without setting any
|
|
122
|
+
* `ValidityState` flag — left unchecked, `native.validity.valid` would then read `true` (empty is
|
|
123
|
+
* fine when not required) while `this.value`/the bridged form value still held the literal invalid
|
|
124
|
+
* string. Detect that mismatch and report it as `badInput` instead of trusting native blindly.
|
|
125
|
+
*/
|
|
126
|
+
updateValidity() {
|
|
127
|
+
const native = this.inputEl;
|
|
128
|
+
if (!native) {
|
|
129
|
+
if (this.required && this.value === '') {
|
|
130
|
+
this[SET_ANCHORED_VALIDITY]({ valueMissing: true }, 'Please fill out this field.');
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this[SET_ANCHORED_VALIDITY]({});
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
native.value = this.value;
|
|
138
|
+
const sanitizedAway = this.value !== '' && native.value === '';
|
|
139
|
+
const v = native.validity;
|
|
140
|
+
if (v.valid) {
|
|
141
|
+
if (sanitizedAway) {
|
|
142
|
+
this[SET_ANCHORED_VALIDITY]({ badInput: true }, this.localize('valueInvalid'));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this[SET_ANCHORED_VALIDITY]({});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this[SET_ANCHORED_VALIDITY]({
|
|
149
|
+
valueMissing: v.valueMissing,
|
|
150
|
+
typeMismatch: v.typeMismatch,
|
|
151
|
+
rangeUnderflow: v.rangeUnderflow,
|
|
152
|
+
rangeOverflow: v.rangeOverflow,
|
|
153
|
+
stepMismatch: v.stepMismatch,
|
|
154
|
+
badInput: v.badInput,
|
|
155
|
+
}, native.validationMessage);
|
|
156
|
+
}
|
|
157
|
+
updated(changed) {
|
|
158
|
+
super.updated(changed);
|
|
159
|
+
if (changed.has('type') || changed.has('min') || changed.has('max') || changed.has('step')) {
|
|
160
|
+
this.updateValidity();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
render() {
|
|
164
|
+
const hasHint = this.hasHintSlot || this.hint.length > 0;
|
|
165
|
+
const hasError = this.hasErrorSlot || this.errorText.length > 0;
|
|
166
|
+
const hasLabel = this.hasLabelSlot || this.label.length > 0;
|
|
167
|
+
const describedBy = [hasError ? 'input-error' : '', hasHint ? 'input-hint' : ''].filter(Boolean).join(' ');
|
|
168
|
+
const isPassword = this.type === 'password';
|
|
169
|
+
const nativeType = isPassword && this.passwordVisible ? 'text' : this.type;
|
|
170
|
+
return html `
|
|
171
|
+
<div part="form-control">
|
|
172
|
+
<label part="form-control-label" for="input" ?hidden=${!hasLabel}>
|
|
173
|
+
${this.label}<slot name="label" @slotchange=${this.onLabelSlotChange}></slot>
|
|
174
|
+
</label>
|
|
175
|
+
<div part="input-wrapper">
|
|
176
|
+
<input
|
|
177
|
+
id="input"
|
|
178
|
+
part="input"
|
|
179
|
+
type=${nativeType}
|
|
180
|
+
placeholder=${this.placeholder}
|
|
181
|
+
aria-label=${this.accessibleLabel ||
|
|
182
|
+
(hasLabel ? nothing : this.placeholder || this.localize('inputLabel'))}
|
|
183
|
+
aria-describedby=${describedBy || nothing}
|
|
184
|
+
aria-required=${this.required ? 'true' : 'false'}
|
|
185
|
+
aria-invalid=${hasError || (this.touched && !this.internals.validity.valid) ? 'true' : 'false'}
|
|
186
|
+
autocomplete=${this.autocomplete || nothing}
|
|
187
|
+
min=${this.min ?? nothing}
|
|
188
|
+
max=${this.max ?? nothing}
|
|
189
|
+
step=${this.step ?? nothing}
|
|
190
|
+
.value=${this.value}
|
|
191
|
+
?required=${this.required}
|
|
192
|
+
?disabled=${this.effectiveDisabled}
|
|
193
|
+
@input=${this.onInput}
|
|
194
|
+
@change=${this.onChange}
|
|
195
|
+
@focus=${this.onFocus}
|
|
196
|
+
@blur=${this.onBlur}
|
|
197
|
+
/>
|
|
198
|
+
${isPassword
|
|
199
|
+
? html `<button
|
|
200
|
+
part="password-toggle"
|
|
201
|
+
type="button"
|
|
202
|
+
?disabled=${this.effectiveDisabled}
|
|
203
|
+
aria-label=${this.localize(this.passwordVisible ? 'hidePassword' : 'showPassword')}
|
|
204
|
+
aria-pressed=${this.passwordVisible ? 'true' : 'false'}
|
|
205
|
+
@click=${this.onTogglePasswordVisible}
|
|
206
|
+
>
|
|
207
|
+
${this.passwordVisible ? eyeOffIcon() : eyeIcon()}
|
|
208
|
+
</button>`
|
|
209
|
+
: ''}
|
|
210
|
+
</div>
|
|
211
|
+
<div id="input-error" part="error" ?hidden=${!hasError}>
|
|
212
|
+
${this.errorText}<slot name="error" @slotchange=${this.onErrorSlotChange}></slot>
|
|
213
|
+
</div>
|
|
214
|
+
<div id="input-hint" part="hint" ?hidden=${!hasHint}>
|
|
215
|
+
${this.hint}<slot name="hint" @slotchange=${this.onHintSlotChange}></slot>
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
`;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
__decorate([
|
|
222
|
+
property()
|
|
223
|
+
], LyraInput.prototype, "type", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
property()
|
|
226
|
+
], LyraInput.prototype, "placeholder", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
property()
|
|
229
|
+
], LyraInput.prototype, "label", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
property()
|
|
232
|
+
], LyraInput.prototype, "hint", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
property({ attribute: 'error-text' })
|
|
235
|
+
], LyraInput.prototype, "errorText", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
property({ attribute: 'aria-label' })
|
|
238
|
+
], LyraInput.prototype, "accessibleLabel", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
property()
|
|
241
|
+
], LyraInput.prototype, "autocomplete", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
property({ type: Number })
|
|
244
|
+
], LyraInput.prototype, "min", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
property({ type: Number })
|
|
247
|
+
], LyraInput.prototype, "max", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
property({ type: Number })
|
|
250
|
+
], LyraInput.prototype, "step", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
property({ type: Boolean, attribute: 'password-visible' })
|
|
253
|
+
], LyraInput.prototype, "passwordVisible", void 0);
|
|
254
|
+
__decorate([
|
|
255
|
+
state()
|
|
256
|
+
], LyraInput.prototype, "hasHintSlot", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
state()
|
|
259
|
+
], LyraInput.prototype, "hasErrorSlot", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
state()
|
|
262
|
+
], LyraInput.prototype, "hasLabelSlot", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
state()
|
|
265
|
+
], LyraInput.prototype, "touched", void 0);
|
|
266
|
+
__decorate([
|
|
267
|
+
query('input')
|
|
268
|
+
], LyraInput.prototype, "inputEl", void 0);
|
|
269
|
+
//# sourceMappingURL=input.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.class.js","sourceRoot":"","sources":["../../../src/components/input/input.class.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAU3C,MAAM,aAAc,SAAQ,WAA8B;CAAG;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,OAAO,SAAU,SAAQ,cAAc,CAAC,aAAa,CAAC;IAA5D;;QAGc,SAAI,GAAkB,MAAM,CAAC;QAC7B,gBAAW,GAAG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AE,YAAY,EAAE,CAAC;4CAAgB;AAGf;IAAtC,QAAQ,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDAAuC;AACjE;IAAX,QAAQ,EAAE;+CAAmB;AAGF;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAe;AAGkB;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;kDAAyB;AAEnE;IAAhB,KAAK,EAAE;8CAA6B;AACpB;IAAhB,KAAK,EAAE;+CAA8B;AACrB;IAAhB,KAAK,EAAE;+CAA8B;AACrB;IAAhB,KAAK,EAAE;0CAAyB;AAET;IAAvB,KAAK,CAAC,OAAO,CAAC;0CAAoC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/components/input/input.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.styles.d.ts","sourceRoot":"","sources":["../../../src/components/input/input.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAqFlB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
[part='form-control-label'] {
|
|
7
|
+
display: block;
|
|
8
|
+
margin-block-end: var(--lyra-space-xs);
|
|
9
|
+
font-size: var(--lyra-font-size-md-sm);
|
|
10
|
+
font-weight: var(--lyra-font-weight-semibold);
|
|
11
|
+
}
|
|
12
|
+
[part='form-control-label'][hidden] {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
:host([required]) [part='form-control-label']::after {
|
|
16
|
+
content: ' *';
|
|
17
|
+
color: var(--lyra-color-danger);
|
|
18
|
+
}
|
|
19
|
+
[part='input-wrapper'] {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: var(--lyra-space-xs);
|
|
23
|
+
inline-size: 100%;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
padding-inline: var(--lyra-space-s);
|
|
26
|
+
border: var(--lyra-border-width-thin) solid var(--lyra-color-border);
|
|
27
|
+
border-radius: var(--lyra-radius);
|
|
28
|
+
background: var(--lyra-color-surface);
|
|
29
|
+
}
|
|
30
|
+
[part='input-wrapper']:focus-within {
|
|
31
|
+
border-color: var(--lyra-color-brand);
|
|
32
|
+
}
|
|
33
|
+
[part='input'] {
|
|
34
|
+
flex: 1 1 auto;
|
|
35
|
+
min-inline-size: 0;
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
padding-block: var(--lyra-space-s);
|
|
38
|
+
border: none;
|
|
39
|
+
outline: none;
|
|
40
|
+
background: transparent;
|
|
41
|
+
color: var(--lyra-color-text);
|
|
42
|
+
font: inherit;
|
|
43
|
+
font-size: var(--lyra-font-size-md-sm);
|
|
44
|
+
}
|
|
45
|
+
[part='input']::placeholder {
|
|
46
|
+
color: var(--lyra-color-text-quiet);
|
|
47
|
+
}
|
|
48
|
+
[part='input']:disabled {
|
|
49
|
+
opacity: var(--lyra-opacity-disabled);
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
}
|
|
52
|
+
[part='password-toggle'] {
|
|
53
|
+
flex: 0 0 auto;
|
|
54
|
+
display: inline-flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
border: none;
|
|
58
|
+
background: none;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
color: var(--lyra-color-text-quiet);
|
|
61
|
+
padding: var(--lyra-space-xs);
|
|
62
|
+
min-inline-size: var(--lyra-icon-button-size);
|
|
63
|
+
min-block-size: var(--lyra-icon-button-size);
|
|
64
|
+
line-height: var(--lyra-line-height-none);
|
|
65
|
+
font-size: var(--lyra-font-size-md);
|
|
66
|
+
}
|
|
67
|
+
[part='password-toggle']:focus-visible {
|
|
68
|
+
outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
|
|
69
|
+
outline-offset: var(--lyra-focus-ring-offset);
|
|
70
|
+
}
|
|
71
|
+
[part='hint'] {
|
|
72
|
+
margin-block-start: var(--lyra-space-xs);
|
|
73
|
+
font-size: var(--lyra-font-size-sm);
|
|
74
|
+
color: var(--lyra-color-text-quiet);
|
|
75
|
+
}
|
|
76
|
+
[part='hint'][hidden] {
|
|
77
|
+
display: none;
|
|
78
|
+
}
|
|
79
|
+
[part='error'] {
|
|
80
|
+
margin-block-start: var(--lyra-space-xs);
|
|
81
|
+
font-size: var(--lyra-font-size-sm);
|
|
82
|
+
color: var(--lyra-color-danger);
|
|
83
|
+
}
|
|
84
|
+
[part='error'][hidden] {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
//# sourceMappingURL=input.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.styles.js","sourceRoot":"","sources":["../../../src/components/input/input.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqFxB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { LyraElement } from '../../internal/lyra-element.js';
|
|
|
3
3
|
import { type ToolRendererRegistry } from './registry.js';
|
|
4
4
|
import '../skeleton/skeleton.class.js';
|
|
5
5
|
import '../json-viewer/json-viewer.class.js';
|
|
6
|
+
import '../copy-button/copy-button.class.js';
|
|
6
7
|
export interface LyraToolResultViewEventMap {
|
|
7
8
|
'lyra-render-error': CustomEvent<{
|
|
8
9
|
toolName: string;
|
|
@@ -24,10 +25,12 @@ export interface LyraToolResultViewEventMap {
|
|
|
24
25
|
* `findToolRenderer()`'s two-step (exact name, then shape-based `matches()`)
|
|
25
26
|
* lookup order for the full rule.
|
|
26
27
|
*
|
|
27
|
-
* `fallback`
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* `fallback` implements two kinds: `"json"` (the default, an unconditional `<lyra-json-viewer>`)
|
|
29
|
+
* and `"text"`, which renders a *string* `result` as preformatted text instead — falling back to
|
|
30
|
+
* the `"json"` behavior when `result` isn't a string, so setting `fallback="text"` defensively
|
|
31
|
+
* against an unpredictable result shape never renders broken output. `copyable` adds a
|
|
32
|
+
* copy-to-clipboard affordance to either fallback kind (forwarded to `<lyra-json-viewer>`'s own
|
|
33
|
+
* `copyable` for `"json"`; a `<lyra-copy-button>` alongside the text for `"text"`).
|
|
31
34
|
*
|
|
32
35
|
* @customElement lyra-tool-result-view
|
|
33
36
|
* @event lyra-render-error - `detail: { toolName, error }` — fired immediately
|
|
@@ -35,6 +38,8 @@ export interface LyraToolResultViewEventMap {
|
|
|
35
38
|
* matched, a candidate renderer's `matches()` predicate threw during dispatch,
|
|
36
39
|
* a renderer's `load()` rejected, or its `render()` threw.
|
|
37
40
|
* @csspart base - The root wrapper around the resolved renderer's output (or the loading/fallback view).
|
|
41
|
+
* @csspart fallback-text - The `<pre>` element for the `fallback="text"` kind's preformatted result text (only present in that mode).
|
|
42
|
+
* @csspart fallback-copy - The `<lyra-copy-button>` shown when `copyable` is set alongside the `fallback="text"` kind (only present when both are set).
|
|
38
43
|
*/
|
|
39
44
|
export declare class LyraToolResultView extends LyraElement<LyraToolResultViewEventMap> {
|
|
40
45
|
static styles: import("lit").CSSResultGroup[];
|
|
@@ -46,8 +51,10 @@ export declare class LyraToolResultView extends LyraElement<LyraToolResultViewEv
|
|
|
46
51
|
result: unknown;
|
|
47
52
|
/** The tool call's original arguments, if available — handed to the matched renderer's `render()` alongside `result`. */
|
|
48
53
|
args: unknown;
|
|
49
|
-
/**
|
|
54
|
+
/** Fallback-kind selector — see the class doc's `fallback` paragraph for the full "json" vs "text" behavior. */
|
|
50
55
|
fallback: string;
|
|
56
|
+
/** Shows a copy-to-clipboard affordance alongside the fallback view (both `"json"` and `"text"` kinds) — forwarded to `<lyra-json-viewer>`'s own `copyable`, or renders a `<lyra-copy-button>` next to the text fallback. */
|
|
57
|
+
copyable: boolean;
|
|
51
58
|
private renderState;
|
|
52
59
|
private generation;
|
|
53
60
|
private resolvedLazy?;
|
|
@@ -56,6 +63,7 @@ export declare class LyraToolResultView extends LyraElement<LyraToolResultViewEv
|
|
|
56
63
|
private renderWith;
|
|
57
64
|
private fail;
|
|
58
65
|
render(): TemplateResult;
|
|
66
|
+
private renderFallback;
|
|
59
67
|
}
|
|
60
68
|
declare global {
|
|
61
69
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-result-view.class.d.ts","sourceRoot":"","sources":["../../../src/components/tool-result-view/tool-result-view.class.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"tool-result-view.class.d.ts","sourceRoot":"","sources":["../../../src/components/tool-result-view/tool-result-view.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,cAAc,EAA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i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { html } from 'lit';
|
|
7
|
+
import { html, nothing } from 'lit';
|
|
8
8
|
import { property, state } from 'lit/decorators.js';
|
|
9
9
|
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
10
|
import { findToolRenderer, getDefaultToolRendererRegistry, loadToolRenderer, } from './registry.js';
|
|
11
11
|
import { styles } from './tool-result-view.styles.js';
|
|
12
12
|
import '../skeleton/skeleton.class.js';
|
|
13
13
|
import '../json-viewer/json-viewer.class.js';
|
|
14
|
+
import '../copy-button/copy-button.class.js';
|
|
14
15
|
const FALLBACK_STATE = { kind: 'fallback' };
|
|
15
16
|
/**
|
|
16
17
|
* `<lyra-tool-result-view>` — renders a tool call's result via whichever
|
|
@@ -27,10 +28,12 @@ const FALLBACK_STATE = { kind: 'fallback' };
|
|
|
27
28
|
* `findToolRenderer()`'s two-step (exact name, then shape-based `matches()`)
|
|
28
29
|
* lookup order for the full rule.
|
|
29
30
|
*
|
|
30
|
-
* `fallback`
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* `fallback` implements two kinds: `"json"` (the default, an unconditional `<lyra-json-viewer>`)
|
|
32
|
+
* and `"text"`, which renders a *string* `result` as preformatted text instead — falling back to
|
|
33
|
+
* the `"json"` behavior when `result` isn't a string, so setting `fallback="text"` defensively
|
|
34
|
+
* against an unpredictable result shape never renders broken output. `copyable` adds a
|
|
35
|
+
* copy-to-clipboard affordance to either fallback kind (forwarded to `<lyra-json-viewer>`'s own
|
|
36
|
+
* `copyable` for `"json"`; a `<lyra-copy-button>` alongside the text for `"text"`).
|
|
34
37
|
*
|
|
35
38
|
* @customElement lyra-tool-result-view
|
|
36
39
|
* @event lyra-render-error - `detail: { toolName, error }` — fired immediately
|
|
@@ -38,14 +41,18 @@ const FALLBACK_STATE = { kind: 'fallback' };
|
|
|
38
41
|
* matched, a candidate renderer's `matches()` predicate threw during dispatch,
|
|
39
42
|
* a renderer's `load()` rejected, or its `render()` threw.
|
|
40
43
|
* @csspart base - The root wrapper around the resolved renderer's output (or the loading/fallback view).
|
|
44
|
+
* @csspart fallback-text - The `<pre>` element for the `fallback="text"` kind's preformatted result text (only present in that mode).
|
|
45
|
+
* @csspart fallback-copy - The `<lyra-copy-button>` shown when `copyable` is set alongside the `fallback="text"` kind (only present when both are set).
|
|
41
46
|
*/
|
|
42
47
|
export class LyraToolResultView extends LyraElement {
|
|
43
48
|
constructor() {
|
|
44
49
|
super(...arguments);
|
|
45
50
|
/** The tool's name — the primary dispatch key (see `findToolRenderer()`). */
|
|
46
51
|
this.toolName = '';
|
|
47
|
-
/**
|
|
52
|
+
/** Fallback-kind selector — see the class doc's `fallback` paragraph for the full "json" vs "text" behavior. */
|
|
48
53
|
this.fallback = 'json';
|
|
54
|
+
/** Shows a copy-to-clipboard affordance alongside the fallback view (both `"json"` and `"text"` kinds) — forwarded to `<lyra-json-viewer>`'s own `copyable`, or renders a `<lyra-copy-button>` next to the text fallback. */
|
|
55
|
+
this.copyable = false;
|
|
49
56
|
this.renderState = FALLBACK_STATE;
|
|
50
57
|
// Bumped on every resolve() call so a stale in-flight load() (superseded by
|
|
51
58
|
// a newer toolName/result/args/registry before it settles) can detect it's
|
|
@@ -125,10 +132,19 @@ export class LyraToolResultView extends LyraElement {
|
|
|
125
132
|
? html `<lyra-skeleton variant="rect" height="4rem"></lyra-skeleton>`
|
|
126
133
|
: state.kind === 'rendered'
|
|
127
134
|
? state.template
|
|
128
|
-
:
|
|
135
|
+
: this.renderFallback()}
|
|
129
136
|
</div>
|
|
130
137
|
`;
|
|
131
138
|
}
|
|
139
|
+
renderFallback() {
|
|
140
|
+
if (this.fallback === 'text' && typeof this.result === 'string') {
|
|
141
|
+
return html `
|
|
142
|
+
<pre part="fallback-text">${this.result}</pre>
|
|
143
|
+
${this.copyable ? html `<lyra-copy-button part="fallback-copy" .value=${this.result}></lyra-copy-button>` : nothing}
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
return html `<lyra-json-viewer .data=${this.result} ?copyable=${this.copyable}></lyra-json-viewer>`;
|
|
147
|
+
}
|
|
132
148
|
}
|
|
133
149
|
__decorate([
|
|
134
150
|
property({ attribute: false })
|
|
@@ -145,6 +161,9 @@ __decorate([
|
|
|
145
161
|
__decorate([
|
|
146
162
|
property({ reflect: true })
|
|
147
163
|
], LyraToolResultView.prototype, "fallback", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
property({ type: Boolean, reflect: true })
|
|
166
|
+
], LyraToolResultView.prototype, "copyable", void 0);
|
|
148
167
|
__decorate([
|
|
149
168
|
state()
|
|
150
169
|
], LyraToolResultView.prototype, "renderState", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-result-view.class.js","sourceRoot":"","sources":["../../../src/components/tool-result-view/tool-result-view.class.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAA4C,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-result-view.class.js","sourceRoot":"","sources":["../../../src/components/tool-result-view/tool-result-view.class.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,8BAA8B,EAC9B,gBAAgB,GAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,+BAA+B,CAAC;AACvC,OAAO,qCAAqC,CAAC;AAC7C,OAAO,qCAAqC,CAAC;AAQ7C,MAAM,cAAc,GAAgB,EAAE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QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;kDAAiB;AAGhB;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;gDAAe;AAGjB;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAmB;AAGH;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAkB;AAE5C;IAAhB,KAAK,EAAE;uDAAmD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-result-view.styles.d.ts","sourceRoot":"","sources":["../../../src/components/tool-result-view/tool-result-view.styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"tool-result-view.styles.d.ts","sourceRoot":"","sources":["../../../src/components/tool-result-view/tool-result-view.styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,MAAM,yBAkBlB,CAAC"}
|
|
@@ -10,5 +10,16 @@ export const styles = css `
|
|
|
10
10
|
[part='base'] {
|
|
11
11
|
display: block;
|
|
12
12
|
}
|
|
13
|
+
[part='fallback-text'] {
|
|
14
|
+
margin: 0;
|
|
15
|
+
white-space: pre-wrap;
|
|
16
|
+
word-break: break-word;
|
|
17
|
+
font-family: var(--lyra-tool-result-view-font, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
|
|
18
|
+
font-size: var(--lyra-font-size-md-sm);
|
|
19
|
+
color: var(--lyra-color-text);
|
|
20
|
+
}
|
|
21
|
+
[part='fallback-copy'] {
|
|
22
|
+
margin-block-start: var(--lyra-space-xs);
|
|
23
|
+
}
|
|
13
24
|
`;
|
|
14
25
|
//# sourceMappingURL=tool-result-view.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-result-view.styles.js","sourceRoot":"","sources":["../../../src/components/tool-result-view/tool-result-view.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,qEAAqE;AACrE,6EAA6E;AAC7E,sEAAsE;AACtE,qCAAqC;AACrC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"tool-result-view.styles.js","sourceRoot":"","sources":["../../../src/components/tool-result-view/tool-result-view.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,qEAAqE;AACrE,6EAA6E;AAC7E,sEAAsE;AACtE,qCAAqC;AACrC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;CAkBxB,CAAC"}
|
package/dist/internal/icons.d.ts
CHANGED
|
@@ -11,4 +11,10 @@ export declare function pauseIcon(): SVGTemplateResult;
|
|
|
11
11
|
export declare function calendarIcon(): SVGTemplateResult;
|
|
12
12
|
/** A four-corner "expand to fullscreen" glyph. */
|
|
13
13
|
export declare function expandIcon(): SVGTemplateResult;
|
|
14
|
+
/** A three-quarter-arc spinner glyph. Rotate the wrapping part element via CSS animation for a loading state. */
|
|
15
|
+
export declare function spinnerIcon(): SVGTemplateResult;
|
|
16
|
+
/** An open-eye glyph, for a password field's "show" toggle. */
|
|
17
|
+
export declare function eyeIcon(): SVGTemplateResult;
|
|
18
|
+
/** A slashed-eye glyph, for a password field's "hide" toggle. */
|
|
19
|
+
export declare function eyeOffIcon(): SVGTemplateResult;
|
|
14
20
|
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/internal/icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,iBAAiB,EAAE,MAAM,KAAK,CAAC;AAqClD,yFAAyF;AACzF,wBAAgB,WAAW,IAAI,iBAAiB,CAE/C;AAED,gCAAgC;AAChC,wBAAgB,SAAS,IAAI,iBAAiB,CAK7C;AAED,sCAAsC;AACtC,wBAAgB,QAAQ,IAAI,iBAAiB,CAE5C;AAED,+BAA+B;AAC/B,wBAAgB,SAAS,IAAI,iBAAiB,CAK7C;AAED,oEAAoE;AACpE,wBAAgB,YAAY,IAAI,iBAAiB,CAOhD;AAED,kDAAkD;AAClD,wBAAgB,UAAU,IAAI,iBAAiB,CAO9C"}
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/internal/icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,iBAAiB,EAAE,MAAM,KAAK,CAAC;AAqClD,yFAAyF;AACzF,wBAAgB,WAAW,IAAI,iBAAiB,CAE/C;AAED,gCAAgC;AAChC,wBAAgB,SAAS,IAAI,iBAAiB,CAK7C;AAED,sCAAsC;AACtC,wBAAgB,QAAQ,IAAI,iBAAiB,CAE5C;AAED,+BAA+B;AAC/B,wBAAgB,SAAS,IAAI,iBAAiB,CAK7C;AAED,oEAAoE;AACpE,wBAAgB,YAAY,IAAI,iBAAiB,CAOhD;AAED,kDAAkD;AAClD,wBAAgB,UAAU,IAAI,iBAAiB,CAO9C;AAED,iHAAiH;AACjH,wBAAgB,WAAW,IAAI,iBAAiB,CAE/C;AAED,+DAA+D;AAC/D,wBAAgB,OAAO,IAAI,iBAAiB,CAK3C;AAED,iEAAiE;AACjE,wBAAgB,UAAU,IAAI,iBAAiB,CAO9C"}
|
package/dist/internal/icons.js
CHANGED
|
@@ -71,4 +71,24 @@ export function expandIcon() {
|
|
|
71
71
|
<line x1="3" y1="21" x2="10" y2="14"></line>
|
|
72
72
|
`);
|
|
73
73
|
}
|
|
74
|
+
/** A three-quarter-arc spinner glyph. Rotate the wrapping part element via CSS animation for a loading state. */
|
|
75
|
+
export function spinnerIcon() {
|
|
76
|
+
return icon(svg `<path d="M21 12a9 9 0 1 1-9-9"></path>`);
|
|
77
|
+
}
|
|
78
|
+
/** An open-eye glyph, for a password field's "show" toggle. */
|
|
79
|
+
export function eyeIcon() {
|
|
80
|
+
return icon(svg `
|
|
81
|
+
<path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7Z"></path>
|
|
82
|
+
<circle cx="12" cy="12" r="3"></circle>
|
|
83
|
+
`);
|
|
84
|
+
}
|
|
85
|
+
/** A slashed-eye glyph, for a password field's "hide" toggle. */
|
|
86
|
+
export function eyeOffIcon() {
|
|
87
|
+
return icon(svg `
|
|
88
|
+
<path d="M17.94 17.94A10.94 10.94 0 0 1 12 19c-7 0-11-7-11-7a18.5 18.5 0 0 1 4.22-5.06"></path>
|
|
89
|
+
<path d="M9.9 4.24A10.4 10.4 0 0 1 12 4c7 0 11 7 11 7a18.5 18.5 0 0 1-2.16 3.19"></path>
|
|
90
|
+
<path d="M14.12 14.12a3 3 0 1 1-4.24-4.24"></path>
|
|
91
|
+
<line x1="1" y1="1" x2="23" y2="23"></line>
|
|
92
|
+
`);
|
|
93
|
+
}
|
|
74
94
|
//# sourceMappingURL=icons.js.map
|