@juice-js/ui 3.0.0-alpha.1 → 3.0.0-alpha.3
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/fesm2022/juice-js-ui.mjs +420 -130
- package/fesm2022/juice-js-ui.mjs.map +1 -1
- package/package.json +6 -5
- package/types/juice-js-ui.d.ts +36 -7
package/fesm2022/juice-js-ui.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, booleanAttribute, inject, ElementRef, DestroyRef, ViewEncapsulation, ChangeDetectionStrategy, Component, isDevMode, afterNextRender, ApplicationRef, EnvironmentInjector, createComponent,
|
|
2
|
+
import { input, booleanAttribute, inject, ElementRef, DestroyRef, ViewEncapsulation, ChangeDetectionStrategy, Component, isDevMode, afterNextRender, ApplicationRef, EnvironmentInjector, createComponent, signal, computed, Directive, InjectionToken, model, contentChildren, viewChild, Injector, forwardRef, effect, numberAttribute, output } from '@angular/core';
|
|
3
3
|
import { NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
4
|
import { ActiveDescendantKeyManager } from '@angular/cdk/a11y';
|
|
5
5
|
import { Overlay, CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
|
|
@@ -39,23 +39,36 @@ const BUTTON_STYLES = `
|
|
|
39
39
|
padding: 0;
|
|
40
40
|
}
|
|
41
41
|
[juiceButton]:focus-visible, [juiceIconButton]:focus-visible {
|
|
42
|
-
outline: 2px solid var(--juice-
|
|
42
|
+
outline: 2px solid var(--juice-button-focus-ring);
|
|
43
43
|
outline-offset: 2px;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[juiceButton][data-variant='
|
|
49
|
-
[juiceButton][data-variant='
|
|
50
|
-
[juiceButton][data-variant='
|
|
51
|
-
[juiceButton][data-variant='
|
|
52
|
-
|
|
45
|
+
/* Interaction (README, Interaction tokens): filled variants lighten slightly on hover and deepen on press in dark, and
|
|
46
|
+
deepen on both in light; outlined and ghost variants step the surface. Hover and press never apply to a disabled
|
|
47
|
+
button: :where() keeps that guard at zero specificity, so the disabled rule below still wins on its own. */
|
|
48
|
+
[juiceButton][data-variant='primary'] { background: var(--juice-button-bg); color: var(--juice-button-fg); }
|
|
49
|
+
[juiceButton][data-variant='primary']:where(:not(:disabled, [aria-disabled='true'])):hover { background: var(--juice-button-hover-bg); }
|
|
50
|
+
[juiceButton][data-variant='primary']:where(:not(:disabled, [aria-disabled='true'])):active { background: var(--juice-button-active-bg); }
|
|
51
|
+
[juiceButton][data-variant='secondary'] {
|
|
52
|
+
background: var(--juice-button-secondary-bg);
|
|
53
|
+
border-color: var(--juice-button-secondary-border);
|
|
54
|
+
color: var(--juice-button-secondary-fg);
|
|
55
|
+
}
|
|
56
|
+
[juiceButton][data-variant='secondary']:where(:not(:disabled, [aria-disabled='true'])):hover {
|
|
57
|
+
background: var(--juice-button-secondary-hover-bg);
|
|
58
|
+
border-color: var(--juice-button-secondary-hover-border);
|
|
59
|
+
}
|
|
60
|
+
[juiceButton][data-variant='secondary']:where(:not(:disabled, [aria-disabled='true'])):active { background: var(--juice-button-secondary-active-bg); }
|
|
61
|
+
[juiceButton][data-variant='ghost'], [juiceIconButton] { color: var(--juice-button-ghost-fg); }
|
|
62
|
+
:is([juiceButton][data-variant='ghost'], [juiceIconButton]):where(:not(:disabled, [aria-disabled='true'])):hover { background: var(--juice-button-ghost-hover-bg); }
|
|
63
|
+
:is([juiceButton][data-variant='ghost'], [juiceIconButton]):where(:not(:disabled, [aria-disabled='true'])):active { background: var(--juice-button-ghost-active-bg); }
|
|
64
|
+
[juiceButton][data-variant='danger'] { background: var(--juice-button-danger-bg); color: var(--juice-button-danger-fg); }
|
|
65
|
+
[juiceButton][data-variant='danger']:where(:not(:disabled, [aria-disabled='true'])):hover { background: var(--juice-button-danger-hover-bg); }
|
|
66
|
+
[juiceButton][data-variant='danger']:where(:not(:disabled, [aria-disabled='true'])):active { background: var(--juice-button-danger-active-bg); }
|
|
53
67
|
[juiceButton]:disabled, [juiceIconButton]:disabled, [juiceButton][aria-disabled='true'] {
|
|
54
|
-
background: var(--juice-
|
|
68
|
+
background: var(--juice-button-disabled-bg);
|
|
55
69
|
border-color: transparent;
|
|
56
|
-
color: var(--juice-
|
|
70
|
+
color: var(--juice-button-disabled-fg);
|
|
57
71
|
cursor: not-allowed;
|
|
58
|
-
filter: none;
|
|
59
72
|
}
|
|
60
73
|
[juiceButton][data-loading] { cursor: progress; }
|
|
61
74
|
.juice-button__spinner {
|
|
@@ -95,7 +108,7 @@ class JuiceButton {
|
|
|
95
108
|
inject(DestroyRef).onDestroy(() => el.removeEventListener('click', block, true));
|
|
96
109
|
}
|
|
97
110
|
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-
|
|
111
|
+
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-button-focus-ring);outline-offset:2px}[juiceButton][data-variant=primary]{background:var(--juice-button-bg);color:var(--juice-button-fg)}[juiceButton][data-variant=primary]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-hover-bg)}[juiceButton][data-variant=primary]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-active-bg)}[juiceButton][data-variant=secondary]{background:var(--juice-button-secondary-bg);border-color:var(--juice-button-secondary-border);color:var(--juice-button-secondary-fg)}[juiceButton][data-variant=secondary]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-secondary-hover-bg);border-color:var(--juice-button-secondary-hover-border)}[juiceButton][data-variant=secondary]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-secondary-active-bg)}[juiceButton][data-variant=ghost],[juiceIconButton]{color:var(--juice-button-ghost-fg)}:is([juiceButton][data-variant=ghost],[juiceIconButton]):where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-ghost-hover-bg)}:is([juiceButton][data-variant=ghost],[juiceIconButton]):where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-ghost-active-bg)}[juiceButton][data-variant=danger]{background:var(--juice-button-danger-bg);color:var(--juice-button-danger-fg)}[juiceButton][data-variant=danger]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-danger-hover-bg)}[juiceButton][data-variant=danger]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-danger-active-bg)}[juiceButton]:disabled,[juiceIconButton]:disabled,[juiceButton][aria-disabled=true]{background:var(--juice-button-disabled-bg);border-color:transparent;color:var(--juice-button-disabled-fg);cursor:not-allowed}[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
112
|
}
|
|
100
113
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceButton, decorators: [{
|
|
101
114
|
type: Component,
|
|
@@ -104,7 +117,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
104
117
|
'[attr.data-size]': 'size()',
|
|
105
118
|
'[attr.data-loading]': 'loading() ? "" : null',
|
|
106
119
|
'[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-
|
|
120
|
+
}, 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-button-focus-ring);outline-offset:2px}[juiceButton][data-variant=primary]{background:var(--juice-button-bg);color:var(--juice-button-fg)}[juiceButton][data-variant=primary]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-hover-bg)}[juiceButton][data-variant=primary]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-active-bg)}[juiceButton][data-variant=secondary]{background:var(--juice-button-secondary-bg);border-color:var(--juice-button-secondary-border);color:var(--juice-button-secondary-fg)}[juiceButton][data-variant=secondary]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-secondary-hover-bg);border-color:var(--juice-button-secondary-hover-border)}[juiceButton][data-variant=secondary]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-secondary-active-bg)}[juiceButton][data-variant=ghost],[juiceIconButton]{color:var(--juice-button-ghost-fg)}:is([juiceButton][data-variant=ghost],[juiceIconButton]):where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-ghost-hover-bg)}:is([juiceButton][data-variant=ghost],[juiceIconButton]):where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-ghost-active-bg)}[juiceButton][data-variant=danger]{background:var(--juice-button-danger-bg);color:var(--juice-button-danger-fg)}[juiceButton][data-variant=danger]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-danger-hover-bg)}[juiceButton][data-variant=danger]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-danger-active-bg)}[juiceButton]:disabled,[juiceIconButton]:disabled,[juiceButton][aria-disabled=true]{background:var(--juice-button-disabled-bg);border-color:transparent;color:var(--juice-button-disabled-fg);cursor:not-allowed}[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
121
|
}], 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
122
|
/** Square icon-only button. It has no visible text, so an `aria-label` (or `aria-labelledby`) is required. */
|
|
110
123
|
class JuiceIconButton {
|
|
@@ -121,11 +134,11 @@ class JuiceIconButton {
|
|
|
121
134
|
}
|
|
122
135
|
}
|
|
123
136
|
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-
|
|
137
|
+
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-button-focus-ring);outline-offset:2px}[juiceButton][data-variant=primary]{background:var(--juice-button-bg);color:var(--juice-button-fg)}[juiceButton][data-variant=primary]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-hover-bg)}[juiceButton][data-variant=primary]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-active-bg)}[juiceButton][data-variant=secondary]{background:var(--juice-button-secondary-bg);border-color:var(--juice-button-secondary-border);color:var(--juice-button-secondary-fg)}[juiceButton][data-variant=secondary]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-secondary-hover-bg);border-color:var(--juice-button-secondary-hover-border)}[juiceButton][data-variant=secondary]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-secondary-active-bg)}[juiceButton][data-variant=ghost],[juiceIconButton]{color:var(--juice-button-ghost-fg)}:is([juiceButton][data-variant=ghost],[juiceIconButton]):where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-ghost-hover-bg)}:is([juiceButton][data-variant=ghost],[juiceIconButton]):where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-ghost-active-bg)}[juiceButton][data-variant=danger]{background:var(--juice-button-danger-bg);color:var(--juice-button-danger-fg)}[juiceButton][data-variant=danger]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-danger-hover-bg)}[juiceButton][data-variant=danger]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-danger-active-bg)}[juiceButton]:disabled,[juiceIconButton]:disabled,[juiceButton][aria-disabled=true]{background:var(--juice-button-disabled-bg);border-color:transparent;color:var(--juice-button-disabled-fg);cursor:not-allowed}[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
138
|
}
|
|
126
139
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceIconButton, decorators: [{
|
|
127
140
|
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-
|
|
141
|
+
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-button-focus-ring);outline-offset:2px}[juiceButton][data-variant=primary]{background:var(--juice-button-bg);color:var(--juice-button-fg)}[juiceButton][data-variant=primary]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-hover-bg)}[juiceButton][data-variant=primary]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-active-bg)}[juiceButton][data-variant=secondary]{background:var(--juice-button-secondary-bg);border-color:var(--juice-button-secondary-border);color:var(--juice-button-secondary-fg)}[juiceButton][data-variant=secondary]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-secondary-hover-bg);border-color:var(--juice-button-secondary-hover-border)}[juiceButton][data-variant=secondary]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-secondary-active-bg)}[juiceButton][data-variant=ghost],[juiceIconButton]{color:var(--juice-button-ghost-fg)}:is([juiceButton][data-variant=ghost],[juiceIconButton]):where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-ghost-hover-bg)}:is([juiceButton][data-variant=ghost],[juiceIconButton]):where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-ghost-active-bg)}[juiceButton][data-variant=danger]{background:var(--juice-button-danger-bg);color:var(--juice-button-danger-fg)}[juiceButton][data-variant=danger]:where(:not(:disabled,[aria-disabled=true])):hover{background:var(--juice-button-danger-hover-bg)}[juiceButton][data-variant=danger]:where(:not(:disabled,[aria-disabled=true])):active{background:var(--juice-button-danger-active-bg)}[juiceButton]:disabled,[juiceIconButton]:disabled,[juiceButton][aria-disabled=true]{background:var(--juice-button-disabled-bg);border-color:transparent;color:var(--juice-button-disabled-fg);cursor:not-allowed}[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
142
|
}], ctorParameters: () => [] });
|
|
130
143
|
|
|
131
144
|
const loaded = new WeakMap();
|
|
@@ -150,41 +163,89 @@ function loadStyles(styleHost) {
|
|
|
150
163
|
createComponent(styleHost, { environmentInjector: env });
|
|
151
164
|
}
|
|
152
165
|
|
|
166
|
+
// One rulebook for every text control (input, textarea, and the select trigger, which reads the same tokens):
|
|
167
|
+
// content 14/20, label 13/20 medium, assistance 12/16; one edge; focus = accent edge + soft halo, never a second outline.
|
|
153
168
|
const FIELD_STYLES = `
|
|
154
|
-
juice-field { display: flex; flex-direction: column;
|
|
155
|
-
.juice-field__label {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
169
|
+
juice-field { display: flex; flex-direction: column; font-family: var(--juice-font-sans); }
|
|
170
|
+
.juice-field__label {
|
|
171
|
+
margin-bottom: var(--juice-field-label-gap);
|
|
172
|
+
color: var(--juice-field-label);
|
|
173
|
+
font-size: var(--juice-field-label-font-size);
|
|
174
|
+
font-weight: var(--juice-field-label-font-weight);
|
|
175
|
+
line-height: 1.25rem;
|
|
176
|
+
}
|
|
177
|
+
.juice-field__message {
|
|
178
|
+
display: flex;
|
|
179
|
+
align-items: flex-start;
|
|
180
|
+
gap: 0.375rem;
|
|
181
|
+
margin-top: var(--juice-field-message-gap);
|
|
182
|
+
color: var(--juice-field-hint);
|
|
183
|
+
font-size: var(--juice-field-message-font-size);
|
|
184
|
+
line-height: var(--juice-field-message-line-height);
|
|
185
|
+
}
|
|
186
|
+
.juice-field__message[data-status='error'] { color: var(--juice-field-error); }
|
|
187
|
+
.juice-field__message[data-status='warning'] { color: var(--juice-field-warning); }
|
|
188
|
+
.juice-field__message[data-status='success'] { color: var(--juice-field-success); }
|
|
189
|
+
.juice-field__icon { flex: none; width: 0.875rem; height: 0.875rem; margin-top: 1px; }
|
|
190
|
+
.juice-field__counter { margin-left: auto; padding-left: var(--juice-space-2); color: var(--juice-field-counter-fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
191
|
+
.juice-field__counter[data-level='near'] { color: var(--juice-field-warning); }
|
|
192
|
+
.juice-field__counter[data-level='limit'] { color: var(--juice-field-error); }
|
|
193
|
+
.juice-field__live { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
|
|
194
|
+
|
|
195
|
+
:is(input, textarea)[juiceInput] {
|
|
159
196
|
box-sizing: border-box;
|
|
160
197
|
width: 100%;
|
|
161
|
-
min-height: var(--juice-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
border
|
|
165
|
-
|
|
166
|
-
|
|
198
|
+
min-height: var(--juice-field-height);
|
|
199
|
+
margin: 0;
|
|
200
|
+
padding: 0 var(--juice-field-padding-x);
|
|
201
|
+
border: 1px solid var(--juice-field-border);
|
|
202
|
+
border-radius: var(--juice-field-radius);
|
|
203
|
+
background: var(--juice-field-bg);
|
|
204
|
+
color: var(--juice-field-fg);
|
|
167
205
|
font-family: var(--juice-font-sans);
|
|
168
|
-
font-size: var(--juice-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
206
|
+
font-size: var(--juice-field-font-size);
|
|
207
|
+
line-height: var(--juice-field-line-height);
|
|
208
|
+
transition:
|
|
209
|
+
border-color var(--juice-field-duration) var(--juice-field-ease),
|
|
210
|
+
box-shadow var(--juice-field-duration) var(--juice-field-ease);
|
|
211
|
+
}
|
|
212
|
+
textarea[juiceInput] {
|
|
213
|
+
display: block;
|
|
214
|
+
min-height: var(--juice-field-textarea-min-height);
|
|
215
|
+
padding-block: var(--juice-field-textarea-padding-y);
|
|
216
|
+
resize: vertical;
|
|
217
|
+
}
|
|
218
|
+
:is(input, textarea)[juiceInput]::placeholder { color: var(--juice-field-placeholder); opacity: 1; }
|
|
219
|
+
:is(input, textarea)[juiceInput]:enabled:not([readonly]):hover { border-color: var(--juice-field-border-hover); }
|
|
220
|
+
:is(input, textarea)[juiceInput]:focus {
|
|
221
|
+
outline: none;
|
|
222
|
+
border-color: var(--juice-field-border-focus);
|
|
223
|
+
box-shadow: 0 0 0 3px var(--juice-field-focus-halo);
|
|
224
|
+
}
|
|
225
|
+
:is(input, textarea)[juiceInput][data-status='error'] { border-color: var(--juice-field-error); }
|
|
226
|
+
:is(input, textarea)[juiceInput][data-status='error']:focus { box-shadow: 0 0 0 3px var(--juice-field-error-halo); }
|
|
227
|
+
:is(input, textarea)[juiceInput][data-status='warning'] { border-color: var(--juice-field-warning); }
|
|
228
|
+
:is(input, textarea)[juiceInput][data-status='warning']:focus { box-shadow: 0 0 0 3px var(--juice-field-warning-halo); }
|
|
229
|
+
:is(input, textarea)[juiceInput][data-status='success'] { border-color: var(--juice-field-success); }
|
|
230
|
+
:is(input, textarea)[juiceInput][data-status='success']:focus { box-shadow: 0 0 0 3px var(--juice-field-success-halo); }
|
|
231
|
+
:is(input, textarea)[juiceInput][readonly] { background: var(--juice-field-readonly-bg); border-color: var(--juice-field-readonly-border); }
|
|
232
|
+
:is(input, textarea)[juiceInput]:disabled {
|
|
233
|
+
background: var(--juice-field-disabled-bg);
|
|
234
|
+
border-color: var(--juice-field-disabled-border);
|
|
235
|
+
color: var(--juice-field-disabled-fg);
|
|
182
236
|
cursor: not-allowed;
|
|
183
237
|
}
|
|
238
|
+
:is(input, textarea)[juiceInput]:disabled::placeholder { color: var(--juice-field-disabled-fg); }
|
|
239
|
+
@media (prefers-reduced-motion: reduce) { :is(input, textarea)[juiceInput] { transition: none; } }
|
|
240
|
+
/* Forced colours drop box-shadow, so focus falls back to a system-coloured outline. */
|
|
241
|
+
@media (forced-colors: active) { :is(input, textarea)[juiceInput]:focus { outline: 2px solid CanvasText; outline-offset: 1px; } }
|
|
184
242
|
`;
|
|
185
243
|
/**
|
|
186
|
-
* Label, hint and
|
|
187
|
-
* label points at, `aria-describedby` for
|
|
244
|
+
* Label, hint, status message and optional character counter for one form control. The projected `[juiceInput]` (or
|
|
245
|
+
* `<juice-select>`) gets the id the label points at, `aria-describedby` for the message and counter, `aria-invalid` for
|
|
246
|
+
* an error, and `data-status` for its edge. A status message (error over warning over success) replaces the hint while it
|
|
247
|
+
* shows. `counter` shows `length / maxlength` for a control with a `maxlength`; screen readers hear only the 90% and limit
|
|
248
|
+
* thresholds, not every keystroke.
|
|
188
249
|
*/
|
|
189
250
|
class JuiceField {
|
|
190
251
|
constructor() {
|
|
@@ -194,52 +255,128 @@ class JuiceField {
|
|
|
194
255
|
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
195
256
|
this.error = input('', /* @ts-ignore */
|
|
196
257
|
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
258
|
+
this.warning = input('', /* @ts-ignore */
|
|
259
|
+
...(ngDevMode ? [{ debugName: "warning" }] : /* istanbul ignore next */ []));
|
|
260
|
+
this.success = input('', /* @ts-ignore */
|
|
261
|
+
...(ngDevMode ? [{ debugName: "success" }] : /* istanbul ignore next */ []));
|
|
262
|
+
this.counter = input(false, { ...(ngDevMode ? { debugName: "counter" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
197
263
|
this.controlId = nextId('juice-field');
|
|
198
|
-
this.
|
|
199
|
-
this.
|
|
264
|
+
this.messageId = `${this.controlId}-message`;
|
|
265
|
+
this.counterId = `${this.controlId}-counter`;
|
|
200
266
|
this.labelId = `${this.controlId}-label`;
|
|
267
|
+
/** @deprecated since 3.0: the hint and the status message share one element; use `messageId`. */
|
|
268
|
+
this.hintId = this.messageId;
|
|
269
|
+
/** @deprecated since 3.0: use `messageId`. */
|
|
270
|
+
this.errorId = this.messageId;
|
|
271
|
+
/** Length and `maxlength` of the projected control, reported by `[juiceInput]`. */
|
|
272
|
+
this.length = signal(0, /* @ts-ignore */
|
|
273
|
+
...(ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []));
|
|
274
|
+
this.max = signal(null, /* @ts-ignore */
|
|
275
|
+
...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
276
|
+
this.status = computed(() => this.error() ? 'error' : this.warning() ? 'warning' : this.success() ? 'success' : null, /* @ts-ignore */
|
|
277
|
+
...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
|
|
278
|
+
this.message = computed(() => {
|
|
279
|
+
const s = this.status();
|
|
280
|
+
return s === 'error' ? this.error() : s === 'warning' ? this.warning() : s === 'success' ? this.success() : this.hint();
|
|
281
|
+
}, /* @ts-ignore */
|
|
282
|
+
...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
|
|
201
283
|
this.invalid = () => !!this.error();
|
|
284
|
+
this.showCounter = computed(() => this.counter() && this.max() !== null, /* @ts-ignore */
|
|
285
|
+
...(ngDevMode ? [{ debugName: "showCounter" }] : /* istanbul ignore next */ []));
|
|
286
|
+
this.level = computed(() => {
|
|
287
|
+
const max = this.max();
|
|
288
|
+
if (!this.counter() || max === null || max <= 0)
|
|
289
|
+
return null;
|
|
290
|
+
const n = this.length();
|
|
291
|
+
return n >= max ? 'limit' : n >= max * 0.9 ? 'near' : null;
|
|
292
|
+
}, /* @ts-ignore */
|
|
293
|
+
...(ngDevMode ? [{ debugName: "level" }] : /* istanbul ignore next */ []));
|
|
294
|
+
this.announcement = computed(() => this.level() === 'limit' ? 'Character limit reached' : this.level() === 'near' ? 'Approaching the character limit' : '', /* @ts-ignore */
|
|
295
|
+
...(ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []));
|
|
202
296
|
this.describedBy = computed(() => {
|
|
203
|
-
const ids = [this.
|
|
297
|
+
const ids = [this.message() ? this.messageId : '', this.showCounter() ? this.counterId : ''].filter(Boolean);
|
|
204
298
|
return ids.length ? ids.join(' ') : null;
|
|
205
299
|
}, /* @ts-ignore */
|
|
206
300
|
...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
|
|
207
301
|
}
|
|
208
302
|
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: `
|
|
303
|
+
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 }, warning: { classPropertyName: "warning", publicName: "warning", isSignal: true, isRequired: false, transformFunction: null }, success: { classPropertyName: "success", publicName: "success", isSignal: true, isRequired: false, transformFunction: null }, counter: { classPropertyName: "counter", publicName: "counter", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
210
304
|
<label class="juice-field__label" [id]="labelId" [attr.for]="controlId">{{ label() }}</label>
|
|
211
305
|
<ng-content />
|
|
212
|
-
@if (
|
|
213
|
-
<div class="juice-
|
|
306
|
+
@if (message() || showCounter()) {
|
|
307
|
+
<div class="juice-field__message" [attr.data-status]="status()">
|
|
308
|
+
@if (message()) {
|
|
309
|
+
@switch (status()) {
|
|
310
|
+
@case ('error') {
|
|
311
|
+
<svg class="juice-field__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="10" /><path d="M12 8v4M12 16h.01" /></svg>
|
|
312
|
+
}
|
|
313
|
+
@case ('warning') {
|
|
314
|
+
<svg class="juice-field__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /><path d="M12 9v4M12 17h.01" /></svg>
|
|
315
|
+
}
|
|
316
|
+
@case ('success') {
|
|
317
|
+
<svg class="juice-field__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="10" /><path d="m9 12 2 2 4-4" /></svg>
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
<span [id]="messageId">{{ message() }}</span>
|
|
321
|
+
}
|
|
322
|
+
@if (showCounter()) {
|
|
323
|
+
<span class="juice-field__counter" [id]="counterId" [attr.data-level]="level()">{{ length() }} / {{ max() }}</span>
|
|
324
|
+
}
|
|
325
|
+
</div>
|
|
214
326
|
}
|
|
215
|
-
@if (
|
|
216
|
-
<
|
|
327
|
+
@if (showCounter()) {
|
|
328
|
+
<span class="juice-field__live" aria-live="polite">{{ announcement() }}</span>
|
|
217
329
|
}
|
|
218
|
-
`, isInline: true, styles: ["juice-field{display:flex;flex-direction:column;gap:var(--juice-
|
|
330
|
+
`, isInline: true, styles: ["juice-field{display:flex;flex-direction:column;font-family:var(--juice-font-sans)}.juice-field__label{margin-bottom:var(--juice-field-label-gap);color:var(--juice-field-label);font-size:var(--juice-field-label-font-size);font-weight:var(--juice-field-label-font-weight);line-height:1.25rem}.juice-field__message{display:flex;align-items:flex-start;gap:.375rem;margin-top:var(--juice-field-message-gap);color:var(--juice-field-hint);font-size:var(--juice-field-message-font-size);line-height:var(--juice-field-message-line-height)}.juice-field__message[data-status=error]{color:var(--juice-field-error)}.juice-field__message[data-status=warning]{color:var(--juice-field-warning)}.juice-field__message[data-status=success]{color:var(--juice-field-success)}.juice-field__icon{flex:none;width:.875rem;height:.875rem;margin-top:1px}.juice-field__counter{margin-left:auto;padding-left:var(--juice-space-2);color:var(--juice-field-counter-fg);font-variant-numeric:tabular-nums;white-space:nowrap}.juice-field__counter[data-level=near]{color:var(--juice-field-warning)}.juice-field__counter[data-level=limit]{color:var(--juice-field-error)}.juice-field__live{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}:is(input,textarea)[juiceInput]{box-sizing:border-box;width:100%;min-height:var(--juice-field-height);margin:0;padding:0 var(--juice-field-padding-x);border:1px solid var(--juice-field-border);border-radius:var(--juice-field-radius);background:var(--juice-field-bg);color:var(--juice-field-fg);font-family:var(--juice-font-sans);font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);transition:border-color var(--juice-field-duration) var(--juice-field-ease),box-shadow var(--juice-field-duration) var(--juice-field-ease)}textarea[juiceInput]{display:block;min-height:var(--juice-field-textarea-min-height);padding-block:var(--juice-field-textarea-padding-y);resize:vertical}:is(input,textarea)[juiceInput]::placeholder{color:var(--juice-field-placeholder);opacity:1}:is(input,textarea)[juiceInput]:enabled:not([readonly]):hover{border-color:var(--juice-field-border-hover)}:is(input,textarea)[juiceInput]:focus{outline:none;border-color:var(--juice-field-border-focus);box-shadow:0 0 0 3px var(--juice-field-focus-halo)}:is(input,textarea)[juiceInput][data-status=error]{border-color:var(--juice-field-error)}:is(input,textarea)[juiceInput][data-status=error]:focus{box-shadow:0 0 0 3px var(--juice-field-error-halo)}:is(input,textarea)[juiceInput][data-status=warning]{border-color:var(--juice-field-warning)}:is(input,textarea)[juiceInput][data-status=warning]:focus{box-shadow:0 0 0 3px var(--juice-field-warning-halo)}:is(input,textarea)[juiceInput][data-status=success]{border-color:var(--juice-field-success)}:is(input,textarea)[juiceInput][data-status=success]:focus{box-shadow:0 0 0 3px var(--juice-field-success-halo)}:is(input,textarea)[juiceInput][readonly]{background:var(--juice-field-readonly-bg);border-color:var(--juice-field-readonly-border)}:is(input,textarea)[juiceInput]:disabled{background:var(--juice-field-disabled-bg);border-color:var(--juice-field-disabled-border);color:var(--juice-field-disabled-fg);cursor:not-allowed}:is(input,textarea)[juiceInput]:disabled::placeholder{color:var(--juice-field-disabled-fg)}@media(prefers-reduced-motion:reduce){:is(input,textarea)[juiceInput]{transition:none}}@media(forced-colors:active){:is(input,textarea)[juiceInput]:focus{outline:2px solid CanvasText;outline-offset:1px}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
219
331
|
}
|
|
220
332
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceField, decorators: [{
|
|
221
333
|
type: Component,
|
|
222
334
|
args: [{ selector: 'juice-field', template: `
|
|
223
335
|
<label class="juice-field__label" [id]="labelId" [attr.for]="controlId">{{ label() }}</label>
|
|
224
336
|
<ng-content />
|
|
225
|
-
@if (
|
|
226
|
-
<div class="juice-
|
|
337
|
+
@if (message() || showCounter()) {
|
|
338
|
+
<div class="juice-field__message" [attr.data-status]="status()">
|
|
339
|
+
@if (message()) {
|
|
340
|
+
@switch (status()) {
|
|
341
|
+
@case ('error') {
|
|
342
|
+
<svg class="juice-field__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="10" /><path d="M12 8v4M12 16h.01" /></svg>
|
|
343
|
+
}
|
|
344
|
+
@case ('warning') {
|
|
345
|
+
<svg class="juice-field__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /><path d="M12 9v4M12 17h.01" /></svg>
|
|
346
|
+
}
|
|
347
|
+
@case ('success') {
|
|
348
|
+
<svg class="juice-field__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="10" /><path d="m9 12 2 2 4-4" /></svg>
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
<span [id]="messageId">{{ message() }}</span>
|
|
352
|
+
}
|
|
353
|
+
@if (showCounter()) {
|
|
354
|
+
<span class="juice-field__counter" [id]="counterId" [attr.data-level]="level()">{{ length() }} / {{ max() }}</span>
|
|
355
|
+
}
|
|
356
|
+
</div>
|
|
227
357
|
}
|
|
228
|
-
@if (
|
|
229
|
-
<
|
|
358
|
+
@if (showCounter()) {
|
|
359
|
+
<span class="juice-field__live" aria-live="polite">{{ announcement() }}</span>
|
|
230
360
|
}
|
|
231
|
-
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: ["juice-field{display:flex;flex-direction:column;gap:var(--juice-
|
|
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. */
|
|
361
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: ["juice-field{display:flex;flex-direction:column;font-family:var(--juice-font-sans)}.juice-field__label{margin-bottom:var(--juice-field-label-gap);color:var(--juice-field-label);font-size:var(--juice-field-label-font-size);font-weight:var(--juice-field-label-font-weight);line-height:1.25rem}.juice-field__message{display:flex;align-items:flex-start;gap:.375rem;margin-top:var(--juice-field-message-gap);color:var(--juice-field-hint);font-size:var(--juice-field-message-font-size);line-height:var(--juice-field-message-line-height)}.juice-field__message[data-status=error]{color:var(--juice-field-error)}.juice-field__message[data-status=warning]{color:var(--juice-field-warning)}.juice-field__message[data-status=success]{color:var(--juice-field-success)}.juice-field__icon{flex:none;width:.875rem;height:.875rem;margin-top:1px}.juice-field__counter{margin-left:auto;padding-left:var(--juice-space-2);color:var(--juice-field-counter-fg);font-variant-numeric:tabular-nums;white-space:nowrap}.juice-field__counter[data-level=near]{color:var(--juice-field-warning)}.juice-field__counter[data-level=limit]{color:var(--juice-field-error)}.juice-field__live{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}:is(input,textarea)[juiceInput]{box-sizing:border-box;width:100%;min-height:var(--juice-field-height);margin:0;padding:0 var(--juice-field-padding-x);border:1px solid var(--juice-field-border);border-radius:var(--juice-field-radius);background:var(--juice-field-bg);color:var(--juice-field-fg);font-family:var(--juice-font-sans);font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);transition:border-color var(--juice-field-duration) var(--juice-field-ease),box-shadow var(--juice-field-duration) var(--juice-field-ease)}textarea[juiceInput]{display:block;min-height:var(--juice-field-textarea-min-height);padding-block:var(--juice-field-textarea-padding-y);resize:vertical}:is(input,textarea)[juiceInput]::placeholder{color:var(--juice-field-placeholder);opacity:1}:is(input,textarea)[juiceInput]:enabled:not([readonly]):hover{border-color:var(--juice-field-border-hover)}:is(input,textarea)[juiceInput]:focus{outline:none;border-color:var(--juice-field-border-focus);box-shadow:0 0 0 3px var(--juice-field-focus-halo)}:is(input,textarea)[juiceInput][data-status=error]{border-color:var(--juice-field-error)}:is(input,textarea)[juiceInput][data-status=error]:focus{box-shadow:0 0 0 3px var(--juice-field-error-halo)}:is(input,textarea)[juiceInput][data-status=warning]{border-color:var(--juice-field-warning)}:is(input,textarea)[juiceInput][data-status=warning]:focus{box-shadow:0 0 0 3px var(--juice-field-warning-halo)}:is(input,textarea)[juiceInput][data-status=success]{border-color:var(--juice-field-success)}:is(input,textarea)[juiceInput][data-status=success]:focus{box-shadow:0 0 0 3px var(--juice-field-success-halo)}:is(input,textarea)[juiceInput][readonly]{background:var(--juice-field-readonly-bg);border-color:var(--juice-field-readonly-border)}:is(input,textarea)[juiceInput]:disabled{background:var(--juice-field-disabled-bg);border-color:var(--juice-field-disabled-border);color:var(--juice-field-disabled-fg);cursor:not-allowed}:is(input,textarea)[juiceInput]:disabled::placeholder{color:var(--juice-field-disabled-fg)}@media(prefers-reduced-motion:reduce){:is(input,textarea)[juiceInput]{transition:none}}@media(forced-colors:active){:is(input,textarea)[juiceInput]:focus{outline:2px solid CanvasText;outline-offset:1px}}\n"] }]
|
|
362
|
+
}], 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 }] }], warning: [{ type: i0.Input, args: [{ isSignal: true, alias: "warning", required: false }] }], success: [{ type: i0.Input, args: [{ isSignal: true, alias: "success", required: false }] }], counter: [{ type: i0.Input, args: [{ isSignal: true, alias: "counter", required: false }] }] } });
|
|
363
|
+
/** Styles for the text input and textarea, wired to a surrounding `<juice-field>` when there is one. */
|
|
234
364
|
class JuiceInput {
|
|
235
365
|
constructor() {
|
|
236
366
|
this.field = inject(JuiceField, { optional: true });
|
|
237
367
|
this.control = inject(NgControl, { optional: true, self: true });
|
|
368
|
+
this.el = inject(ElementRef).nativeElement;
|
|
238
369
|
this.state = signal(false, /* @ts-ignore */
|
|
239
370
|
...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
240
371
|
/** Invalid is shown only once the user has touched the control (or the field was given an error without a form control). */
|
|
241
372
|
this.invalid = computed(() => this.state() || (!this.control && !!this.field?.error()), /* @ts-ignore */
|
|
242
373
|
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
374
|
+
/** The field's status edge; an error edge waits for `invalid`, like `aria-invalid`. */
|
|
375
|
+
this.status = computed(() => {
|
|
376
|
+
const s = this.field?.status() ?? null;
|
|
377
|
+
return s === 'error' && !this.invalid() && !!this.control ? null : s;
|
|
378
|
+
}, /* @ts-ignore */
|
|
379
|
+
...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
|
|
243
380
|
loadStyles(JuiceFieldStyles);
|
|
244
381
|
}
|
|
245
382
|
ngDoCheck() {
|
|
@@ -248,9 +385,14 @@ class JuiceInput {
|
|
|
248
385
|
sync() {
|
|
249
386
|
const c = this.control;
|
|
250
387
|
this.state.set(!!c && !!c.invalid && !!c.touched);
|
|
388
|
+
const f = this.field;
|
|
389
|
+
if (f) {
|
|
390
|
+
f.length.set(this.el.value.length);
|
|
391
|
+
f.max.set(this.el.maxLength > 0 ? this.el.maxLength : null);
|
|
392
|
+
}
|
|
251
393
|
}
|
|
252
394
|
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 }); }
|
|
395
|
+
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", "attr.data-status": "status()" } }, ngImport: i0 }); }
|
|
254
396
|
}
|
|
255
397
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceInput, decorators: [{
|
|
256
398
|
type: Directive,
|
|
@@ -260,6 +402,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
260
402
|
'[attr.id]': 'field?.controlId ?? null',
|
|
261
403
|
'[attr.aria-describedby]': 'field?.describedBy() ?? null',
|
|
262
404
|
'[attr.aria-invalid]': 'invalid() ? "true" : null',
|
|
405
|
+
'[attr.data-status]': 'status()',
|
|
263
406
|
'(blur)': 'sync()',
|
|
264
407
|
'(input)': 'sync()',
|
|
265
408
|
},
|
|
@@ -267,14 +410,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
267
410
|
}], ctorParameters: () => [] });
|
|
268
411
|
class JuiceFieldStyles {
|
|
269
412
|
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-
|
|
413
|
+
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;font-family:var(--juice-font-sans)}.juice-field__label{margin-bottom:var(--juice-field-label-gap);color:var(--juice-field-label);font-size:var(--juice-field-label-font-size);font-weight:var(--juice-field-label-font-weight);line-height:1.25rem}.juice-field__message{display:flex;align-items:flex-start;gap:.375rem;margin-top:var(--juice-field-message-gap);color:var(--juice-field-hint);font-size:var(--juice-field-message-font-size);line-height:var(--juice-field-message-line-height)}.juice-field__message[data-status=error]{color:var(--juice-field-error)}.juice-field__message[data-status=warning]{color:var(--juice-field-warning)}.juice-field__message[data-status=success]{color:var(--juice-field-success)}.juice-field__icon{flex:none;width:.875rem;height:.875rem;margin-top:1px}.juice-field__counter{margin-left:auto;padding-left:var(--juice-space-2);color:var(--juice-field-counter-fg);font-variant-numeric:tabular-nums;white-space:nowrap}.juice-field__counter[data-level=near]{color:var(--juice-field-warning)}.juice-field__counter[data-level=limit]{color:var(--juice-field-error)}.juice-field__live{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}:is(input,textarea)[juiceInput]{box-sizing:border-box;width:100%;min-height:var(--juice-field-height);margin:0;padding:0 var(--juice-field-padding-x);border:1px solid var(--juice-field-border);border-radius:var(--juice-field-radius);background:var(--juice-field-bg);color:var(--juice-field-fg);font-family:var(--juice-font-sans);font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);transition:border-color var(--juice-field-duration) var(--juice-field-ease),box-shadow var(--juice-field-duration) var(--juice-field-ease)}textarea[juiceInput]{display:block;min-height:var(--juice-field-textarea-min-height);padding-block:var(--juice-field-textarea-padding-y);resize:vertical}:is(input,textarea)[juiceInput]::placeholder{color:var(--juice-field-placeholder);opacity:1}:is(input,textarea)[juiceInput]:enabled:not([readonly]):hover{border-color:var(--juice-field-border-hover)}:is(input,textarea)[juiceInput]:focus{outline:none;border-color:var(--juice-field-border-focus);box-shadow:0 0 0 3px var(--juice-field-focus-halo)}:is(input,textarea)[juiceInput][data-status=error]{border-color:var(--juice-field-error)}:is(input,textarea)[juiceInput][data-status=error]:focus{box-shadow:0 0 0 3px var(--juice-field-error-halo)}:is(input,textarea)[juiceInput][data-status=warning]{border-color:var(--juice-field-warning)}:is(input,textarea)[juiceInput][data-status=warning]:focus{box-shadow:0 0 0 3px var(--juice-field-warning-halo)}:is(input,textarea)[juiceInput][data-status=success]{border-color:var(--juice-field-success)}:is(input,textarea)[juiceInput][data-status=success]:focus{box-shadow:0 0 0 3px var(--juice-field-success-halo)}:is(input,textarea)[juiceInput][readonly]{background:var(--juice-field-readonly-bg);border-color:var(--juice-field-readonly-border)}:is(input,textarea)[juiceInput]:disabled{background:var(--juice-field-disabled-bg);border-color:var(--juice-field-disabled-border);color:var(--juice-field-disabled-fg);cursor:not-allowed}:is(input,textarea)[juiceInput]:disabled::placeholder{color:var(--juice-field-disabled-fg)}@media(prefers-reduced-motion:reduce){:is(input,textarea)[juiceInput]{transition:none}}@media(forced-colors:active){:is(input,textarea)[juiceInput]:focus{outline:2px solid CanvasText;outline-offset:1px}}\n"], encapsulation: i0.ViewEncapsulation.None }); }
|
|
271
414
|
}
|
|
272
415
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceFieldStyles, decorators: [{
|
|
273
416
|
type: Component,
|
|
274
|
-
args: [{ selector: 'juice-field-styles', template: '', encapsulation: ViewEncapsulation.None, styles: ["juice-field{display:flex;flex-direction:column;gap:var(--juice-
|
|
417
|
+
args: [{ selector: 'juice-field-styles', template: '', encapsulation: ViewEncapsulation.None, styles: ["juice-field{display:flex;flex-direction:column;font-family:var(--juice-font-sans)}.juice-field__label{margin-bottom:var(--juice-field-label-gap);color:var(--juice-field-label);font-size:var(--juice-field-label-font-size);font-weight:var(--juice-field-label-font-weight);line-height:1.25rem}.juice-field__message{display:flex;align-items:flex-start;gap:.375rem;margin-top:var(--juice-field-message-gap);color:var(--juice-field-hint);font-size:var(--juice-field-message-font-size);line-height:var(--juice-field-message-line-height)}.juice-field__message[data-status=error]{color:var(--juice-field-error)}.juice-field__message[data-status=warning]{color:var(--juice-field-warning)}.juice-field__message[data-status=success]{color:var(--juice-field-success)}.juice-field__icon{flex:none;width:.875rem;height:.875rem;margin-top:1px}.juice-field__counter{margin-left:auto;padding-left:var(--juice-space-2);color:var(--juice-field-counter-fg);font-variant-numeric:tabular-nums;white-space:nowrap}.juice-field__counter[data-level=near]{color:var(--juice-field-warning)}.juice-field__counter[data-level=limit]{color:var(--juice-field-error)}.juice-field__live{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}:is(input,textarea)[juiceInput]{box-sizing:border-box;width:100%;min-height:var(--juice-field-height);margin:0;padding:0 var(--juice-field-padding-x);border:1px solid var(--juice-field-border);border-radius:var(--juice-field-radius);background:var(--juice-field-bg);color:var(--juice-field-fg);font-family:var(--juice-font-sans);font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);transition:border-color var(--juice-field-duration) var(--juice-field-ease),box-shadow var(--juice-field-duration) var(--juice-field-ease)}textarea[juiceInput]{display:block;min-height:var(--juice-field-textarea-min-height);padding-block:var(--juice-field-textarea-padding-y);resize:vertical}:is(input,textarea)[juiceInput]::placeholder{color:var(--juice-field-placeholder);opacity:1}:is(input,textarea)[juiceInput]:enabled:not([readonly]):hover{border-color:var(--juice-field-border-hover)}:is(input,textarea)[juiceInput]:focus{outline:none;border-color:var(--juice-field-border-focus);box-shadow:0 0 0 3px var(--juice-field-focus-halo)}:is(input,textarea)[juiceInput][data-status=error]{border-color:var(--juice-field-error)}:is(input,textarea)[juiceInput][data-status=error]:focus{box-shadow:0 0 0 3px var(--juice-field-error-halo)}:is(input,textarea)[juiceInput][data-status=warning]{border-color:var(--juice-field-warning)}:is(input,textarea)[juiceInput][data-status=warning]:focus{box-shadow:0 0 0 3px var(--juice-field-warning-halo)}:is(input,textarea)[juiceInput][data-status=success]{border-color:var(--juice-field-success)}:is(input,textarea)[juiceInput][data-status=success]:focus{box-shadow:0 0 0 3px var(--juice-field-success-halo)}:is(input,textarea)[juiceInput][readonly]{background:var(--juice-field-readonly-bg);border-color:var(--juice-field-readonly-border)}:is(input,textarea)[juiceInput]:disabled{background:var(--juice-field-disabled-bg);border-color:var(--juice-field-disabled-border);color:var(--juice-field-disabled-fg);cursor:not-allowed}:is(input,textarea)[juiceInput]:disabled::placeholder{color:var(--juice-field-disabled-fg)}@media(prefers-reduced-motion:reduce){:is(input,textarea)[juiceInput]{transition:none}}@media(forced-colors:active){:is(input,textarea)[juiceInput]:focus{outline:2px solid CanvasText;outline-offset:1px}}\n"] }]
|
|
275
418
|
}] });
|
|
276
419
|
|
|
277
420
|
const JUICE_SELECT_HOST = new InjectionToken('JUICE_SELECT_HOST');
|
|
421
|
+
// The trigger follows the text-field rulebook exactly (it reads the --juice-field-* tokens); the list reads --juice-listbox-*.
|
|
278
422
|
const SELECT_STYLES = `
|
|
279
423
|
juice-select { display: block; position: relative; font-family: var(--juice-font-sans); }
|
|
280
424
|
.juice-select__trigger {
|
|
@@ -284,47 +428,95 @@ const SELECT_STYLES = `
|
|
|
284
428
|
justify-content: space-between;
|
|
285
429
|
gap: var(--juice-space-2);
|
|
286
430
|
width: 100%;
|
|
287
|
-
min-height: var(--juice-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
border
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
font-
|
|
431
|
+
min-height: var(--juice-field-height);
|
|
432
|
+
margin: 0;
|
|
433
|
+
padding: 0 var(--juice-field-padding-x);
|
|
434
|
+
border: 1px solid var(--juice-field-border);
|
|
435
|
+
border-radius: var(--juice-field-radius);
|
|
436
|
+
background: var(--juice-field-bg);
|
|
437
|
+
color: var(--juice-field-fg);
|
|
438
|
+
font-family: inherit;
|
|
439
|
+
font-size: var(--juice-field-font-size);
|
|
440
|
+
line-height: var(--juice-field-line-height);
|
|
295
441
|
text-align: start;
|
|
296
442
|
cursor: pointer;
|
|
443
|
+
transition:
|
|
444
|
+
border-color var(--juice-field-duration) var(--juice-field-ease),
|
|
445
|
+
box-shadow var(--juice-field-duration) var(--juice-field-ease);
|
|
446
|
+
}
|
|
447
|
+
.juice-select__trigger:enabled:hover { border-color: var(--juice-field-border-hover); }
|
|
448
|
+
.juice-select__trigger:focus-visible,
|
|
449
|
+
.juice-select__trigger[aria-expanded='true'] {
|
|
450
|
+
outline: none;
|
|
451
|
+
border-color: var(--juice-field-border-focus);
|
|
452
|
+
box-shadow: 0 0 0 3px var(--juice-field-focus-halo);
|
|
453
|
+
}
|
|
454
|
+
.juice-select__trigger[data-status='error'] { border-color: var(--juice-field-error); }
|
|
455
|
+
.juice-select__trigger[data-status='error']:is(:focus-visible, [aria-expanded='true']) { box-shadow: 0 0 0 3px var(--juice-field-error-halo); }
|
|
456
|
+
.juice-select__trigger[data-status='warning'] { border-color: var(--juice-field-warning); }
|
|
457
|
+
.juice-select__trigger[data-status='warning']:is(:focus-visible, [aria-expanded='true']) { box-shadow: 0 0 0 3px var(--juice-field-warning-halo); }
|
|
458
|
+
.juice-select__trigger[data-status='success'] { border-color: var(--juice-field-success); }
|
|
459
|
+
.juice-select__trigger[data-status='success']:is(:focus-visible, [aria-expanded='true']) { box-shadow: 0 0 0 3px var(--juice-field-success-halo); }
|
|
460
|
+
.juice-select__trigger:disabled {
|
|
461
|
+
background: var(--juice-field-disabled-bg);
|
|
462
|
+
border-color: var(--juice-field-disabled-border);
|
|
463
|
+
color: var(--juice-field-disabled-fg);
|
|
464
|
+
cursor: not-allowed;
|
|
297
465
|
}
|
|
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
466
|
.juice-select__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
303
|
-
.juice-select__placeholder { color: var(--juice-
|
|
304
|
-
.juice-
|
|
467
|
+
.juice-select__placeholder { color: var(--juice-field-placeholder); }
|
|
468
|
+
.juice-select__trigger:disabled .juice-select__placeholder { color: inherit; }
|
|
469
|
+
.juice-select__chevron {
|
|
470
|
+
flex: none;
|
|
471
|
+
width: 1rem;
|
|
472
|
+
height: 1rem;
|
|
473
|
+
color: var(--juice-listbox-chevron);
|
|
474
|
+
transition: transform var(--juice-field-duration) var(--juice-field-ease);
|
|
475
|
+
}
|
|
476
|
+
.juice-select__trigger[aria-expanded='true'] .juice-select__chevron { transform: rotate(180deg); }
|
|
477
|
+
/* The CDK pane is a flex box: the panel must grow to fill it, or it shrinks to its content under a wide trigger. */
|
|
305
478
|
.juice-select-panel {
|
|
306
479
|
box-sizing: border-box;
|
|
307
|
-
|
|
480
|
+
flex: 1 1 auto;
|
|
481
|
+
width: 100%;
|
|
482
|
+
max-height: var(--juice-listbox-max-height);
|
|
308
483
|
margin: 0;
|
|
309
|
-
padding: var(--juice-
|
|
484
|
+
padding: var(--juice-listbox-padding);
|
|
310
485
|
overflow-y: auto;
|
|
311
|
-
border: 1px solid var(--juice-
|
|
312
|
-
border-radius: var(--juice-radius
|
|
313
|
-
background: var(--juice-
|
|
314
|
-
color: var(--juice-
|
|
315
|
-
box-shadow: var(--juice-shadow
|
|
486
|
+
border: 1px solid var(--juice-listbox-border);
|
|
487
|
+
border-radius: var(--juice-listbox-radius);
|
|
488
|
+
background: var(--juice-listbox-bg);
|
|
489
|
+
color: var(--juice-listbox-fg);
|
|
490
|
+
box-shadow: var(--juice-listbox-shadow);
|
|
316
491
|
font-family: var(--juice-font-sans);
|
|
317
|
-
font-size: var(--juice-
|
|
492
|
+
font-size: var(--juice-field-font-size);
|
|
493
|
+
line-height: var(--juice-field-line-height);
|
|
494
|
+
animation: juice-select-in var(--juice-field-duration) var(--juice-field-ease);
|
|
318
495
|
}
|
|
496
|
+
@keyframes juice-select-in { from { opacity: 0; transform: translateY(-2px); } }
|
|
319
497
|
juice-option {
|
|
320
|
-
display:
|
|
321
|
-
|
|
322
|
-
|
|
498
|
+
display: flex;
|
|
499
|
+
align-items: center;
|
|
500
|
+
gap: var(--juice-listbox-option-gap);
|
|
501
|
+
min-height: var(--juice-listbox-option-height);
|
|
502
|
+
padding: 0 var(--juice-listbox-option-padding-x);
|
|
503
|
+
border-radius: var(--juice-listbox-option-radius);
|
|
323
504
|
cursor: pointer;
|
|
324
505
|
}
|
|
325
|
-
|
|
326
|
-
juice-
|
|
327
|
-
juice-option
|
|
506
|
+
.juice-option__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
507
|
+
.juice-option__check { flex: none; width: 1rem; height: 1rem; color: var(--juice-listbox-option-check); }
|
|
508
|
+
juice-option.juice-option--active { background: var(--juice-listbox-option-active-bg); }
|
|
509
|
+
juice-option[aria-selected='true'] { background: var(--juice-listbox-option-selected-bg); color: var(--juice-listbox-option-selected-fg); }
|
|
510
|
+
juice-option[aria-selected='true'].juice-option--active { background: var(--juice-listbox-option-active-bg); }
|
|
511
|
+
juice-option[aria-disabled='true'] { color: var(--juice-listbox-option-disabled-fg); cursor: not-allowed; }
|
|
512
|
+
@media (prefers-reduced-motion: reduce) {
|
|
513
|
+
.juice-select__trigger, .juice-select__chevron { transition: none; }
|
|
514
|
+
.juice-select-panel { animation: none; }
|
|
515
|
+
}
|
|
516
|
+
@media (forced-colors: active) {
|
|
517
|
+
.juice-select__trigger:is(:focus-visible, [aria-expanded='true']) { outline: 2px solid CanvasText; outline-offset: 1px; }
|
|
518
|
+
juice-option.juice-option--active { outline: 1px solid Highlight; }
|
|
519
|
+
}
|
|
328
520
|
`;
|
|
329
521
|
/** One choice in a `<juice-select>`. Its text is the label shown in the trigger and matched by typeahead. */
|
|
330
522
|
class JuiceOption {
|
|
@@ -355,11 +547,17 @@ class JuiceOption {
|
|
|
355
547
|
this.active.set(false);
|
|
356
548
|
}
|
|
357
549
|
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.
|
|
550
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.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: `<span class="juice-option__label"><ng-content /></span>
|
|
551
|
+
@if (selected()) {
|
|
552
|
+
<svg class="juice-option__check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M20 6 9 17l-5-5" /></svg>
|
|
553
|
+
}`, 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-field-height);margin:0;padding:0 var(--juice-field-padding-x);border:1px solid var(--juice-field-border);border-radius:var(--juice-field-radius);background:var(--juice-field-bg);color:var(--juice-field-fg);font-family:inherit;font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);text-align:start;cursor:pointer;transition:border-color var(--juice-field-duration) var(--juice-field-ease),box-shadow var(--juice-field-duration) var(--juice-field-ease)}.juice-select__trigger:enabled:hover{border-color:var(--juice-field-border-hover)}.juice-select__trigger:focus-visible,.juice-select__trigger[aria-expanded=true]{outline:none;border-color:var(--juice-field-border-focus);box-shadow:0 0 0 3px var(--juice-field-focus-halo)}.juice-select__trigger[data-status=error]{border-color:var(--juice-field-error)}.juice-select__trigger[data-status=error]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-error-halo)}.juice-select__trigger[data-status=warning]{border-color:var(--juice-field-warning)}.juice-select__trigger[data-status=warning]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-warning-halo)}.juice-select__trigger[data-status=success]{border-color:var(--juice-field-success)}.juice-select__trigger[data-status=success]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-success-halo)}.juice-select__trigger:disabled{background:var(--juice-field-disabled-bg);border-color:var(--juice-field-disabled-border);color:var(--juice-field-disabled-fg);cursor:not-allowed}.juice-select__value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-select__placeholder{color:var(--juice-field-placeholder)}.juice-select__trigger:disabled .juice-select__placeholder{color:inherit}.juice-select__chevron{flex:none;width:1rem;height:1rem;color:var(--juice-listbox-chevron);transition:transform var(--juice-field-duration) var(--juice-field-ease)}.juice-select__trigger[aria-expanded=true] .juice-select__chevron{transform:rotate(180deg)}.juice-select-panel{box-sizing:border-box;flex:1 1 auto;width:100%;max-height:var(--juice-listbox-max-height);margin:0;padding:var(--juice-listbox-padding);overflow-y:auto;border:1px solid var(--juice-listbox-border);border-radius:var(--juice-listbox-radius);background:var(--juice-listbox-bg);color:var(--juice-listbox-fg);box-shadow:var(--juice-listbox-shadow);font-family:var(--juice-font-sans);font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);animation:juice-select-in var(--juice-field-duration) var(--juice-field-ease)}@keyframes juice-select-in{0%{opacity:0;transform:translateY(-2px)}}juice-option{display:flex;align-items:center;gap:var(--juice-listbox-option-gap);min-height:var(--juice-listbox-option-height);padding:0 var(--juice-listbox-option-padding-x);border-radius:var(--juice-listbox-option-radius);cursor:pointer}.juice-option__label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-option__check{flex:none;width:1rem;height:1rem;color:var(--juice-listbox-option-check)}juice-option.juice-option--active{background:var(--juice-listbox-option-active-bg)}juice-option[aria-selected=true]{background:var(--juice-listbox-option-selected-bg);color:var(--juice-listbox-option-selected-fg)}juice-option[aria-selected=true].juice-option--active{background:var(--juice-listbox-option-active-bg)}juice-option[aria-disabled=true]{color:var(--juice-listbox-option-disabled-fg);cursor:not-allowed}@media(prefers-reduced-motion:reduce){.juice-select__trigger,.juice-select__chevron{transition:none}.juice-select-panel{animation:none}}@media(forced-colors:active){.juice-select__trigger:is(:focus-visible,[aria-expanded=true]){outline:2px solid CanvasText;outline-offset:1px}juice-option.juice-option--active{outline:1px solid Highlight}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
359
554
|
}
|
|
360
555
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceOption, decorators: [{
|
|
361
556
|
type: Component,
|
|
362
|
-
args: [{ selector: 'juice-option', template:
|
|
557
|
+
args: [{ selector: 'juice-option', template: `<span class="juice-option__label"><ng-content /></span>
|
|
558
|
+
@if (selected()) {
|
|
559
|
+
<svg class="juice-option__check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M20 6 9 17l-5-5" /></svg>
|
|
560
|
+
}`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
|
363
561
|
role: 'option',
|
|
364
562
|
'[id]': 'id',
|
|
365
563
|
'[attr.aria-selected]': 'selected() ? "true" : "false"',
|
|
@@ -367,7 +565,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
367
565
|
'[class.juice-option--active]': 'active()',
|
|
368
566
|
'(click)': 'select.choose(this)',
|
|
369
567
|
'(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-
|
|
568
|
+
}, 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-field-height);margin:0;padding:0 var(--juice-field-padding-x);border:1px solid var(--juice-field-border);border-radius:var(--juice-field-radius);background:var(--juice-field-bg);color:var(--juice-field-fg);font-family:inherit;font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);text-align:start;cursor:pointer;transition:border-color var(--juice-field-duration) var(--juice-field-ease),box-shadow var(--juice-field-duration) var(--juice-field-ease)}.juice-select__trigger:enabled:hover{border-color:var(--juice-field-border-hover)}.juice-select__trigger:focus-visible,.juice-select__trigger[aria-expanded=true]{outline:none;border-color:var(--juice-field-border-focus);box-shadow:0 0 0 3px var(--juice-field-focus-halo)}.juice-select__trigger[data-status=error]{border-color:var(--juice-field-error)}.juice-select__trigger[data-status=error]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-error-halo)}.juice-select__trigger[data-status=warning]{border-color:var(--juice-field-warning)}.juice-select__trigger[data-status=warning]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-warning-halo)}.juice-select__trigger[data-status=success]{border-color:var(--juice-field-success)}.juice-select__trigger[data-status=success]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-success-halo)}.juice-select__trigger:disabled{background:var(--juice-field-disabled-bg);border-color:var(--juice-field-disabled-border);color:var(--juice-field-disabled-fg);cursor:not-allowed}.juice-select__value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-select__placeholder{color:var(--juice-field-placeholder)}.juice-select__trigger:disabled .juice-select__placeholder{color:inherit}.juice-select__chevron{flex:none;width:1rem;height:1rem;color:var(--juice-listbox-chevron);transition:transform var(--juice-field-duration) var(--juice-field-ease)}.juice-select__trigger[aria-expanded=true] .juice-select__chevron{transform:rotate(180deg)}.juice-select-panel{box-sizing:border-box;flex:1 1 auto;width:100%;max-height:var(--juice-listbox-max-height);margin:0;padding:var(--juice-listbox-padding);overflow-y:auto;border:1px solid var(--juice-listbox-border);border-radius:var(--juice-listbox-radius);background:var(--juice-listbox-bg);color:var(--juice-listbox-fg);box-shadow:var(--juice-listbox-shadow);font-family:var(--juice-font-sans);font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);animation:juice-select-in var(--juice-field-duration) var(--juice-field-ease)}@keyframes juice-select-in{0%{opacity:0;transform:translateY(-2px)}}juice-option{display:flex;align-items:center;gap:var(--juice-listbox-option-gap);min-height:var(--juice-listbox-option-height);padding:0 var(--juice-listbox-option-padding-x);border-radius:var(--juice-listbox-option-radius);cursor:pointer}.juice-option__label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-option__check{flex:none;width:1rem;height:1rem;color:var(--juice-listbox-option-check)}juice-option.juice-option--active{background:var(--juice-listbox-option-active-bg)}juice-option[aria-selected=true]{background:var(--juice-listbox-option-selected-bg);color:var(--juice-listbox-option-selected-fg)}juice-option[aria-selected=true].juice-option--active{background:var(--juice-listbox-option-active-bg)}juice-option[aria-disabled=true]{color:var(--juice-listbox-option-disabled-fg);cursor:not-allowed}@media(prefers-reduced-motion:reduce){.juice-select__trigger,.juice-select__chevron{transition:none}.juice-select-panel{animation:none}}@media(forced-colors:active){.juice-select__trigger:is(:focus-visible,[aria-expanded=true]){outline:2px solid CanvasText;outline-offset:1px}juice-option.juice-option--active{outline:1px solid Highlight}}\n"] }]
|
|
371
569
|
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
372
570
|
const POSITIONS = [
|
|
373
571
|
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 4 },
|
|
@@ -396,6 +594,10 @@ class JuiceSelect {
|
|
|
396
594
|
...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
397
595
|
this.triggerWidth = signal(0, /* @ts-ignore */
|
|
398
596
|
...(ngDevMode ? [{ debugName: "triggerWidth" }] : /* istanbul ignore next */ []));
|
|
597
|
+
/** The trigger's colour scheme, carried into the overlay (which lives at the end of <body>), so a select inside a
|
|
598
|
+
* dark-themed region opens a dark list. */
|
|
599
|
+
this.scheme = signal('', /* @ts-ignore */
|
|
600
|
+
...(ngDevMode ? [{ debugName: "scheme" }] : /* istanbul ignore next */ []));
|
|
399
601
|
this.activeId = signal(null, /* @ts-ignore */
|
|
400
602
|
...(ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []));
|
|
401
603
|
this.displayLabel = signal('', /* @ts-ignore */
|
|
@@ -412,6 +614,7 @@ class JuiceSelect {
|
|
|
412
614
|
this.keys = new ActiveDescendantKeyManager(this.options, inject(Injector))
|
|
413
615
|
.withTypeAhead(200)
|
|
414
616
|
.withHomeAndEnd()
|
|
617
|
+
.withPageUpDown()
|
|
415
618
|
.skipPredicate((o) => o.disabled);
|
|
416
619
|
this.onChange = () => undefined;
|
|
417
620
|
this.onTouched = () => undefined;
|
|
@@ -459,7 +662,9 @@ class JuiceSelect {
|
|
|
459
662
|
show() {
|
|
460
663
|
if (this.isDisabled() || this.open())
|
|
461
664
|
return;
|
|
462
|
-
this.
|
|
665
|
+
const trigger = this.trigger().nativeElement;
|
|
666
|
+
this.triggerWidth.set(trigger.offsetWidth);
|
|
667
|
+
this.scheme.set(getComputedStyle(trigger).colorScheme);
|
|
463
668
|
this.open.set(true);
|
|
464
669
|
const items = this.options();
|
|
465
670
|
const selected = items.findIndex((o) => o.value() === this.value() && !o.disabled);
|
|
@@ -531,13 +736,14 @@ class JuiceSelect {
|
|
|
531
736
|
[attr.aria-label]="field ? null : label() || null"
|
|
532
737
|
[attr.aria-describedby]="field?.describedBy() ?? null"
|
|
533
738
|
[attr.aria-invalid]="field && field.invalid() ? 'true' : null"
|
|
739
|
+
[attr.data-status]="field?.status() ?? null"
|
|
534
740
|
[disabled]="isDisabled()"
|
|
535
741
|
(click)="toggle()"
|
|
536
742
|
(keydown)="onKeydown($event)"
|
|
537
743
|
(blur)="onTouched()"
|
|
538
744
|
>
|
|
539
745
|
<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="
|
|
746
|
+
<svg class="juice-select__chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
541
747
|
<path d="m6 9 6 6 6-6" />
|
|
542
748
|
</svg>
|
|
543
749
|
</button>
|
|
@@ -548,6 +754,7 @@ class JuiceSelect {
|
|
|
548
754
|
[cdkConnectedOverlayPositions]="positions"
|
|
549
755
|
[cdkConnectedOverlayMinWidth]="triggerWidth()"
|
|
550
756
|
[cdkConnectedOverlayScrollStrategy]="scrollStrategy"
|
|
757
|
+
[cdkConnectedOverlayViewportMargin]="8"
|
|
551
758
|
(overlayOutsideClick)="onOutsideClick($event)"
|
|
552
759
|
(detach)="close()"
|
|
553
760
|
>
|
|
@@ -555,6 +762,7 @@ class JuiceSelect {
|
|
|
555
762
|
class="juice-select-panel"
|
|
556
763
|
role="listbox"
|
|
557
764
|
[id]="listboxId"
|
|
765
|
+
[style.color-scheme]="scheme() || null"
|
|
558
766
|
[attr.aria-label]="field ? null : label() || placeholder() || 'Options'"
|
|
559
767
|
[attr.aria-labelledby]="field ? field.labelId : null"
|
|
560
768
|
(mousedown)="$event.preventDefault()"
|
|
@@ -562,7 +770,7 @@ class JuiceSelect {
|
|
|
562
770
|
<ng-content />
|
|
563
771
|
</div>
|
|
564
772
|
</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-
|
|
773
|
+
`, 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-field-height);margin:0;padding:0 var(--juice-field-padding-x);border:1px solid var(--juice-field-border);border-radius:var(--juice-field-radius);background:var(--juice-field-bg);color:var(--juice-field-fg);font-family:inherit;font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);text-align:start;cursor:pointer;transition:border-color var(--juice-field-duration) var(--juice-field-ease),box-shadow var(--juice-field-duration) var(--juice-field-ease)}.juice-select__trigger:enabled:hover{border-color:var(--juice-field-border-hover)}.juice-select__trigger:focus-visible,.juice-select__trigger[aria-expanded=true]{outline:none;border-color:var(--juice-field-border-focus);box-shadow:0 0 0 3px var(--juice-field-focus-halo)}.juice-select__trigger[data-status=error]{border-color:var(--juice-field-error)}.juice-select__trigger[data-status=error]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-error-halo)}.juice-select__trigger[data-status=warning]{border-color:var(--juice-field-warning)}.juice-select__trigger[data-status=warning]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-warning-halo)}.juice-select__trigger[data-status=success]{border-color:var(--juice-field-success)}.juice-select__trigger[data-status=success]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-success-halo)}.juice-select__trigger:disabled{background:var(--juice-field-disabled-bg);border-color:var(--juice-field-disabled-border);color:var(--juice-field-disabled-fg);cursor:not-allowed}.juice-select__value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-select__placeholder{color:var(--juice-field-placeholder)}.juice-select__trigger:disabled .juice-select__placeholder{color:inherit}.juice-select__chevron{flex:none;width:1rem;height:1rem;color:var(--juice-listbox-chevron);transition:transform var(--juice-field-duration) var(--juice-field-ease)}.juice-select__trigger[aria-expanded=true] .juice-select__chevron{transform:rotate(180deg)}.juice-select-panel{box-sizing:border-box;flex:1 1 auto;width:100%;max-height:var(--juice-listbox-max-height);margin:0;padding:var(--juice-listbox-padding);overflow-y:auto;border:1px solid var(--juice-listbox-border);border-radius:var(--juice-listbox-radius);background:var(--juice-listbox-bg);color:var(--juice-listbox-fg);box-shadow:var(--juice-listbox-shadow);font-family:var(--juice-font-sans);font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);animation:juice-select-in var(--juice-field-duration) var(--juice-field-ease)}@keyframes juice-select-in{0%{opacity:0;transform:translateY(-2px)}}juice-option{display:flex;align-items:center;gap:var(--juice-listbox-option-gap);min-height:var(--juice-listbox-option-height);padding:0 var(--juice-listbox-option-padding-x);border-radius:var(--juice-listbox-option-radius);cursor:pointer}.juice-option__label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-option__check{flex:none;width:1rem;height:1rem;color:var(--juice-listbox-option-check)}juice-option.juice-option--active{background:var(--juice-listbox-option-active-bg)}juice-option[aria-selected=true]{background:var(--juice-listbox-option-selected-bg);color:var(--juice-listbox-option-selected-fg)}juice-option[aria-selected=true].juice-option--active{background:var(--juice-listbox-option-active-bg)}juice-option[aria-disabled=true]{color:var(--juice-listbox-option-disabled-fg);cursor:not-allowed}@media(prefers-reduced-motion:reduce){.juice-select__trigger,.juice-select__chevron{transition:none}.juice-select-panel{animation:none}}@media(forced-colors:active){.juice-select__trigger:is(:focus-visible,[aria-expanded=true]){outline:2px solid CanvasText;outline-offset:1px}juice-option.juice-option--active{outline:1px solid Highlight}}\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
774
|
}
|
|
567
775
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceSelect, decorators: [{
|
|
568
776
|
type: Component,
|
|
@@ -582,13 +790,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
582
790
|
[attr.aria-label]="field ? null : label() || null"
|
|
583
791
|
[attr.aria-describedby]="field?.describedBy() ?? null"
|
|
584
792
|
[attr.aria-invalid]="field && field.invalid() ? 'true' : null"
|
|
793
|
+
[attr.data-status]="field?.status() ?? null"
|
|
585
794
|
[disabled]="isDisabled()"
|
|
586
795
|
(click)="toggle()"
|
|
587
796
|
(keydown)="onKeydown($event)"
|
|
588
797
|
(blur)="onTouched()"
|
|
589
798
|
>
|
|
590
799
|
<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="
|
|
800
|
+
<svg class="juice-select__chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
592
801
|
<path d="m6 9 6 6 6-6" />
|
|
593
802
|
</svg>
|
|
594
803
|
</button>
|
|
@@ -599,6 +808,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
599
808
|
[cdkConnectedOverlayPositions]="positions"
|
|
600
809
|
[cdkConnectedOverlayMinWidth]="triggerWidth()"
|
|
601
810
|
[cdkConnectedOverlayScrollStrategy]="scrollStrategy"
|
|
811
|
+
[cdkConnectedOverlayViewportMargin]="8"
|
|
602
812
|
(overlayOutsideClick)="onOutsideClick($event)"
|
|
603
813
|
(detach)="close()"
|
|
604
814
|
>
|
|
@@ -606,6 +816,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
606
816
|
class="juice-select-panel"
|
|
607
817
|
role="listbox"
|
|
608
818
|
[id]="listboxId"
|
|
819
|
+
[style.color-scheme]="scheme() || null"
|
|
609
820
|
[attr.aria-label]="field ? null : label() || placeholder() || 'Options'"
|
|
610
821
|
[attr.aria-labelledby]="field ? field.labelId : null"
|
|
611
822
|
(mousedown)="$event.preventDefault()"
|
|
@@ -616,65 +827,144 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
616
827
|
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [
|
|
617
828
|
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => JuiceSelect), multi: true },
|
|
618
829
|
{ 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-
|
|
830
|
+
], 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-field-height);margin:0;padding:0 var(--juice-field-padding-x);border:1px solid var(--juice-field-border);border-radius:var(--juice-field-radius);background:var(--juice-field-bg);color:var(--juice-field-fg);font-family:inherit;font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);text-align:start;cursor:pointer;transition:border-color var(--juice-field-duration) var(--juice-field-ease),box-shadow var(--juice-field-duration) var(--juice-field-ease)}.juice-select__trigger:enabled:hover{border-color:var(--juice-field-border-hover)}.juice-select__trigger:focus-visible,.juice-select__trigger[aria-expanded=true]{outline:none;border-color:var(--juice-field-border-focus);box-shadow:0 0 0 3px var(--juice-field-focus-halo)}.juice-select__trigger[data-status=error]{border-color:var(--juice-field-error)}.juice-select__trigger[data-status=error]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-error-halo)}.juice-select__trigger[data-status=warning]{border-color:var(--juice-field-warning)}.juice-select__trigger[data-status=warning]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-warning-halo)}.juice-select__trigger[data-status=success]{border-color:var(--juice-field-success)}.juice-select__trigger[data-status=success]:is(:focus-visible,[aria-expanded=true]){box-shadow:0 0 0 3px var(--juice-field-success-halo)}.juice-select__trigger:disabled{background:var(--juice-field-disabled-bg);border-color:var(--juice-field-disabled-border);color:var(--juice-field-disabled-fg);cursor:not-allowed}.juice-select__value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-select__placeholder{color:var(--juice-field-placeholder)}.juice-select__trigger:disabled .juice-select__placeholder{color:inherit}.juice-select__chevron{flex:none;width:1rem;height:1rem;color:var(--juice-listbox-chevron);transition:transform var(--juice-field-duration) var(--juice-field-ease)}.juice-select__trigger[aria-expanded=true] .juice-select__chevron{transform:rotate(180deg)}.juice-select-panel{box-sizing:border-box;flex:1 1 auto;width:100%;max-height:var(--juice-listbox-max-height);margin:0;padding:var(--juice-listbox-padding);overflow-y:auto;border:1px solid var(--juice-listbox-border);border-radius:var(--juice-listbox-radius);background:var(--juice-listbox-bg);color:var(--juice-listbox-fg);box-shadow:var(--juice-listbox-shadow);font-family:var(--juice-font-sans);font-size:var(--juice-field-font-size);line-height:var(--juice-field-line-height);animation:juice-select-in var(--juice-field-duration) var(--juice-field-ease)}@keyframes juice-select-in{0%{opacity:0;transform:translateY(-2px)}}juice-option{display:flex;align-items:center;gap:var(--juice-listbox-option-gap);min-height:var(--juice-listbox-option-height);padding:0 var(--juice-listbox-option-padding-x);border-radius:var(--juice-listbox-option-radius);cursor:pointer}.juice-option__label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.juice-option__check{flex:none;width:1rem;height:1rem;color:var(--juice-listbox-option-check)}juice-option.juice-option--active{background:var(--juice-listbox-option-active-bg)}juice-option[aria-selected=true]{background:var(--juice-listbox-option-selected-bg);color:var(--juice-listbox-option-selected-fg)}juice-option[aria-selected=true].juice-option--active{background:var(--juice-listbox-option-active-bg)}juice-option[aria-disabled=true]{color:var(--juice-listbox-option-disabled-fg);cursor:not-allowed}@media(prefers-reduced-motion:reduce){.juice-select__trigger,.juice-select__chevron{transition:none}.juice-select-panel{animation:none}}@media(forced-colors:active){.juice-select__trigger:is(:focus-visible,[aria-expanded=true]){outline:2px solid CanvasText;outline-offset:1px}juice-option.juice-option--active{outline:1px solid Highlight}}\n"] }]
|
|
620
831
|
}], 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
832
|
|
|
622
833
|
const CHECKBOX_STYLES = `
|
|
834
|
+
/* The marks are drawn on the box's own 16-unit grid (viewBox 0 0 16 16 = the border box), so they scale with
|
|
835
|
+
--juice-checkbox-size and stay optically centred: the tick's bounding box is centred on (8, 8) and its 1.75 stroke
|
|
836
|
+
matches the minus. */
|
|
623
837
|
input[type='checkbox'][juiceCheckbox] {
|
|
838
|
+
--_mark-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.75 8.25 6.9 10.4 11.25 5.6'/%3E%3C/svg%3E");
|
|
839
|
+
--_mark-minus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round'%3E%3Cpath d='M5 8h6'/%3E%3C/svg%3E");
|
|
624
840
|
appearance: none;
|
|
625
841
|
box-sizing: border-box;
|
|
626
842
|
position: relative;
|
|
627
843
|
flex: none;
|
|
628
|
-
width:
|
|
629
|
-
height:
|
|
844
|
+
width: var(--juice-checkbox-size);
|
|
845
|
+
height: var(--juice-checkbox-size);
|
|
630
846
|
margin: 0;
|
|
631
|
-
border: 1px solid var(--juice-
|
|
632
|
-
border-radius: var(--juice-radius
|
|
633
|
-
background: var(--juice-
|
|
847
|
+
border: 1px solid var(--juice-checkbox-border);
|
|
848
|
+
border-radius: var(--juice-checkbox-radius);
|
|
849
|
+
background: var(--juice-checkbox-bg);
|
|
634
850
|
vertical-align: middle;
|
|
635
851
|
cursor: pointer;
|
|
852
|
+
transition:
|
|
853
|
+
background-color var(--juice-checkbox-duration) var(--juice-checkbox-ease),
|
|
854
|
+
border-color var(--juice-checkbox-duration) var(--juice-checkbox-ease),
|
|
855
|
+
transform var(--juice-checkbox-duration) var(--juice-checkbox-ease);
|
|
636
856
|
}
|
|
637
|
-
input[type='checkbox'][juiceCheckbox]
|
|
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 {
|
|
857
|
+
input[type='checkbox'][juiceCheckbox]::after {
|
|
643
858
|
content: '';
|
|
644
859
|
position: absolute;
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
860
|
+
inset: -1px;
|
|
861
|
+
background: var(--juice-checkbox-checked-fg);
|
|
862
|
+
-webkit-mask: var(--_mark-check) center / 100% 100% no-repeat;
|
|
863
|
+
mask: var(--_mark-check) center / 100% 100% no-repeat;
|
|
864
|
+
opacity: 0;
|
|
865
|
+
transform: scale(0.6);
|
|
866
|
+
transition:
|
|
867
|
+
opacity var(--juice-checkbox-duration) var(--juice-checkbox-ease),
|
|
868
|
+
transform var(--juice-checkbox-duration) var(--juice-checkbox-ease);
|
|
652
869
|
}
|
|
653
870
|
input[type='checkbox'][juiceCheckbox]:indeterminate::after {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
871
|
+
-webkit-mask-image: var(--_mark-minus);
|
|
872
|
+
mask-image: var(--_mark-minus);
|
|
873
|
+
}
|
|
874
|
+
input[type='checkbox'][juiceCheckbox]:is(:checked, :indeterminate)::after { opacity: 1; transform: none; }
|
|
875
|
+
|
|
876
|
+
/* Filled: checked and indeterminate. */
|
|
877
|
+
input[type='checkbox'][juiceCheckbox]:is(:checked, :indeterminate) {
|
|
878
|
+
border-color: var(--juice-checkbox-checked-bg);
|
|
879
|
+
background: var(--juice-checkbox-checked-bg);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/* Hover: the edge darkens on an empty box, the fill deepens on a filled one; the whole label is the target. */
|
|
883
|
+
input[type='checkbox'][juiceCheckbox]:enabled:hover,
|
|
884
|
+
label:hover > input[type='checkbox'][juiceCheckbox]:enabled {
|
|
885
|
+
border-color: var(--juice-checkbox-hover-border);
|
|
886
|
+
}
|
|
887
|
+
input[type='checkbox'][juiceCheckbox]:enabled:is(:checked, :indeterminate):hover,
|
|
888
|
+
label:hover > input[type='checkbox'][juiceCheckbox]:enabled:is(:checked, :indeterminate) {
|
|
889
|
+
border-color: var(--juice-checkbox-checked-hover-bg);
|
|
890
|
+
background: var(--juice-checkbox-checked-hover-bg);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/* Pressed: a small settle, not a bounce. */
|
|
894
|
+
input[type='checkbox'][juiceCheckbox]:enabled:active,
|
|
895
|
+
label:active > input[type='checkbox'][juiceCheckbox]:enabled {
|
|
896
|
+
background: var(--juice-checkbox-active-bg);
|
|
897
|
+
transform: scale(0.92);
|
|
898
|
+
}
|
|
899
|
+
input[type='checkbox'][juiceCheckbox]:enabled:is(:checked, :indeterminate):active,
|
|
900
|
+
label:active > input[type='checkbox'][juiceCheckbox]:enabled:is(:checked, :indeterminate) {
|
|
901
|
+
border-color: var(--juice-checkbox-checked-active-bg);
|
|
902
|
+
background: var(--juice-checkbox-checked-active-bg);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
input[type='checkbox'][juiceCheckbox]:focus-visible {
|
|
906
|
+
outline: 2px solid var(--juice-checkbox-focus-ring);
|
|
907
|
+
outline-offset: 2px;
|
|
661
908
|
}
|
|
662
|
-
|
|
909
|
+
|
|
910
|
+
/* Disabled: an empty box keeps its edge; a value keeps a neutral fill and its mark, so checked and unchecked stay apart. */
|
|
663
911
|
input[type='checkbox'][juiceCheckbox]:disabled {
|
|
664
|
-
border-color:
|
|
665
|
-
background: var(--juice-
|
|
912
|
+
border-color: var(--juice-checkbox-disabled-border);
|
|
913
|
+
background: var(--juice-checkbox-disabled-bg);
|
|
914
|
+
cursor: not-allowed;
|
|
915
|
+
}
|
|
916
|
+
input[type='checkbox'][juiceCheckbox]:disabled:is(:checked, :indeterminate) {
|
|
917
|
+
border-color: var(--juice-checkbox-disabled-checked-bg);
|
|
918
|
+
background: var(--juice-checkbox-disabled-checked-bg);
|
|
919
|
+
}
|
|
920
|
+
input[type='checkbox'][juiceCheckbox]:disabled::after { background: var(--juice-checkbox-disabled-checked-fg); }
|
|
921
|
+
|
|
922
|
+
/* A <label> that wraps the box: 14px Inter, 8px gap, the box centred on the first line (1lh) so long labels wrap under
|
|
923
|
+
the text, not under the box. :where() keeps it at zero specificity, so apps can restyle their labels. */
|
|
924
|
+
:where(label:has(> input[type='checkbox'][juiceCheckbox])) {
|
|
925
|
+
display: inline-flex;
|
|
926
|
+
align-items: flex-start;
|
|
927
|
+
gap: var(--juice-checkbox-label-gap);
|
|
928
|
+
font-family: var(--juice-font-sans);
|
|
929
|
+
font-size: var(--juice-checkbox-label-font-size);
|
|
930
|
+
font-weight: var(--juice-checkbox-label-font-weight);
|
|
931
|
+
line-height: var(--juice-checkbox-label-line-height);
|
|
932
|
+
color: var(--juice-checkbox-label-fg);
|
|
933
|
+
cursor: pointer;
|
|
934
|
+
}
|
|
935
|
+
:where(label:has(> input[type='checkbox'][juiceCheckbox])) > input[type='checkbox'][juiceCheckbox] {
|
|
936
|
+
margin-block-start: calc((1lh - var(--juice-checkbox-size)) / 2);
|
|
937
|
+
}
|
|
938
|
+
:where(label:has(> input[type='checkbox'][juiceCheckbox]:disabled)) {
|
|
939
|
+
color: var(--juice-checkbox-label-disabled-fg);
|
|
666
940
|
cursor: not-allowed;
|
|
667
941
|
}
|
|
942
|
+
|
|
943
|
+
@media (prefers-reduced-motion: reduce) {
|
|
944
|
+
input[type='checkbox'][juiceCheckbox],
|
|
945
|
+
input[type='checkbox'][juiceCheckbox]::after { transition: none; }
|
|
946
|
+
input[type='checkbox'][juiceCheckbox]:enabled:active,
|
|
947
|
+
label:active > input[type='checkbox'][juiceCheckbox]:enabled { transform: none; }
|
|
948
|
+
}
|
|
949
|
+
/* Forced colours (Windows contrast themes) drop backgrounds and masks: hand the box back to the native checkbox. */
|
|
950
|
+
@media (forced-colors: active) {
|
|
951
|
+
input[type='checkbox'][juiceCheckbox] { appearance: auto; border: 0; background: none; transform: none; }
|
|
952
|
+
input[type='checkbox'][juiceCheckbox]::after { display: none; }
|
|
953
|
+
}
|
|
668
954
|
`;
|
|
669
955
|
class JuiceCheckboxStyles {
|
|
670
956
|
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:
|
|
957
|
+
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]{--_mark-check: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.75 8.25 6.9 10.4 11.25 5.6'/%3E%3C/svg%3E\");--_mark-minus: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round'%3E%3Cpath d='M5 8h6'/%3E%3C/svg%3E\");appearance:none;box-sizing:border-box;position:relative;flex:none;width:var(--juice-checkbox-size);height:var(--juice-checkbox-size);margin:0;border:1px solid var(--juice-checkbox-border);border-radius:var(--juice-checkbox-radius);background:var(--juice-checkbox-bg);vertical-align:middle;cursor:pointer;transition:background-color var(--juice-checkbox-duration) var(--juice-checkbox-ease),border-color var(--juice-checkbox-duration) var(--juice-checkbox-ease),transform var(--juice-checkbox-duration) var(--juice-checkbox-ease)}input[type=checkbox][juiceCheckbox]:after{content:\"\";position:absolute;inset:-1px;background:var(--juice-checkbox-checked-fg);-webkit-mask:var(--_mark-check) center / 100% 100% no-repeat;mask:var(--_mark-check) center / 100% 100% no-repeat;opacity:0;transform:scale(.6);transition:opacity var(--juice-checkbox-duration) var(--juice-checkbox-ease),transform var(--juice-checkbox-duration) var(--juice-checkbox-ease)}input[type=checkbox][juiceCheckbox]:indeterminate:after{-webkit-mask-image:var(--_mark-minus);mask-image:var(--_mark-minus)}input[type=checkbox][juiceCheckbox]:is(:checked,:indeterminate):after{opacity:1;transform:none}input[type=checkbox][juiceCheckbox]:is(:checked,:indeterminate){border-color:var(--juice-checkbox-checked-bg);background:var(--juice-checkbox-checked-bg)}input[type=checkbox][juiceCheckbox]:enabled:hover,label:hover>input[type=checkbox][juiceCheckbox]:enabled{border-color:var(--juice-checkbox-hover-border)}input[type=checkbox][juiceCheckbox]:enabled:is(:checked,:indeterminate):hover,label:hover>input[type=checkbox][juiceCheckbox]:enabled:is(:checked,:indeterminate){border-color:var(--juice-checkbox-checked-hover-bg);background:var(--juice-checkbox-checked-hover-bg)}input[type=checkbox][juiceCheckbox]:enabled:active,label:active>input[type=checkbox][juiceCheckbox]:enabled{background:var(--juice-checkbox-active-bg);transform:scale(.92)}input[type=checkbox][juiceCheckbox]:enabled:is(:checked,:indeterminate):active,label:active>input[type=checkbox][juiceCheckbox]:enabled:is(:checked,:indeterminate){border-color:var(--juice-checkbox-checked-active-bg);background:var(--juice-checkbox-checked-active-bg)}input[type=checkbox][juiceCheckbox]:focus-visible{outline:2px solid var(--juice-checkbox-focus-ring);outline-offset:2px}input[type=checkbox][juiceCheckbox]:disabled{border-color:var(--juice-checkbox-disabled-border);background:var(--juice-checkbox-disabled-bg);cursor:not-allowed}input[type=checkbox][juiceCheckbox]:disabled:is(:checked,:indeterminate){border-color:var(--juice-checkbox-disabled-checked-bg);background:var(--juice-checkbox-disabled-checked-bg)}input[type=checkbox][juiceCheckbox]:disabled:after{background:var(--juice-checkbox-disabled-checked-fg)}:where(label:has(>input[type=checkbox][juiceCheckbox])){display:inline-flex;align-items:flex-start;gap:var(--juice-checkbox-label-gap);font-family:var(--juice-font-sans);font-size:var(--juice-checkbox-label-font-size);font-weight:var(--juice-checkbox-label-font-weight);line-height:var(--juice-checkbox-label-line-height);color:var(--juice-checkbox-label-fg);cursor:pointer}:where(label:has(>input[type=checkbox][juiceCheckbox]))>input[type=checkbox][juiceCheckbox]{margin-block-start:calc((1lh - var(--juice-checkbox-size)) / 2)}:where(label:has(>input[type=checkbox][juiceCheckbox]:disabled)){color:var(--juice-checkbox-label-disabled-fg);cursor:not-allowed}@media(prefers-reduced-motion:reduce){input[type=checkbox][juiceCheckbox],input[type=checkbox][juiceCheckbox]:after{transition:none}input[type=checkbox][juiceCheckbox]:enabled:active,label:active>input[type=checkbox][juiceCheckbox]:enabled{transform:none}}@media(forced-colors:active){input[type=checkbox][juiceCheckbox]{appearance:auto;border:0;background:none;transform:none}input[type=checkbox][juiceCheckbox]:after{display:none}}\n"], encapsulation: i0.ViewEncapsulation.None }); }
|
|
672
958
|
}
|
|
673
959
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JuiceCheckboxStyles, decorators: [{
|
|
674
960
|
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:
|
|
961
|
+
args: [{ selector: 'juice-checkbox-styles', template: '', encapsulation: ViewEncapsulation.None, styles: ["input[type=checkbox][juiceCheckbox]{--_mark-check: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.75 8.25 6.9 10.4 11.25 5.6'/%3E%3C/svg%3E\");--_mark-minus: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round'%3E%3Cpath d='M5 8h6'/%3E%3C/svg%3E\");appearance:none;box-sizing:border-box;position:relative;flex:none;width:var(--juice-checkbox-size);height:var(--juice-checkbox-size);margin:0;border:1px solid var(--juice-checkbox-border);border-radius:var(--juice-checkbox-radius);background:var(--juice-checkbox-bg);vertical-align:middle;cursor:pointer;transition:background-color var(--juice-checkbox-duration) var(--juice-checkbox-ease),border-color var(--juice-checkbox-duration) var(--juice-checkbox-ease),transform var(--juice-checkbox-duration) var(--juice-checkbox-ease)}input[type=checkbox][juiceCheckbox]:after{content:\"\";position:absolute;inset:-1px;background:var(--juice-checkbox-checked-fg);-webkit-mask:var(--_mark-check) center / 100% 100% no-repeat;mask:var(--_mark-check) center / 100% 100% no-repeat;opacity:0;transform:scale(.6);transition:opacity var(--juice-checkbox-duration) var(--juice-checkbox-ease),transform var(--juice-checkbox-duration) var(--juice-checkbox-ease)}input[type=checkbox][juiceCheckbox]:indeterminate:after{-webkit-mask-image:var(--_mark-minus);mask-image:var(--_mark-minus)}input[type=checkbox][juiceCheckbox]:is(:checked,:indeterminate):after{opacity:1;transform:none}input[type=checkbox][juiceCheckbox]:is(:checked,:indeterminate){border-color:var(--juice-checkbox-checked-bg);background:var(--juice-checkbox-checked-bg)}input[type=checkbox][juiceCheckbox]:enabled:hover,label:hover>input[type=checkbox][juiceCheckbox]:enabled{border-color:var(--juice-checkbox-hover-border)}input[type=checkbox][juiceCheckbox]:enabled:is(:checked,:indeterminate):hover,label:hover>input[type=checkbox][juiceCheckbox]:enabled:is(:checked,:indeterminate){border-color:var(--juice-checkbox-checked-hover-bg);background:var(--juice-checkbox-checked-hover-bg)}input[type=checkbox][juiceCheckbox]:enabled:active,label:active>input[type=checkbox][juiceCheckbox]:enabled{background:var(--juice-checkbox-active-bg);transform:scale(.92)}input[type=checkbox][juiceCheckbox]:enabled:is(:checked,:indeterminate):active,label:active>input[type=checkbox][juiceCheckbox]:enabled:is(:checked,:indeterminate){border-color:var(--juice-checkbox-checked-active-bg);background:var(--juice-checkbox-checked-active-bg)}input[type=checkbox][juiceCheckbox]:focus-visible{outline:2px solid var(--juice-checkbox-focus-ring);outline-offset:2px}input[type=checkbox][juiceCheckbox]:disabled{border-color:var(--juice-checkbox-disabled-border);background:var(--juice-checkbox-disabled-bg);cursor:not-allowed}input[type=checkbox][juiceCheckbox]:disabled:is(:checked,:indeterminate){border-color:var(--juice-checkbox-disabled-checked-bg);background:var(--juice-checkbox-disabled-checked-bg)}input[type=checkbox][juiceCheckbox]:disabled:after{background:var(--juice-checkbox-disabled-checked-fg)}:where(label:has(>input[type=checkbox][juiceCheckbox])){display:inline-flex;align-items:flex-start;gap:var(--juice-checkbox-label-gap);font-family:var(--juice-font-sans);font-size:var(--juice-checkbox-label-font-size);font-weight:var(--juice-checkbox-label-font-weight);line-height:var(--juice-checkbox-label-line-height);color:var(--juice-checkbox-label-fg);cursor:pointer}:where(label:has(>input[type=checkbox][juiceCheckbox]))>input[type=checkbox][juiceCheckbox]{margin-block-start:calc((1lh - var(--juice-checkbox-size)) / 2)}:where(label:has(>input[type=checkbox][juiceCheckbox]:disabled)){color:var(--juice-checkbox-label-disabled-fg);cursor:not-allowed}@media(prefers-reduced-motion:reduce){input[type=checkbox][juiceCheckbox],input[type=checkbox][juiceCheckbox]:after{transition:none}input[type=checkbox][juiceCheckbox]:enabled:active,label:active>input[type=checkbox][juiceCheckbox]:enabled{transform:none}}@media(forced-colors:active){input[type=checkbox][juiceCheckbox]{appearance:auto;border:0;background:none;transform:none}input[type=checkbox][juiceCheckbox]:after{display:none}}\n"] }]
|
|
676
962
|
}] });
|
|
677
|
-
/**
|
|
963
|
+
/**
|
|
964
|
+
* Styled native checkbox: keyboard, form and screen-reader behaviour stay the platform's. `indeterminate` sets the DOM
|
|
965
|
+
* property (it has no attribute). Wrap it in a `<label>` with its text after it (the label then gets the 14px type and 8px
|
|
966
|
+
* gap), or give it `aria-label`.
|
|
967
|
+
*/
|
|
678
968
|
class JuiceCheckbox {
|
|
679
969
|
constructor() {
|
|
680
970
|
this.indeterminate = input(false, { ...(ngDevMode ? { debugName: "indeterminate" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|