@juice-js/ui 0.0.0-stage → 2.5.0-alpha.5

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.
@@ -0,0 +1,944 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, booleanAttribute, inject, ElementRef, DestroyRef, ViewEncapsulation, ChangeDetectionStrategy, Component, isDevMode, afterNextRender, ApplicationRef, EnvironmentInjector, createComponent, computed, signal, Directive, InjectionToken, model, contentChildren, viewChild, Injector, forwardRef, effect, numberAttribute, output } from '@angular/core';
3
+ import { NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
4
+ import { ActiveDescendantKeyManager } from '@angular/cdk/a11y';
5
+ import { Overlay, CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
6
+ import { JuiceIcon } from '@juice-js/icons';
7
+
8
+ const BUTTON_STYLES = `
9
+ [juiceButton], [juiceIconButton] {
10
+ box-sizing: border-box;
11
+ position: relative;
12
+ display: inline-flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ gap: var(--juice-space-2);
16
+ min-height: var(--juice-control-height-md);
17
+ padding: 0 var(--juice-space-4);
18
+ border: 1px solid transparent;
19
+ border-radius: var(--juice-radius-md);
20
+ background: transparent;
21
+ color: var(--juice-color-text);
22
+ font-family: var(--juice-font-sans);
23
+ font-size: var(--juice-text-sm);
24
+ font-weight: var(--juice-weight-medium);
25
+ line-height: 1;
26
+ text-decoration: none;
27
+ white-space: nowrap;
28
+ cursor: pointer;
29
+ user-select: none;
30
+ transition: background-color var(--juice-duration-fast) var(--juice-ease-standard),
31
+ border-color var(--juice-duration-fast) var(--juice-ease-standard),
32
+ color var(--juice-duration-fast) var(--juice-ease-standard);
33
+ }
34
+ [juiceButton][data-size='sm'] { min-height: var(--juice-control-height-sm); padding: 0 var(--juice-space-3); font-size: var(--juice-text-xs); }
35
+ [juiceButton][data-size='lg'] { min-height: var(--juice-control-height-lg); padding: 0 var(--juice-space-6); font-size: var(--juice-text-md); }
36
+ [juiceIconButton] {
37
+ width: var(--juice-control-height-md);
38
+ height: var(--juice-control-height-md);
39
+ padding: 0;
40
+ }
41
+ [juiceButton]:focus-visible, [juiceIconButton]:focus-visible {
42
+ outline: 2px solid var(--juice-color-focus-ring);
43
+ outline-offset: 2px;
44
+ }
45
+ [juiceButton][data-variant='primary'] { background: var(--juice-color-accent); color: var(--juice-color-text-on-accent); }
46
+ [juiceButton][data-variant='primary']:hover { background: var(--juice-color-accent-hover); }
47
+ [juiceButton][data-variant='primary']:active { background: var(--juice-color-accent-active); }
48
+ [juiceButton][data-variant='secondary'] { background: var(--juice-color-surface); border-color: var(--juice-color-border-strong); }
49
+ [juiceButton][data-variant='secondary']:hover { background: var(--juice-color-accent-subtle); }
50
+ [juiceButton][data-variant='ghost']:hover, [juiceIconButton]:hover { background: var(--juice-color-accent-subtle); }
51
+ [juiceButton][data-variant='danger'] { background: var(--juice-color-bad); color: var(--juice-color-text-on-accent); }
52
+ [juiceButton][data-variant='danger']:hover { background: var(--juice-color-bad); filter: brightness(0.92); }
53
+ [juiceButton]:disabled, [juiceIconButton]:disabled, [juiceButton][aria-disabled='true'] {
54
+ background: var(--juice-color-disabled-bg);
55
+ border-color: transparent;
56
+ color: var(--juice-color-disabled-text);
57
+ cursor: not-allowed;
58
+ filter: none;
59
+ }
60
+ [juiceButton][data-loading] { cursor: progress; }
61
+ .juice-button__spinner {
62
+ box-sizing: border-box;
63
+ width: 1em;
64
+ height: 1em;
65
+ border: 2px solid currentColor;
66
+ border-right-color: transparent;
67
+ border-radius: var(--juice-radius-full);
68
+ animation: juice-button-spin 700ms linear infinite;
69
+ }
70
+ @media (prefers-reduced-motion: reduce) { .juice-button__spinner { animation-duration: 3s; } }
71
+ @keyframes juice-button-spin { to { transform: rotate(360deg); } }
72
+ `;
73
+ /**
74
+ * Button or link styled as a button. `loading` sets `aria-busy` and swallows activation (the element stays focusable
75
+ * and does not use `disabled`, so focus is not lost while busy).
76
+ */
77
+ class JuiceButton {
78
+ constructor() {
79
+ this.variant = input('secondary', /* @ts-ignore */
80
+ ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
81
+ this.size = input('md', /* @ts-ignore */
82
+ ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
83
+ this.loading = input(false, { ...(ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
84
+ const el = inject(ElementRef).nativeElement;
85
+ if (el.tagName === 'BUTTON' && !el.hasAttribute('type'))
86
+ el.setAttribute('type', 'button');
87
+ // Capture phase on the target itself runs before the consumer's (click) handler, so loading blocks it.
88
+ const block = (e) => {
89
+ if (this.loading()) {
90
+ e.preventDefault();
91
+ e.stopImmediatePropagation();
92
+ }
93
+ };
94
+ el.addEventListener('click', block, true);
95
+ inject(DestroyRef).onDestroy(() => el.removeEventListener('click', block, true));
96
+ }
97
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceButton, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
98
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: JuiceButton, isStandalone: true, selector: "button[juiceButton], a[juiceButton]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-variant": "variant()", "attr.data-size": "size()", "attr.data-loading": "loading() ? \"\" : null", "attr.aria-busy": "loading() ? \"true\" : null" } }, ngImport: i0, template: `@if (loading()) {<span class="juice-button__spinner" aria-hidden="true"></span>}<span class="juice-button__label"><ng-content /></span>`, isInline: true, styles: ["[juiceButton],[juiceIconButton]{box-sizing:border-box;position:relative;display:inline-flex;align-items:center;justify-content:center;gap:var(--juice-space-2);min-height:var(--juice-control-height-md);padding:0 var(--juice-space-4);border:1px solid transparent;border-radius:var(--juice-radius-md);background:transparent;color:var(--juice-color-text);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm);font-weight:var(--juice-weight-medium);line-height:1;text-decoration:none;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--juice-duration-fast) var(--juice-ease-standard),border-color var(--juice-duration-fast) var(--juice-ease-standard),color var(--juice-duration-fast) var(--juice-ease-standard)}[juiceButton][data-size=sm]{min-height:var(--juice-control-height-sm);padding:0 var(--juice-space-3);font-size:var(--juice-text-xs)}[juiceButton][data-size=lg]{min-height:var(--juice-control-height-lg);padding:0 var(--juice-space-6);font-size:var(--juice-text-md)}[juiceIconButton]{width:var(--juice-control-height-md);height:var(--juice-control-height-md);padding:0}[juiceButton]:focus-visible,[juiceIconButton]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:2px}[juiceButton][data-variant=primary]{background:var(--juice-color-accent);color:var(--juice-color-text-on-accent)}[juiceButton][data-variant=primary]:hover{background:var(--juice-color-accent-hover)}[juiceButton][data-variant=primary]:active{background:var(--juice-color-accent-active)}[juiceButton][data-variant=secondary]{background:var(--juice-color-surface);border-color:var(--juice-color-border-strong)}[juiceButton][data-variant=secondary]:hover,[juiceButton][data-variant=ghost]:hover,[juiceIconButton]:hover{background:var(--juice-color-accent-subtle)}[juiceButton][data-variant=danger]{background:var(--juice-color-bad);color:var(--juice-color-text-on-accent)}[juiceButton][data-variant=danger]:hover{background:var(--juice-color-bad);filter:brightness(.92)}[juiceButton]:disabled,[juiceIconButton]:disabled,[juiceButton][aria-disabled=true]{background:var(--juice-color-disabled-bg);border-color:transparent;color:var(--juice-color-disabled-text);cursor:not-allowed;filter:none}[juiceButton][data-loading]{cursor:progress}.juice-button__spinner{box-sizing:border-box;width:1em;height:1em;border:2px solid currentColor;border-right-color:transparent;border-radius:var(--juice-radius-full);animation:juice-button-spin .7s linear infinite}@media(prefers-reduced-motion:reduce){.juice-button__spinner{animation-duration:3s}}@keyframes juice-button-spin{to{transform:rotate(360deg)}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
99
+ }
100
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceButton, decorators: [{
101
+ type: Component,
102
+ args: [{ selector: 'button[juiceButton], a[juiceButton]', template: `@if (loading()) {<span class="juice-button__spinner" aria-hidden="true"></span>}<span class="juice-button__label"><ng-content /></span>`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
103
+ '[attr.data-variant]': 'variant()',
104
+ '[attr.data-size]': 'size()',
105
+ '[attr.data-loading]': 'loading() ? "" : null',
106
+ '[attr.aria-busy]': 'loading() ? "true" : null',
107
+ }, styles: ["[juiceButton],[juiceIconButton]{box-sizing:border-box;position:relative;display:inline-flex;align-items:center;justify-content:center;gap:var(--juice-space-2);min-height:var(--juice-control-height-md);padding:0 var(--juice-space-4);border:1px solid transparent;border-radius:var(--juice-radius-md);background:transparent;color:var(--juice-color-text);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm);font-weight:var(--juice-weight-medium);line-height:1;text-decoration:none;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--juice-duration-fast) var(--juice-ease-standard),border-color var(--juice-duration-fast) var(--juice-ease-standard),color var(--juice-duration-fast) var(--juice-ease-standard)}[juiceButton][data-size=sm]{min-height:var(--juice-control-height-sm);padding:0 var(--juice-space-3);font-size:var(--juice-text-xs)}[juiceButton][data-size=lg]{min-height:var(--juice-control-height-lg);padding:0 var(--juice-space-6);font-size:var(--juice-text-md)}[juiceIconButton]{width:var(--juice-control-height-md);height:var(--juice-control-height-md);padding:0}[juiceButton]:focus-visible,[juiceIconButton]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:2px}[juiceButton][data-variant=primary]{background:var(--juice-color-accent);color:var(--juice-color-text-on-accent)}[juiceButton][data-variant=primary]:hover{background:var(--juice-color-accent-hover)}[juiceButton][data-variant=primary]:active{background:var(--juice-color-accent-active)}[juiceButton][data-variant=secondary]{background:var(--juice-color-surface);border-color:var(--juice-color-border-strong)}[juiceButton][data-variant=secondary]:hover,[juiceButton][data-variant=ghost]:hover,[juiceIconButton]:hover{background:var(--juice-color-accent-subtle)}[juiceButton][data-variant=danger]{background:var(--juice-color-bad);color:var(--juice-color-text-on-accent)}[juiceButton][data-variant=danger]:hover{background:var(--juice-color-bad);filter:brightness(.92)}[juiceButton]:disabled,[juiceIconButton]:disabled,[juiceButton][aria-disabled=true]{background:var(--juice-color-disabled-bg);border-color:transparent;color:var(--juice-color-disabled-text);cursor:not-allowed;filter:none}[juiceButton][data-loading]{cursor:progress}.juice-button__spinner{box-sizing:border-box;width:1em;height:1em;border:2px solid currentColor;border-right-color:transparent;border-radius:var(--juice-radius-full);animation:juice-button-spin .7s linear infinite}@media(prefers-reduced-motion:reduce){.juice-button__spinner{animation-duration:3s}}@keyframes juice-button-spin{to{transform:rotate(360deg)}}\n"] }]
108
+ }], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }] } });
109
+ /** Square icon-only button. It has no visible text, so an `aria-label` (or `aria-labelledby`) is required. */
110
+ class JuiceIconButton {
111
+ constructor() {
112
+ const el = inject(ElementRef).nativeElement;
113
+ if (!el.hasAttribute('type'))
114
+ el.setAttribute('type', 'button');
115
+ if (isDevMode()) {
116
+ afterNextRender(() => {
117
+ if (!el.getAttribute('aria-label')?.trim() && !el.getAttribute('aria-labelledby')?.trim()) {
118
+ console.error('[juiceIconButton] An icon button needs an aria-label (or aria-labelledby).', el);
119
+ }
120
+ });
121
+ }
122
+ }
123
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceIconButton, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
124
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: JuiceIconButton, isStandalone: true, selector: "button[juiceIconButton]", ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["[juiceButton],[juiceIconButton]{box-sizing:border-box;position:relative;display:inline-flex;align-items:center;justify-content:center;gap:var(--juice-space-2);min-height:var(--juice-control-height-md);padding:0 var(--juice-space-4);border:1px solid transparent;border-radius:var(--juice-radius-md);background:transparent;color:var(--juice-color-text);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm);font-weight:var(--juice-weight-medium);line-height:1;text-decoration:none;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--juice-duration-fast) var(--juice-ease-standard),border-color var(--juice-duration-fast) var(--juice-ease-standard),color var(--juice-duration-fast) var(--juice-ease-standard)}[juiceButton][data-size=sm]{min-height:var(--juice-control-height-sm);padding:0 var(--juice-space-3);font-size:var(--juice-text-xs)}[juiceButton][data-size=lg]{min-height:var(--juice-control-height-lg);padding:0 var(--juice-space-6);font-size:var(--juice-text-md)}[juiceIconButton]{width:var(--juice-control-height-md);height:var(--juice-control-height-md);padding:0}[juiceButton]:focus-visible,[juiceIconButton]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:2px}[juiceButton][data-variant=primary]{background:var(--juice-color-accent);color:var(--juice-color-text-on-accent)}[juiceButton][data-variant=primary]:hover{background:var(--juice-color-accent-hover)}[juiceButton][data-variant=primary]:active{background:var(--juice-color-accent-active)}[juiceButton][data-variant=secondary]{background:var(--juice-color-surface);border-color:var(--juice-color-border-strong)}[juiceButton][data-variant=secondary]:hover,[juiceButton][data-variant=ghost]:hover,[juiceIconButton]:hover{background:var(--juice-color-accent-subtle)}[juiceButton][data-variant=danger]{background:var(--juice-color-bad);color:var(--juice-color-text-on-accent)}[juiceButton][data-variant=danger]:hover{background:var(--juice-color-bad);filter:brightness(.92)}[juiceButton]:disabled,[juiceIconButton]:disabled,[juiceButton][aria-disabled=true]{background:var(--juice-color-disabled-bg);border-color:transparent;color:var(--juice-color-disabled-text);cursor:not-allowed;filter:none}[juiceButton][data-loading]{cursor:progress}.juice-button__spinner{box-sizing:border-box;width:1em;height:1em;border:2px solid currentColor;border-right-color:transparent;border-radius:var(--juice-radius-full);animation:juice-button-spin .7s linear infinite}@media(prefers-reduced-motion:reduce){.juice-button__spinner{animation-duration:3s}}@keyframes juice-button-spin{to{transform:rotate(360deg)}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
125
+ }
126
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceIconButton, decorators: [{
127
+ type: Component,
128
+ args: [{ selector: 'button[juiceIconButton]', template: `<ng-content />`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: ["[juiceButton],[juiceIconButton]{box-sizing:border-box;position:relative;display:inline-flex;align-items:center;justify-content:center;gap:var(--juice-space-2);min-height:var(--juice-control-height-md);padding:0 var(--juice-space-4);border:1px solid transparent;border-radius:var(--juice-radius-md);background:transparent;color:var(--juice-color-text);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm);font-weight:var(--juice-weight-medium);line-height:1;text-decoration:none;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--juice-duration-fast) var(--juice-ease-standard),border-color var(--juice-duration-fast) var(--juice-ease-standard),color var(--juice-duration-fast) var(--juice-ease-standard)}[juiceButton][data-size=sm]{min-height:var(--juice-control-height-sm);padding:0 var(--juice-space-3);font-size:var(--juice-text-xs)}[juiceButton][data-size=lg]{min-height:var(--juice-control-height-lg);padding:0 var(--juice-space-6);font-size:var(--juice-text-md)}[juiceIconButton]{width:var(--juice-control-height-md);height:var(--juice-control-height-md);padding:0}[juiceButton]:focus-visible,[juiceIconButton]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:2px}[juiceButton][data-variant=primary]{background:var(--juice-color-accent);color:var(--juice-color-text-on-accent)}[juiceButton][data-variant=primary]:hover{background:var(--juice-color-accent-hover)}[juiceButton][data-variant=primary]:active{background:var(--juice-color-accent-active)}[juiceButton][data-variant=secondary]{background:var(--juice-color-surface);border-color:var(--juice-color-border-strong)}[juiceButton][data-variant=secondary]:hover,[juiceButton][data-variant=ghost]:hover,[juiceIconButton]:hover{background:var(--juice-color-accent-subtle)}[juiceButton][data-variant=danger]{background:var(--juice-color-bad);color:var(--juice-color-text-on-accent)}[juiceButton][data-variant=danger]:hover{background:var(--juice-color-bad);filter:brightness(.92)}[juiceButton]:disabled,[juiceIconButton]:disabled,[juiceButton][aria-disabled=true]{background:var(--juice-color-disabled-bg);border-color:transparent;color:var(--juice-color-disabled-text);cursor:not-allowed;filter:none}[juiceButton][data-loading]{cursor:progress}.juice-button__spinner{box-sizing:border-box;width:1em;height:1em;border:2px solid currentColor;border-right-color:transparent;border-radius:var(--juice-radius-full);animation:juice-button-spin .7s linear infinite}@media(prefers-reduced-motion:reduce){.juice-button__spinner{animation-duration:3s}}@keyframes juice-button-spin{to{transform:rotate(360deg)}}\n"] }]
129
+ }], ctorParameters: () => [] });
130
+
131
+ const loaded = new WeakMap();
132
+ let counter = 0;
133
+ /** Next unique DOM id with the given prefix (unique per page, not per component). */
134
+ function nextId(prefix) {
135
+ return `${prefix}-${++counter}`;
136
+ }
137
+ /**
138
+ * Directives on native elements (`input[juiceInput]`) cannot own styles. This instantiates a hidden component whose
139
+ * `ViewEncapsulation.None` styles Angular adds to the document once per application. Call it from an injection context.
140
+ */
141
+ function loadStyles(styleHost) {
142
+ const appRef = inject(ApplicationRef);
143
+ const env = inject(EnvironmentInjector);
144
+ let set = loaded.get(appRef);
145
+ if (!set)
146
+ loaded.set(appRef, (set = new Set()));
147
+ if (set.has(styleHost))
148
+ return;
149
+ set.add(styleHost);
150
+ createComponent(styleHost, { environmentInjector: env });
151
+ }
152
+
153
+ const FIELD_STYLES = `
154
+ juice-field { display: flex; flex-direction: column; gap: var(--juice-space-1); font-family: var(--juice-font-sans); }
155
+ .juice-field__label { color: var(--juice-color-text); font-size: var(--juice-text-sm); font-weight: var(--juice-weight-medium); }
156
+ .juice-field__hint { color: var(--juice-color-text-muted); font-size: var(--juice-text-xs); }
157
+ .juice-field__error { color: var(--juice-color-bad); font-size: var(--juice-text-xs); }
158
+ input[juiceInput], textarea[juiceInput] {
159
+ box-sizing: border-box;
160
+ width: 100%;
161
+ min-height: var(--juice-control-height-md);
162
+ padding: 0 var(--juice-space-3);
163
+ border: 1px solid var(--juice-color-border-strong);
164
+ border-radius: var(--juice-radius-md);
165
+ background: var(--juice-color-surface);
166
+ color: var(--juice-color-text);
167
+ font-family: var(--juice-font-sans);
168
+ font-size: var(--juice-text-sm);
169
+ transition: border-color var(--juice-duration-fast) var(--juice-ease-standard);
170
+ }
171
+ textarea[juiceInput] { padding-top: var(--juice-space-2); padding-bottom: var(--juice-space-2); line-height: 1.5; resize: vertical; }
172
+ input[juiceInput]::placeholder, textarea[juiceInput]::placeholder { color: var(--juice-color-text-subtle); }
173
+ input[juiceInput]:hover, textarea[juiceInput]:hover { border-color: var(--juice-color-text-muted); }
174
+ input[juiceInput]:focus-visible, textarea[juiceInput]:focus-visible {
175
+ outline: 2px solid var(--juice-color-focus-ring);
176
+ outline-offset: 1px;
177
+ }
178
+ input[juiceInput][aria-invalid='true'], textarea[juiceInput][aria-invalid='true'] { border-color: var(--juice-color-bad); }
179
+ input[juiceInput]:disabled, textarea[juiceInput]:disabled {
180
+ background: var(--juice-color-disabled-bg);
181
+ color: var(--juice-color-disabled-text);
182
+ cursor: not-allowed;
183
+ }
184
+ `;
185
+ /**
186
+ * Label, hint and error wrapper for one form control. The projected `[juiceInput]` (or `<juice-select>`) gets the id the
187
+ * label points at, `aria-describedby` for hint and error, and `aria-invalid`.
188
+ */
189
+ class JuiceField {
190
+ constructor() {
191
+ this.label = input.required(/* @ts-ignore */
192
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
193
+ this.hint = input('', /* @ts-ignore */
194
+ ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
195
+ this.error = input('', /* @ts-ignore */
196
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
197
+ this.controlId = nextId('juice-field');
198
+ this.hintId = `${this.controlId}-hint`;
199
+ this.errorId = `${this.controlId}-error`;
200
+ this.labelId = `${this.controlId}-label`;
201
+ this.invalid = () => !!this.error();
202
+ this.describedBy = computed(() => {
203
+ const ids = [this.hint() ? this.hintId : '', this.error() ? this.errorId : ''].filter(Boolean);
204
+ return ids.length ? ids.join(' ') : null;
205
+ }, /* @ts-ignore */
206
+ ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
207
+ }
208
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceField, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
209
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: JuiceField, isStandalone: true, selector: "juice-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
210
+ <label class="juice-field__label" [id]="labelId" [attr.for]="controlId">{{ label() }}</label>
211
+ <ng-content />
212
+ @if (hint()) {
213
+ <div class="juice-field__hint" [id]="hintId">{{ hint() }}</div>
214
+ }
215
+ @if (error()) {
216
+ <div class="juice-field__error" [id]="errorId">{{ error() }}</div>
217
+ }
218
+ `, isInline: true, styles: ["juice-field{display:flex;flex-direction:column;gap:var(--juice-space-1);font-family:var(--juice-font-sans)}.juice-field__label{color:var(--juice-color-text);font-size:var(--juice-text-sm);font-weight:var(--juice-weight-medium)}.juice-field__hint{color:var(--juice-color-text-muted);font-size:var(--juice-text-xs)}.juice-field__error{color:var(--juice-color-bad);font-size:var(--juice-text-xs)}input[juiceInput],textarea[juiceInput]{box-sizing:border-box;width:100%;min-height:var(--juice-control-height-md);padding:0 var(--juice-space-3);border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-md);background:var(--juice-color-surface);color:var(--juice-color-text);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm);transition:border-color var(--juice-duration-fast) var(--juice-ease-standard)}textarea[juiceInput]{padding-top:var(--juice-space-2);padding-bottom:var(--juice-space-2);line-height:1.5;resize:vertical}input[juiceInput]::placeholder,textarea[juiceInput]::placeholder{color:var(--juice-color-text-subtle)}input[juiceInput]:hover,textarea[juiceInput]:hover{border-color:var(--juice-color-text-muted)}input[juiceInput]:focus-visible,textarea[juiceInput]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:1px}input[juiceInput][aria-invalid=true],textarea[juiceInput][aria-invalid=true]{border-color:var(--juice-color-bad)}input[juiceInput]:disabled,textarea[juiceInput]:disabled{background:var(--juice-color-disabled-bg);color:var(--juice-color-disabled-text);cursor:not-allowed}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
219
+ }
220
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceField, decorators: [{
221
+ type: Component,
222
+ args: [{ selector: 'juice-field', template: `
223
+ <label class="juice-field__label" [id]="labelId" [attr.for]="controlId">{{ label() }}</label>
224
+ <ng-content />
225
+ @if (hint()) {
226
+ <div class="juice-field__hint" [id]="hintId">{{ hint() }}</div>
227
+ }
228
+ @if (error()) {
229
+ <div class="juice-field__error" [id]="errorId">{{ error() }}</div>
230
+ }
231
+ `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: ["juice-field{display:flex;flex-direction:column;gap:var(--juice-space-1);font-family:var(--juice-font-sans)}.juice-field__label{color:var(--juice-color-text);font-size:var(--juice-text-sm);font-weight:var(--juice-weight-medium)}.juice-field__hint{color:var(--juice-color-text-muted);font-size:var(--juice-text-xs)}.juice-field__error{color:var(--juice-color-bad);font-size:var(--juice-text-xs)}input[juiceInput],textarea[juiceInput]{box-sizing:border-box;width:100%;min-height:var(--juice-control-height-md);padding:0 var(--juice-space-3);border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-md);background:var(--juice-color-surface);color:var(--juice-color-text);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm);transition:border-color var(--juice-duration-fast) var(--juice-ease-standard)}textarea[juiceInput]{padding-top:var(--juice-space-2);padding-bottom:var(--juice-space-2);line-height:1.5;resize:vertical}input[juiceInput]::placeholder,textarea[juiceInput]::placeholder{color:var(--juice-color-text-subtle)}input[juiceInput]:hover,textarea[juiceInput]:hover{border-color:var(--juice-color-text-muted)}input[juiceInput]:focus-visible,textarea[juiceInput]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:1px}input[juiceInput][aria-invalid=true],textarea[juiceInput][aria-invalid=true]{border-color:var(--juice-color-bad)}input[juiceInput]:disabled,textarea[juiceInput]:disabled{background:var(--juice-color-disabled-bg);color:var(--juice-color-disabled-text);cursor:not-allowed}\n"] }]
232
+ }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }] } });
233
+ /** Styles for the text input, wired to a surrounding `<juice-field>` when there is one. */
234
+ class JuiceInput {
235
+ constructor() {
236
+ this.field = inject(JuiceField, { optional: true });
237
+ this.control = inject(NgControl, { optional: true, self: true });
238
+ this.state = signal(false, /* @ts-ignore */
239
+ ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
240
+ /** Invalid is shown only once the user has touched the control (or the field was given an error without a form control). */
241
+ this.invalid = computed(() => this.state() || (!this.control && !!this.field?.error()), /* @ts-ignore */
242
+ ...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
243
+ loadStyles(JuiceFieldStyles);
244
+ }
245
+ ngDoCheck() {
246
+ this.sync();
247
+ }
248
+ sync() {
249
+ const c = this.control;
250
+ this.state.set(!!c && !!c.invalid && !!c.touched);
251
+ }
252
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceInput, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
253
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: JuiceInput, isStandalone: true, selector: "input[juiceInput], textarea[juiceInput]", host: { listeners: { "blur": "sync()", "input": "sync()" }, properties: { "attr.id": "field?.controlId ?? null", "attr.aria-describedby": "field?.describedBy() ?? null", "attr.aria-invalid": "invalid() ? \"true\" : null" } }, ngImport: i0 }); }
254
+ }
255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceInput, decorators: [{
256
+ type: Directive,
257
+ args: [{
258
+ selector: 'input[juiceInput], textarea[juiceInput]',
259
+ host: {
260
+ '[attr.id]': 'field?.controlId ?? null',
261
+ '[attr.aria-describedby]': 'field?.describedBy() ?? null',
262
+ '[attr.aria-invalid]': 'invalid() ? "true" : null',
263
+ '(blur)': 'sync()',
264
+ '(input)': 'sync()',
265
+ },
266
+ }]
267
+ }], ctorParameters: () => [] });
268
+ class JuiceFieldStyles {
269
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceFieldStyles, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
270
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: JuiceFieldStyles, isStandalone: true, selector: "juice-field-styles", ngImport: i0, template: '', isInline: true, styles: ["juice-field{display:flex;flex-direction:column;gap:var(--juice-space-1);font-family:var(--juice-font-sans)}.juice-field__label{color:var(--juice-color-text);font-size:var(--juice-text-sm);font-weight:var(--juice-weight-medium)}.juice-field__hint{color:var(--juice-color-text-muted);font-size:var(--juice-text-xs)}.juice-field__error{color:var(--juice-color-bad);font-size:var(--juice-text-xs)}input[juiceInput],textarea[juiceInput]{box-sizing:border-box;width:100%;min-height:var(--juice-control-height-md);padding:0 var(--juice-space-3);border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-md);background:var(--juice-color-surface);color:var(--juice-color-text);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm);transition:border-color var(--juice-duration-fast) var(--juice-ease-standard)}textarea[juiceInput]{padding-top:var(--juice-space-2);padding-bottom:var(--juice-space-2);line-height:1.5;resize:vertical}input[juiceInput]::placeholder,textarea[juiceInput]::placeholder{color:var(--juice-color-text-subtle)}input[juiceInput]:hover,textarea[juiceInput]:hover{border-color:var(--juice-color-text-muted)}input[juiceInput]:focus-visible,textarea[juiceInput]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:1px}input[juiceInput][aria-invalid=true],textarea[juiceInput][aria-invalid=true]{border-color:var(--juice-color-bad)}input[juiceInput]:disabled,textarea[juiceInput]:disabled{background:var(--juice-color-disabled-bg);color:var(--juice-color-disabled-text);cursor:not-allowed}\n"], encapsulation: i0.ViewEncapsulation.None }); }
271
+ }
272
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceFieldStyles, decorators: [{
273
+ type: Component,
274
+ args: [{ selector: 'juice-field-styles', template: '', encapsulation: ViewEncapsulation.None, styles: ["juice-field{display:flex;flex-direction:column;gap:var(--juice-space-1);font-family:var(--juice-font-sans)}.juice-field__label{color:var(--juice-color-text);font-size:var(--juice-text-sm);font-weight:var(--juice-weight-medium)}.juice-field__hint{color:var(--juice-color-text-muted);font-size:var(--juice-text-xs)}.juice-field__error{color:var(--juice-color-bad);font-size:var(--juice-text-xs)}input[juiceInput],textarea[juiceInput]{box-sizing:border-box;width:100%;min-height:var(--juice-control-height-md);padding:0 var(--juice-space-3);border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-md);background:var(--juice-color-surface);color:var(--juice-color-text);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm);transition:border-color var(--juice-duration-fast) var(--juice-ease-standard)}textarea[juiceInput]{padding-top:var(--juice-space-2);padding-bottom:var(--juice-space-2);line-height:1.5;resize:vertical}input[juiceInput]::placeholder,textarea[juiceInput]::placeholder{color:var(--juice-color-text-subtle)}input[juiceInput]:hover,textarea[juiceInput]:hover{border-color:var(--juice-color-text-muted)}input[juiceInput]:focus-visible,textarea[juiceInput]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:1px}input[juiceInput][aria-invalid=true],textarea[juiceInput][aria-invalid=true]{border-color:var(--juice-color-bad)}input[juiceInput]:disabled,textarea[juiceInput]:disabled{background:var(--juice-color-disabled-bg);color:var(--juice-color-disabled-text);cursor:not-allowed}\n"] }]
275
+ }] });
276
+
277
+ const JUICE_SELECT_HOST = new InjectionToken('JUICE_SELECT_HOST');
278
+ const SELECT_STYLES = `
279
+ juice-select { display: block; position: relative; font-family: var(--juice-font-sans); }
280
+ .juice-select__trigger {
281
+ box-sizing: border-box;
282
+ display: flex;
283
+ align-items: center;
284
+ justify-content: space-between;
285
+ gap: var(--juice-space-2);
286
+ width: 100%;
287
+ min-height: var(--juice-control-height-md);
288
+ padding: 0 var(--juice-space-3);
289
+ border: 1px solid var(--juice-color-border-strong);
290
+ border-radius: var(--juice-radius-md);
291
+ background: var(--juice-color-surface);
292
+ color: var(--juice-color-text);
293
+ font: inherit;
294
+ font-size: var(--juice-text-sm);
295
+ text-align: start;
296
+ cursor: pointer;
297
+ }
298
+ .juice-select__trigger:hover { border-color: var(--juice-color-text-muted); }
299
+ .juice-select__trigger:focus-visible { outline: 2px solid var(--juice-color-focus-ring); outline-offset: 1px; }
300
+ .juice-select__trigger[aria-invalid='true'] { border-color: var(--juice-color-bad); }
301
+ .juice-select__trigger:disabled { background: var(--juice-color-disabled-bg); color: var(--juice-color-disabled-text); cursor: not-allowed; }
302
+ .juice-select__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
303
+ .juice-select__placeholder { color: var(--juice-color-text-muted); }
304
+ .juice-select__chevron { flex: none; width: 1em; height: 1em; }
305
+ .juice-select-panel {
306
+ box-sizing: border-box;
307
+ max-height: 18rem;
308
+ margin: 0;
309
+ padding: var(--juice-space-1);
310
+ overflow-y: auto;
311
+ border: 1px solid var(--juice-color-border);
312
+ border-radius: var(--juice-radius-md);
313
+ background: var(--juice-color-surface-raised);
314
+ color: var(--juice-color-text);
315
+ box-shadow: var(--juice-shadow-overlay);
316
+ font-family: var(--juice-font-sans);
317
+ font-size: var(--juice-text-sm);
318
+ }
319
+ juice-option {
320
+ display: block;
321
+ padding: var(--juice-space-2) var(--juice-space-3);
322
+ border-radius: var(--juice-radius-sm);
323
+ cursor: pointer;
324
+ }
325
+ juice-option.juice-option--active { background: var(--juice-color-accent-subtle); }
326
+ juice-option[aria-selected='true'] { font-weight: var(--juice-weight-semibold); }
327
+ juice-option[aria-disabled='true'] { color: var(--juice-color-disabled-text); cursor: not-allowed; }
328
+ `;
329
+ /** One choice in a `<juice-select>`. Its text is the label shown in the trigger and matched by typeahead. */
330
+ class JuiceOption {
331
+ constructor() {
332
+ this.value = input(/* @ts-ignore */
333
+ ...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
334
+ this.isDisabled = input(false, { ...(ngDevMode ? { debugName: "isDisabled" } : /* istanbul ignore next */ {}), alias: 'disabled', transform: booleanAttribute });
335
+ this.id = nextId('juice-option');
336
+ this.select = inject(JUICE_SELECT_HOST);
337
+ this.el = inject(ElementRef).nativeElement;
338
+ this.active = signal(false, /* @ts-ignore */
339
+ ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
340
+ this.selected = computed(() => this.select.value() === this.value(), /* @ts-ignore */
341
+ ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
342
+ }
343
+ /** Read by `ListKeyManager` through `skipPredicate`. */
344
+ get disabled() {
345
+ return this.isDisabled();
346
+ }
347
+ getLabel() {
348
+ return (this.el.textContent ?? '').trim();
349
+ }
350
+ setActiveStyles() {
351
+ this.active.set(true);
352
+ this.el.scrollIntoView?.({ block: 'nearest' });
353
+ }
354
+ setInactiveStyles() {
355
+ this.active.set(false);
356
+ }
357
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceOption, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
358
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: JuiceOption, isStandalone: true, selector: "juice-option", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, isDisabled: { classPropertyName: "isDisabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "click": "select.choose(this)", "mouseenter": "select.activate(this)" }, properties: { "id": "id", "attr.aria-selected": "selected() ? \"true\" : \"false\"", "attr.aria-disabled": "isDisabled() ? \"true\" : null", "class.juice-option--active": "active()" } }, ngImport: i0, template: '<ng-content />', isInline: true, styles: ["juice-select{display:block;position:relative;font-family:var(--juice-font-sans)}.juice-select__trigger{box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:var(--juice-space-2);width:100%;min-height:var(--juice-control-height-md);padding:0 var(--juice-space-3);border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-md);background:var(--juice-color-surface);color:var(--juice-color-text);font:inherit;font-size:var(--juice-text-sm);text-align:start;cursor:pointer}.juice-select__trigger:hover{border-color:var(--juice-color-text-muted)}.juice-select__trigger:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:1px}.juice-select__trigger[aria-invalid=true]{border-color:var(--juice-color-bad)}.juice-select__trigger:disabled{background:var(--juice-color-disabled-bg);color:var(--juice-color-disabled-text);cursor:not-allowed}.juice-select__value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-select__placeholder{color:var(--juice-color-text-muted)}.juice-select__chevron{flex:none;width:1em;height:1em}.juice-select-panel{box-sizing:border-box;max-height:18rem;margin:0;padding:var(--juice-space-1);overflow-y:auto;border:1px solid var(--juice-color-border);border-radius:var(--juice-radius-md);background:var(--juice-color-surface-raised);color:var(--juice-color-text);box-shadow:var(--juice-shadow-overlay);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm)}juice-option{display:block;padding:var(--juice-space-2) var(--juice-space-3);border-radius:var(--juice-radius-sm);cursor:pointer}juice-option.juice-option--active{background:var(--juice-color-accent-subtle)}juice-option[aria-selected=true]{font-weight:var(--juice-weight-semibold)}juice-option[aria-disabled=true]{color:var(--juice-color-disabled-text);cursor:not-allowed}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
359
+ }
360
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceOption, decorators: [{
361
+ type: Component,
362
+ args: [{ selector: 'juice-option', template: '<ng-content />', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
363
+ role: 'option',
364
+ '[id]': 'id',
365
+ '[attr.aria-selected]': 'selected() ? "true" : "false"',
366
+ '[attr.aria-disabled]': 'isDisabled() ? "true" : null',
367
+ '[class.juice-option--active]': 'active()',
368
+ '(click)': 'select.choose(this)',
369
+ '(mouseenter)': 'select.activate(this)',
370
+ }, styles: ["juice-select{display:block;position:relative;font-family:var(--juice-font-sans)}.juice-select__trigger{box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:var(--juice-space-2);width:100%;min-height:var(--juice-control-height-md);padding:0 var(--juice-space-3);border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-md);background:var(--juice-color-surface);color:var(--juice-color-text);font:inherit;font-size:var(--juice-text-sm);text-align:start;cursor:pointer}.juice-select__trigger:hover{border-color:var(--juice-color-text-muted)}.juice-select__trigger:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:1px}.juice-select__trigger[aria-invalid=true]{border-color:var(--juice-color-bad)}.juice-select__trigger:disabled{background:var(--juice-color-disabled-bg);color:var(--juice-color-disabled-text);cursor:not-allowed}.juice-select__value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-select__placeholder{color:var(--juice-color-text-muted)}.juice-select__chevron{flex:none;width:1em;height:1em}.juice-select-panel{box-sizing:border-box;max-height:18rem;margin:0;padding:var(--juice-space-1);overflow-y:auto;border:1px solid var(--juice-color-border);border-radius:var(--juice-radius-md);background:var(--juice-color-surface-raised);color:var(--juice-color-text);box-shadow:var(--juice-shadow-overlay);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm)}juice-option{display:block;padding:var(--juice-space-2) var(--juice-space-3);border-radius:var(--juice-radius-sm);cursor:pointer}juice-option.juice-option--active{background:var(--juice-color-accent-subtle)}juice-option[aria-selected=true]{font-weight:var(--juice-weight-semibold)}juice-option[aria-disabled=true]{color:var(--juice-color-disabled-text);cursor:not-allowed}\n"] }]
371
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
372
+ const POSITIONS = [
373
+ { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 4 },
374
+ { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -4 },
375
+ ];
376
+ /**
377
+ * Single-select dropdown. Focus stays on the trigger (combobox pattern); the options are exposed through
378
+ * `aria-activedescendant`. The list opens in a CDK overlay, so it is not clipped by scrolling or `overflow` ancestors.
379
+ */
380
+ class JuiceSelect {
381
+ constructor() {
382
+ this.placeholder = input('', /* @ts-ignore */
383
+ ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
384
+ /** Accessible name when the select is not inside a `<juice-field>`. */
385
+ this.label = input('', /* @ts-ignore */
386
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
387
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
388
+ this.value = model(undefined, /* @ts-ignore */
389
+ ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
390
+ this.field = inject(JuiceField, { optional: true });
391
+ this.triggerId = nextId('juice-select');
392
+ this.listboxId = nextId('juice-listbox');
393
+ this.positions = POSITIONS;
394
+ this.scrollStrategy = inject(Overlay).scrollStrategies.reposition();
395
+ this.open = signal(false, /* @ts-ignore */
396
+ ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
397
+ this.triggerWidth = signal(0, /* @ts-ignore */
398
+ ...(ngDevMode ? [{ debugName: "triggerWidth" }] : /* istanbul ignore next */ []));
399
+ this.activeId = signal(null, /* @ts-ignore */
400
+ ...(ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []));
401
+ this.displayLabel = signal('', /* @ts-ignore */
402
+ ...(ngDevMode ? [{ debugName: "displayLabel" }] : /* istanbul ignore next */ []));
403
+ this.hasValue = signal(false, /* @ts-ignore */
404
+ ...(ngDevMode ? [{ debugName: "hasValue" }] : /* istanbul ignore next */ []));
405
+ this.cvaDisabled = signal(false, /* @ts-ignore */
406
+ ...(ngDevMode ? [{ debugName: "cvaDisabled" }] : /* istanbul ignore next */ []));
407
+ this.isDisabled = computed(() => this.disabled() || this.cvaDisabled(), /* @ts-ignore */
408
+ ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
409
+ this.options = contentChildren(JuiceOption, { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), descendants: true });
410
+ this.trigger = viewChild.required('trigger', /* @ts-ignore */
411
+ ...(ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []));
412
+ this.keys = new ActiveDescendantKeyManager(this.options, inject(Injector))
413
+ .withTypeAhead(200)
414
+ .withHomeAndEnd()
415
+ .skipPredicate((o) => o.disabled);
416
+ this.onChange = () => undefined;
417
+ this.onTouched = () => undefined;
418
+ this.keys.change.subscribe((i) => this.activeId.set(this.options()[i]?.id ?? null));
419
+ }
420
+ ngAfterContentChecked() {
421
+ const match = this.options().find((o) => o.value() === this.value());
422
+ const text = match ? match.getLabel() : this.placeholder();
423
+ if (this.displayLabel() !== text)
424
+ this.displayLabel.set(text);
425
+ if (this.hasValue() !== !!match)
426
+ this.hasValue.set(!!match);
427
+ }
428
+ writeValue(v) {
429
+ this.value.set(v);
430
+ }
431
+ registerOnChange(fn) {
432
+ this.onChange = fn;
433
+ }
434
+ registerOnTouched(fn) {
435
+ this.onTouched = fn;
436
+ }
437
+ setDisabledState(d) {
438
+ this.cvaDisabled.set(d);
439
+ if (d)
440
+ this.close();
441
+ }
442
+ choose(option) {
443
+ if (option.disabled)
444
+ return;
445
+ this.value.set(option.value());
446
+ this.onChange(option.value());
447
+ this.close();
448
+ }
449
+ activate(option) {
450
+ if (!option.disabled)
451
+ this.keys.setActiveItem(option);
452
+ }
453
+ toggle() {
454
+ if (this.open())
455
+ this.close();
456
+ else
457
+ this.show();
458
+ }
459
+ show() {
460
+ if (this.isDisabled() || this.open())
461
+ return;
462
+ this.triggerWidth.set(this.trigger().nativeElement.offsetWidth);
463
+ this.open.set(true);
464
+ const items = this.options();
465
+ const selected = items.findIndex((o) => o.value() === this.value() && !o.disabled);
466
+ if (selected >= 0)
467
+ this.keys.setActiveItem(selected);
468
+ else
469
+ this.keys.setFirstItemActive();
470
+ }
471
+ close() {
472
+ if (!this.open())
473
+ return;
474
+ this.open.set(false);
475
+ this.keys.setActiveItem(-1);
476
+ }
477
+ onOutsideClick(e) {
478
+ if (!this.trigger().nativeElement.contains(e.target))
479
+ this.close();
480
+ }
481
+ onKeydown(e) {
482
+ if (this.isDisabled() || e.altKey || e.ctrlKey || e.metaKey)
483
+ return;
484
+ const key = e.key;
485
+ if (!this.open()) {
486
+ if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Enter' || key === ' ') {
487
+ e.preventDefault();
488
+ this.show();
489
+ }
490
+ else if (key.length === 1) {
491
+ this.show();
492
+ this.keys.onKeydown(e);
493
+ }
494
+ return;
495
+ }
496
+ if (key === 'Escape') {
497
+ e.preventDefault();
498
+ e.stopPropagation();
499
+ this.close();
500
+ }
501
+ else if (key === 'Tab') {
502
+ this.close(); // closes without selecting; focus moves on naturally
503
+ }
504
+ else if (key === 'Enter' || key === ' ') {
505
+ e.preventDefault();
506
+ const active = this.keys.activeItem;
507
+ if (active)
508
+ this.choose(active);
509
+ }
510
+ else {
511
+ this.keys.onKeydown(e);
512
+ }
513
+ }
514
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceSelect, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
515
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: JuiceSelect, isStandalone: true, selector: "juice-select", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, providers: [
516
+ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => JuiceSelect), multi: true },
517
+ { provide: JUICE_SELECT_HOST, useExisting: forwardRef(() => JuiceSelect) },
518
+ ], queries: [{ propertyName: "options", predicate: JuiceOption, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "trigger", first: true, predicate: ["trigger"], descendants: true, isSignal: true }], ngImport: i0, template: `
519
+ <button
520
+ #trigger
521
+ type="button"
522
+ class="juice-select__trigger"
523
+ cdkOverlayOrigin
524
+ #origin="cdkOverlayOrigin"
525
+ role="combobox"
526
+ aria-haspopup="listbox"
527
+ [attr.id]="field?.controlId ?? triggerId"
528
+ [attr.aria-expanded]="open() ? 'true' : 'false'"
529
+ [attr.aria-controls]="open() ? listboxId : null"
530
+ [attr.aria-activedescendant]="open() ? activeId() : null"
531
+ [attr.aria-label]="field ? null : label() || null"
532
+ [attr.aria-describedby]="field?.describedBy() ?? null"
533
+ [attr.aria-invalid]="field && field.invalid() ? 'true' : null"
534
+ [disabled]="isDisabled()"
535
+ (click)="toggle()"
536
+ (keydown)="onKeydown($event)"
537
+ (blur)="onTouched()"
538
+ >
539
+ <span class="juice-select__value" [class.juice-select__placeholder]="!hasValue()">{{ displayLabel() }}</span>
540
+ <svg class="juice-select__chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
541
+ <path d="m6 9 6 6 6-6" />
542
+ </svg>
543
+ </button>
544
+ <ng-template
545
+ cdkConnectedOverlay
546
+ [cdkConnectedOverlayOrigin]="origin"
547
+ [cdkConnectedOverlayOpen]="open()"
548
+ [cdkConnectedOverlayPositions]="positions"
549
+ [cdkConnectedOverlayMinWidth]="triggerWidth()"
550
+ [cdkConnectedOverlayScrollStrategy]="scrollStrategy"
551
+ (overlayOutsideClick)="onOutsideClick($event)"
552
+ (detach)="close()"
553
+ >
554
+ <div
555
+ class="juice-select-panel"
556
+ role="listbox"
557
+ [id]="listboxId"
558
+ [attr.aria-label]="field ? null : label() || placeholder() || 'Options'"
559
+ [attr.aria-labelledby]="field ? field.labelId : null"
560
+ (mousedown)="$event.preventDefault()"
561
+ >
562
+ <ng-content />
563
+ </div>
564
+ </ng-template>
565
+ `, isInline: true, styles: ["juice-select{display:block;position:relative;font-family:var(--juice-font-sans)}.juice-select__trigger{box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:var(--juice-space-2);width:100%;min-height:var(--juice-control-height-md);padding:0 var(--juice-space-3);border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-md);background:var(--juice-color-surface);color:var(--juice-color-text);font:inherit;font-size:var(--juice-text-sm);text-align:start;cursor:pointer}.juice-select__trigger:hover{border-color:var(--juice-color-text-muted)}.juice-select__trigger:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:1px}.juice-select__trigger[aria-invalid=true]{border-color:var(--juice-color-bad)}.juice-select__trigger:disabled{background:var(--juice-color-disabled-bg);color:var(--juice-color-disabled-text);cursor:not-allowed}.juice-select__value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-select__placeholder{color:var(--juice-color-text-muted)}.juice-select__chevron{flex:none;width:1em;height:1em}.juice-select-panel{box-sizing:border-box;max-height:18rem;margin:0;padding:var(--juice-space-1);overflow-y:auto;border:1px solid var(--juice-color-border);border-radius:var(--juice-radius-md);background:var(--juice-color-surface-raised);color:var(--juice-color-text);box-shadow:var(--juice-shadow-overlay);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm)}juice-option{display:block;padding:var(--juice-space-2) var(--juice-space-3);border-radius:var(--juice-radius-sm);cursor:pointer}juice-option.juice-option--active{background:var(--juice-color-accent-subtle)}juice-option[aria-selected=true]{font-weight:var(--juice-weight-semibold)}juice-option[aria-disabled=true]{color:var(--juice-color-disabled-text);cursor:not-allowed}\n"], dependencies: [{ kind: "directive", type: CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation", "cdkConnectedOverlayUsePopover", "cdkConnectedOverlayMatchWidth", "cdkConnectedOverlay"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
566
+ }
567
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceSelect, decorators: [{
568
+ type: Component,
569
+ args: [{ selector: 'juice-select', imports: [CdkConnectedOverlay, CdkOverlayOrigin], template: `
570
+ <button
571
+ #trigger
572
+ type="button"
573
+ class="juice-select__trigger"
574
+ cdkOverlayOrigin
575
+ #origin="cdkOverlayOrigin"
576
+ role="combobox"
577
+ aria-haspopup="listbox"
578
+ [attr.id]="field?.controlId ?? triggerId"
579
+ [attr.aria-expanded]="open() ? 'true' : 'false'"
580
+ [attr.aria-controls]="open() ? listboxId : null"
581
+ [attr.aria-activedescendant]="open() ? activeId() : null"
582
+ [attr.aria-label]="field ? null : label() || null"
583
+ [attr.aria-describedby]="field?.describedBy() ?? null"
584
+ [attr.aria-invalid]="field && field.invalid() ? 'true' : null"
585
+ [disabled]="isDisabled()"
586
+ (click)="toggle()"
587
+ (keydown)="onKeydown($event)"
588
+ (blur)="onTouched()"
589
+ >
590
+ <span class="juice-select__value" [class.juice-select__placeholder]="!hasValue()">{{ displayLabel() }}</span>
591
+ <svg class="juice-select__chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
592
+ <path d="m6 9 6 6 6-6" />
593
+ </svg>
594
+ </button>
595
+ <ng-template
596
+ cdkConnectedOverlay
597
+ [cdkConnectedOverlayOrigin]="origin"
598
+ [cdkConnectedOverlayOpen]="open()"
599
+ [cdkConnectedOverlayPositions]="positions"
600
+ [cdkConnectedOverlayMinWidth]="triggerWidth()"
601
+ [cdkConnectedOverlayScrollStrategy]="scrollStrategy"
602
+ (overlayOutsideClick)="onOutsideClick($event)"
603
+ (detach)="close()"
604
+ >
605
+ <div
606
+ class="juice-select-panel"
607
+ role="listbox"
608
+ [id]="listboxId"
609
+ [attr.aria-label]="field ? null : label() || placeholder() || 'Options'"
610
+ [attr.aria-labelledby]="field ? field.labelId : null"
611
+ (mousedown)="$event.preventDefault()"
612
+ >
613
+ <ng-content />
614
+ </div>
615
+ </ng-template>
616
+ `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [
617
+ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => JuiceSelect), multi: true },
618
+ { provide: JUICE_SELECT_HOST, useExisting: forwardRef(() => JuiceSelect) },
619
+ ], styles: ["juice-select{display:block;position:relative;font-family:var(--juice-font-sans)}.juice-select__trigger{box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:var(--juice-space-2);width:100%;min-height:var(--juice-control-height-md);padding:0 var(--juice-space-3);border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-md);background:var(--juice-color-surface);color:var(--juice-color-text);font:inherit;font-size:var(--juice-text-sm);text-align:start;cursor:pointer}.juice-select__trigger:hover{border-color:var(--juice-color-text-muted)}.juice-select__trigger:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:1px}.juice-select__trigger[aria-invalid=true]{border-color:var(--juice-color-bad)}.juice-select__trigger:disabled{background:var(--juice-color-disabled-bg);color:var(--juice-color-disabled-text);cursor:not-allowed}.juice-select__value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-select__placeholder{color:var(--juice-color-text-muted)}.juice-select__chevron{flex:none;width:1em;height:1em}.juice-select-panel{box-sizing:border-box;max-height:18rem;margin:0;padding:var(--juice-space-1);overflow-y:auto;border:1px solid var(--juice-color-border);border-radius:var(--juice-radius-md);background:var(--juice-color-surface-raised);color:var(--juice-color-text);box-shadow:var(--juice-shadow-overlay);font-family:var(--juice-font-sans);font-size:var(--juice-text-sm)}juice-option{display:block;padding:var(--juice-space-2) var(--juice-space-3);border-radius:var(--juice-radius-sm);cursor:pointer}juice-option.juice-option--active{background:var(--juice-color-accent-subtle)}juice-option[aria-selected=true]{font-weight:var(--juice-weight-semibold)}juice-option[aria-disabled=true]{color:var(--juice-color-disabled-text);cursor:not-allowed}\n"] }]
620
+ }], ctorParameters: () => [], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], options: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => JuiceOption), { ...{ descendants: true }, isSignal: true }] }], trigger: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }] } });
621
+
622
+ const CHECKBOX_STYLES = `
623
+ input[type='checkbox'][juiceCheckbox] {
624
+ appearance: none;
625
+ box-sizing: border-box;
626
+ position: relative;
627
+ flex: none;
628
+ width: 1rem;
629
+ height: 1rem;
630
+ margin: 0;
631
+ border: 1px solid var(--juice-color-border-strong);
632
+ border-radius: var(--juice-radius-sm);
633
+ background: var(--juice-color-surface);
634
+ vertical-align: middle;
635
+ cursor: pointer;
636
+ }
637
+ input[type='checkbox'][juiceCheckbox]:checked,
638
+ input[type='checkbox'][juiceCheckbox]:indeterminate {
639
+ border-color: var(--juice-color-accent);
640
+ background: var(--juice-color-accent);
641
+ }
642
+ input[type='checkbox'][juiceCheckbox]:checked::after {
643
+ content: '';
644
+ position: absolute;
645
+ left: 4px;
646
+ top: 1px;
647
+ width: 4px;
648
+ height: 8px;
649
+ border: solid var(--juice-color-text-on-accent);
650
+ border-width: 0 2px 2px 0;
651
+ transform: rotate(45deg);
652
+ }
653
+ input[type='checkbox'][juiceCheckbox]:indeterminate::after {
654
+ content: '';
655
+ position: absolute;
656
+ left: 3px;
657
+ top: 6px;
658
+ width: 8px;
659
+ height: 2px;
660
+ background: var(--juice-color-text-on-accent);
661
+ }
662
+ input[type='checkbox'][juiceCheckbox]:focus-visible { outline: 2px solid var(--juice-color-focus-ring); outline-offset: 2px; }
663
+ input[type='checkbox'][juiceCheckbox]:disabled {
664
+ border-color: transparent;
665
+ background: var(--juice-color-disabled-bg);
666
+ cursor: not-allowed;
667
+ }
668
+ `;
669
+ class JuiceCheckboxStyles {
670
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceCheckboxStyles, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
671
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: JuiceCheckboxStyles, isStandalone: true, selector: "juice-checkbox-styles", ngImport: i0, template: '', isInline: true, styles: ["input[type=checkbox][juiceCheckbox]{appearance:none;box-sizing:border-box;position:relative;flex:none;width:1rem;height:1rem;margin:0;border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-sm);background:var(--juice-color-surface);vertical-align:middle;cursor:pointer}input[type=checkbox][juiceCheckbox]:checked,input[type=checkbox][juiceCheckbox]:indeterminate{border-color:var(--juice-color-accent);background:var(--juice-color-accent)}input[type=checkbox][juiceCheckbox]:checked:after{content:\"\";position:absolute;left:4px;top:1px;width:4px;height:8px;border:solid var(--juice-color-text-on-accent);border-width:0 2px 2px 0;transform:rotate(45deg)}input[type=checkbox][juiceCheckbox]:indeterminate:after{content:\"\";position:absolute;left:3px;top:6px;width:8px;height:2px;background:var(--juice-color-text-on-accent)}input[type=checkbox][juiceCheckbox]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:2px}input[type=checkbox][juiceCheckbox]:disabled{border-color:transparent;background:var(--juice-color-disabled-bg);cursor:not-allowed}\n"], encapsulation: i0.ViewEncapsulation.None }); }
672
+ }
673
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceCheckboxStyles, decorators: [{
674
+ type: Component,
675
+ args: [{ selector: 'juice-checkbox-styles', template: '', encapsulation: ViewEncapsulation.None, styles: ["input[type=checkbox][juiceCheckbox]{appearance:none;box-sizing:border-box;position:relative;flex:none;width:1rem;height:1rem;margin:0;border:1px solid var(--juice-color-border-strong);border-radius:var(--juice-radius-sm);background:var(--juice-color-surface);vertical-align:middle;cursor:pointer}input[type=checkbox][juiceCheckbox]:checked,input[type=checkbox][juiceCheckbox]:indeterminate{border-color:var(--juice-color-accent);background:var(--juice-color-accent)}input[type=checkbox][juiceCheckbox]:checked:after{content:\"\";position:absolute;left:4px;top:1px;width:4px;height:8px;border:solid var(--juice-color-text-on-accent);border-width:0 2px 2px 0;transform:rotate(45deg)}input[type=checkbox][juiceCheckbox]:indeterminate:after{content:\"\";position:absolute;left:3px;top:6px;width:8px;height:2px;background:var(--juice-color-text-on-accent)}input[type=checkbox][juiceCheckbox]:focus-visible{outline:2px solid var(--juice-color-focus-ring);outline-offset:2px}input[type=checkbox][juiceCheckbox]:disabled{border-color:transparent;background:var(--juice-color-disabled-bg);cursor:not-allowed}\n"] }]
676
+ }] });
677
+ /** Styled native checkbox. `indeterminate` sets the DOM property (it has no attribute). Label it with a `<label>` or `aria-label`. */
678
+ class JuiceCheckbox {
679
+ constructor() {
680
+ this.indeterminate = input(false, { ...(ngDevMode ? { debugName: "indeterminate" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
681
+ loadStyles(JuiceCheckboxStyles);
682
+ const el = inject(ElementRef).nativeElement;
683
+ effect(() => {
684
+ el.indeterminate = this.indeterminate();
685
+ });
686
+ }
687
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
688
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: JuiceCheckbox, isStandalone: true, selector: "input[type=checkbox][juiceCheckbox]", inputs: { indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
689
+ }
690
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceCheckbox, decorators: [{
691
+ type: Directive,
692
+ args: [{ selector: 'input[type=checkbox][juiceCheckbox]' }]
693
+ }], ctorParameters: () => [], propDecorators: { indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }] } });
694
+
695
+ const STYLES = `
696
+ juice-badge {
697
+ display: inline-flex;
698
+ align-items: center;
699
+ padding: 0 var(--juice-space-2);
700
+ border-radius: var(--juice-radius-full);
701
+ background: var(--juice-color-surface-sunken);
702
+ color: var(--juice-color-text);
703
+ font-family: var(--juice-font-sans);
704
+ font-size: var(--juice-text-xs);
705
+ font-weight: var(--juice-weight-medium);
706
+ line-height: 1.5rem;
707
+ white-space: nowrap;
708
+ }
709
+ juice-badge[data-tone='accent'] { background: var(--juice-color-accent-subtle); color: var(--juice-color-text); }
710
+ juice-badge[data-tone='ok'] { background: var(--juice-color-ok-subtle); color: var(--juice-color-text); }
711
+ juice-badge[data-tone='warn'] { background: var(--juice-color-warn-subtle); color: var(--juice-color-text); }
712
+ juice-badge[data-tone='bad'] { background: var(--juice-color-bad-subtle); color: var(--juice-color-text); }
713
+ juice-badge[data-tone='info'] { background: var(--juice-color-info-subtle); color: var(--juice-color-text); }
714
+
715
+ juice-progress { display: block; height: 0.5rem; overflow: hidden; border-radius: var(--juice-radius-full); background: var(--juice-color-surface-sunken); }
716
+ .juice-progress__bar { height: 100%; border-radius: inherit; background: var(--juice-color-accent); transition: width var(--juice-duration-normal) var(--juice-ease-standard); }
717
+ juice-progress[data-indeterminate] .juice-progress__bar { width: 40%; animation: juice-progress-slide 1.2s var(--juice-ease-standard) infinite; }
718
+ @keyframes juice-progress-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
719
+
720
+ juice-spinner { display: inline-flex; flex: none; align-items: center; justify-content: center; }
721
+ .juice-spinner__ring {
722
+ box-sizing: border-box;
723
+ width: 1.5rem;
724
+ height: 1.5rem;
725
+ border: 2px solid var(--juice-color-border-strong);
726
+ border-top-color: var(--juice-color-accent);
727
+ border-radius: var(--juice-radius-full);
728
+ animation: juice-spinner-spin 800ms linear infinite;
729
+ }
730
+ juice-spinner[data-size='sm'] .juice-spinner__ring { width: 1rem; height: 1rem; }
731
+ juice-spinner[data-size='lg'] .juice-spinner__ring { width: 2.5rem; height: 2.5rem; border-width: 3px; }
732
+ @media (prefers-reduced-motion: reduce) {
733
+ .juice-spinner__ring { animation-duration: 3s; }
734
+ juice-progress[data-indeterminate] .juice-progress__bar { animation-duration: 4s; }
735
+ }
736
+ @keyframes juice-spinner-spin { to { transform: rotate(360deg); } }
737
+ .juice-visually-hidden {
738
+ position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
739
+ clip-path: inset(50%); white-space: nowrap; border: 0;
740
+ }
741
+
742
+ .juice-state {
743
+ display: flex;
744
+ flex-direction: column;
745
+ align-items: center;
746
+ gap: var(--juice-space-3);
747
+ padding: var(--juice-space-8);
748
+ color: var(--juice-color-text);
749
+ font-family: var(--juice-font-sans);
750
+ text-align: center;
751
+ }
752
+ .juice-state__icon { color: var(--juice-color-text-muted); }
753
+ .juice-state__title { margin: 0; font-size: var(--juice-text-lg); font-weight: var(--juice-weight-semibold); }
754
+ .juice-state__text { margin: 0; max-width: 40ch; color: var(--juice-color-text-muted); font-size: var(--juice-text-sm); }
755
+ .juice-state--error .juice-state__title { color: var(--juice-color-bad); }
756
+ `;
757
+ const COMMON = { changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: STYLES };
758
+ /** Small status pill. The tone is conveyed by the text, so do not rely on colour alone. */
759
+ class JuiceBadge {
760
+ constructor() {
761
+ this.tone = input('neutral', /* @ts-ignore */
762
+ ...(ngDevMode ? [{ debugName: "tone" }] : /* istanbul ignore next */ []));
763
+ }
764
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceBadge, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
765
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: JuiceBadge, isStandalone: true, selector: "juice-badge", inputs: { tone: { classPropertyName: "tone", publicName: "tone", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-tone": "tone()" } }, ngImport: i0, template: '<ng-content />', isInline: true }); }
766
+ }
767
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceBadge, decorators: [{
768
+ type: Component,
769
+ args: [{
770
+ selector: 'juice-badge',
771
+ template: '<ng-content />',
772
+ ...COMMON,
773
+ host: { '[attr.data-tone]': 'tone()' },
774
+ }]
775
+ }], propDecorators: { tone: [{ type: i0.Input, args: [{ isSignal: true, alias: "tone", required: false }] }] } });
776
+ /** Progress bar. With a `value` (0..max) it reports `aria-valuenow`; without one it is indeterminate. */
777
+ class JuiceProgress {
778
+ constructor() {
779
+ this.value = input(null, { ...(ngDevMode ? { debugName: "value" } : /* istanbul ignore next */ {}), transform: (v) => (v === null || v === undefined || v === '' || Number.isNaN(Number(v)) ? null : Number(v)) });
780
+ this.max = input(100, { ...(ngDevMode ? { debugName: "max" } : /* istanbul ignore next */ {}), transform: numberAttribute });
781
+ this.label = input('Progress', /* @ts-ignore */
782
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
783
+ this.clamped = computed(() => {
784
+ const v = this.value();
785
+ return v == null ? null : Math.min(Math.max(v, 0), this.max());
786
+ }, /* @ts-ignore */
787
+ ...(ngDevMode ? [{ debugName: "clamped" }] : /* istanbul ignore next */ []));
788
+ this.percent = computed(() => {
789
+ const v = this.clamped();
790
+ return v == null || this.max() <= 0 ? null : (v / this.max()) * 100;
791
+ }, /* @ts-ignore */
792
+ ...(ngDevMode ? [{ debugName: "percent" }] : /* istanbul ignore next */ []));
793
+ }
794
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceProgress, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
795
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: JuiceProgress, isStandalone: true, selector: "juice-progress", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "progressbar", "aria-valuemin": "0" }, properties: { "attr.aria-valuemax": "max()", "attr.aria-valuenow": "clamped()", "attr.aria-label": "label()", "attr.data-indeterminate": "clamped() === null ? \"\" : null" } }, ngImport: i0, template: `<div class="juice-progress__bar" [style.width.%]="percent()"></div>`, isInline: true }); }
796
+ }
797
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceProgress, decorators: [{
798
+ type: Component,
799
+ args: [{
800
+ selector: 'juice-progress',
801
+ template: `<div class="juice-progress__bar" [style.width.%]="percent()"></div>`,
802
+ ...COMMON,
803
+ host: {
804
+ role: 'progressbar',
805
+ 'aria-valuemin': '0',
806
+ '[attr.aria-valuemax]': 'max()',
807
+ '[attr.aria-valuenow]': 'clamped()',
808
+ '[attr.aria-label]': 'label()',
809
+ '[attr.data-indeterminate]': 'clamped() === null ? "" : null',
810
+ },
811
+ }]
812
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
813
+ /** Indeterminate activity indicator. The label is read by assistive tech through `role=status`. */
814
+ class JuiceSpinner {
815
+ constructor() {
816
+ this.size = input('md', /* @ts-ignore */
817
+ ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
818
+ this.label = input('Loading', /* @ts-ignore */
819
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
820
+ }
821
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceSpinner, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
822
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: JuiceSpinner, isStandalone: true, selector: "juice-spinner", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "status" }, properties: { "attr.data-size": "size()" } }, ngImport: i0, template: `<span class="juice-spinner__ring" aria-hidden="true"></span><span class="juice-visually-hidden">{{ label() }}</span>`, isInline: true }); }
823
+ }
824
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceSpinner, decorators: [{
825
+ type: Component,
826
+ args: [{
827
+ selector: 'juice-spinner',
828
+ template: `<span class="juice-spinner__ring" aria-hidden="true"></span><span class="juice-visually-hidden">{{ label() }}</span>`,
829
+ ...COMMON,
830
+ host: { role: 'status', '[attr.data-size]': 'size()' },
831
+ }]
832
+ }], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
833
+ /** Nothing-here state with an optional icon, description and a projected action. */
834
+ class JuiceEmptyState {
835
+ constructor() {
836
+ this.icon = input('', /* @ts-ignore */
837
+ ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
838
+ this.title = input.required(/* @ts-ignore */
839
+ ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
840
+ this.description = input('', /* @ts-ignore */
841
+ ...(ngDevMode ? [{ debugName: "description" }] : /* istanbul ignore next */ []));
842
+ }
843
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceEmptyState, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
844
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: JuiceEmptyState, isStandalone: true, selector: "juice-empty-state", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: true, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "juice-state" }, ngImport: i0, template: `
845
+ @if (icon()) {
846
+ <juice-icon class="juice-state__icon" [name]="icon()" [size]="32" />
847
+ }
848
+ <p class="juice-state__title">{{ title() }}</p>
849
+ @if (description()) {
850
+ <p class="juice-state__text">{{ description() }}</p>
851
+ }
852
+ <ng-content />
853
+ `, isInline: true, dependencies: [{ kind: "component", type: JuiceIcon, selector: "juice-icon", inputs: ["name", "size", "label"] }] }); }
854
+ }
855
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceEmptyState, decorators: [{
856
+ type: Component,
857
+ args: [{
858
+ selector: 'juice-empty-state',
859
+ imports: [JuiceIcon],
860
+ template: `
861
+ @if (icon()) {
862
+ <juice-icon class="juice-state__icon" [name]="icon()" [size]="32" />
863
+ }
864
+ <p class="juice-state__title">{{ title() }}</p>
865
+ @if (description()) {
866
+ <p class="juice-state__text">{{ description() }}</p>
867
+ }
868
+ <ng-content />
869
+ `,
870
+ ...COMMON,
871
+ host: { class: 'juice-state' },
872
+ }]
873
+ }], propDecorators: { icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: true }] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }] } });
874
+ /** Loading placeholder for a region: spinner plus visible label. */
875
+ class JuiceLoadingState {
876
+ constructor() {
877
+ this.label = input('Loading', /* @ts-ignore */
878
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
879
+ }
880
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceLoadingState, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
881
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: JuiceLoadingState, isStandalone: true, selector: "juice-loading-state", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "juice-state" }, ngImport: i0, template: `<juice-spinner [label]="label()" /><p class="juice-state__text" aria-hidden="true">{{ label() }}</p>`, isInline: true, dependencies: [{ kind: "component", type: JuiceSpinner, selector: "juice-spinner", inputs: ["size", "label"] }] }); }
882
+ }
883
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceLoadingState, decorators: [{
884
+ type: Component,
885
+ args: [{
886
+ selector: 'juice-loading-state',
887
+ imports: [JuiceSpinner],
888
+ template: `<juice-spinner [label]="label()" /><p class="juice-state__text" aria-hidden="true">{{ label() }}</p>`,
889
+ ...COMMON,
890
+ host: { class: 'juice-state' },
891
+ }]
892
+ }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
893
+ /** Failure state with a retry action. `error` may be an `Error`, a string or anything else (shown generically). */
894
+ class JuiceErrorState {
895
+ constructor() {
896
+ this.title = input('Something went wrong', /* @ts-ignore */
897
+ ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
898
+ this.error = input(null, /* @ts-ignore */
899
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
900
+ this.retryLabel = input('Try again', /* @ts-ignore */
901
+ ...(ngDevMode ? [{ debugName: "retryLabel" }] : /* istanbul ignore next */ []));
902
+ this.retry = output();
903
+ this.message = computed(() => {
904
+ const e = this.error();
905
+ if (typeof e === 'string')
906
+ return e;
907
+ if (e instanceof Error)
908
+ return e.message;
909
+ return '';
910
+ }, /* @ts-ignore */
911
+ ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
912
+ }
913
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceErrorState, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
914
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: JuiceErrorState, isStandalone: true, selector: "juice-error-state", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, retryLabel: { classPropertyName: "retryLabel", publicName: "retryLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { retry: "retry" }, host: { attributes: { "role": "alert" }, classAttribute: "juice-state juice-state--error" }, ngImport: i0, template: `
915
+ <p class="juice-state__title">{{ title() }}</p>
916
+ @if (message()) {
917
+ <p class="juice-state__text">{{ message() }}</p>
918
+ }
919
+ <button juiceButton variant="secondary" (click)="retry.emit()">{{ retryLabel() }}</button>
920
+ `, isInline: true, dependencies: [{ kind: "component", type: JuiceButton, selector: "button[juiceButton], a[juiceButton]", inputs: ["variant", "size", "loading"] }] }); }
921
+ }
922
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceErrorState, decorators: [{
923
+ type: Component,
924
+ args: [{
925
+ selector: 'juice-error-state',
926
+ imports: [JuiceButton],
927
+ template: `
928
+ <p class="juice-state__title">{{ title() }}</p>
929
+ @if (message()) {
930
+ <p class="juice-state__text">{{ message() }}</p>
931
+ }
932
+ <button juiceButton variant="secondary" (click)="retry.emit()">{{ retryLabel() }}</button>
933
+ `,
934
+ ...COMMON,
935
+ host: { class: 'juice-state juice-state--error', role: 'alert' },
936
+ }]
937
+ }], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], retryLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "retryLabel", required: false }] }], retry: [{ type: i0.Output, args: ["retry"] }] } });
938
+
939
+ /**
940
+ * Generated bundle index. Do not edit.
941
+ */
942
+
943
+ export { JuiceBadge, JuiceButton, JuiceCheckbox, JuiceEmptyState, JuiceErrorState, JuiceField, JuiceIconButton, JuiceInput, JuiceLoadingState, JuiceOption, JuiceProgress, JuiceSelect, JuiceSpinner };
944
+ //# sourceMappingURL=juice-js-ui.mjs.map