@filip.mazev/blocks 1.4.15 → 1.4.17
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/core/styles/_a11y.scss +5 -0
- package/core/styles/_field-actions.scss +36 -0
- package/core/styles/_field-state.scss +12 -3
- package/core/styles/_helpers.scss +3 -0
- package/core/styles/_index.scss +1 -0
- package/core/styles/_slider-rail.scss +11 -0
- package/core/styles/_slider.scss +119 -11
- package/core/styles/_text-overflow.scss +7 -0
- package/core/styles/_text.scss +5 -0
- package/core/styles/_validation.scss +48 -0
- package/fesm2022/filip.mazev-blocks-core.mjs +83 -18
- package/fesm2022/filip.mazev-blocks-core.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-effects-runtime.mjs +14 -3
- package/fesm2022/filip.mazev-blocks-effects-runtime.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-effects.mjs +16 -8
- package/fesm2022/filip.mazev-blocks-effects.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-forms.mjs +5282 -1093
- package/fesm2022/filip.mazev-blocks-forms.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-primitives.mjs +2373 -1294
- package/fesm2022/filip.mazev-blocks-primitives.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks.mjs +1 -1
- package/fesm2022/filip.mazev-blocks.mjs.map +1 -1
- package/forms/README.md +80 -0
- package/package.json +1 -1
- package/types/filip.mazev-blocks-core.d.ts +22 -2
- package/types/filip.mazev-blocks-effects.d.ts +1 -1
- package/types/filip.mazev-blocks-forms.d.ts +1290 -76
- package/types/filip.mazev-blocks-primitives.d.ts +304 -6
- package/types/filip.mazev-blocks.d.ts +1 -1
package/core/styles/_a11y.scss
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@use 'mixins' as *;
|
|
2
|
+
@use 'motion' as *;
|
|
3
|
+
|
|
4
|
+
// Shared clear action for search and selection controls.
|
|
5
|
+
@mixin field-clear-action {
|
|
6
|
+
@include bx-transition(color, 0.15s, ease);
|
|
7
|
+
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
background: transparent;
|
|
13
|
+
border: none;
|
|
14
|
+
padding: spacing(1);
|
|
15
|
+
inline-size: spacing(6);
|
|
16
|
+
block-size: spacing(6);
|
|
17
|
+
border-radius: radius(sm);
|
|
18
|
+
color: var(--bx-text-secondary);
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
|
|
22
|
+
&:focus-visible {
|
|
23
|
+
outline: 2px solid var(--bx-border-brand);
|
|
24
|
+
outline-offset: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:hover:not(:disabled) {
|
|
28
|
+
color: var(--bx-text-primary);
|
|
29
|
+
background: var(--bx-bg-element-hover);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:disabled {
|
|
33
|
+
cursor: not-allowed;
|
|
34
|
+
opacity: 0.5;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -14,9 +14,18 @@
|
|
|
14
14
|
display: none;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
&:focus-within:not(
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
&:focus-within:not(
|
|
18
|
+
.is-disabled,
|
|
19
|
+
:disabled,
|
|
20
|
+
.is-readonly,
|
|
21
|
+
[readonly],
|
|
22
|
+
[aria-readonly='true'],
|
|
23
|
+
:has([readonly], [aria-readonly='true'])
|
|
24
|
+
),
|
|
25
|
+
&:focus-visible:not(:disabled, [readonly], [aria-readonly='true']),
|
|
26
|
+
&.is-open:not(:disabled),
|
|
27
|
+
&.is-readonly.is-keyboard-focused:focus-within,
|
|
28
|
+
&:has(.bx-readonly.is-keyboard-focused):focus-within {
|
|
20
29
|
--bx-glass-edge: var(--bx-border-brand);
|
|
21
30
|
|
|
22
31
|
outline: 2px solid var(--bx-border-brand);
|
package/core/styles/_index.scss
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@use 'mixins' as *;
|
|
2
|
+
|
|
3
|
+
// Shared finish and geometry for native slider tracks and the range slider rail.
|
|
4
|
+
@mixin slider-rail {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
height: spacing(2);
|
|
7
|
+
border: 1px solid var(--bx-border-strong);
|
|
8
|
+
border-radius: radius(pill);
|
|
9
|
+
background: var(--bx-bg-neutral);
|
|
10
|
+
box-shadow: inset 0 1px 2px rgb(0 0 0 / 16%);
|
|
11
|
+
}
|
package/core/styles/_slider.scss
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
@use 'mixins' as *;
|
|
2
2
|
@use 'motion' as *;
|
|
3
|
+
@use 'slider-rail' as *;
|
|
3
4
|
|
|
4
5
|
// Native range pseudo-elements differ across engines and must remain separate rules.
|
|
5
6
|
@mixin track {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
border: 1px solid var(--bx-border-strong);
|
|
9
|
-
border-radius: radius(pill);
|
|
7
|
+
@include slider-rail;
|
|
8
|
+
|
|
10
9
|
background: linear-gradient(
|
|
11
10
|
to right,
|
|
12
11
|
var(--bx-accent) 0 var(--bx-slider-progress, 50%),
|
|
13
12
|
var(--bx-bg-neutral) var(--bx-slider-progress, 50%) 100%
|
|
14
13
|
);
|
|
15
|
-
box-shadow: inset 0 1px 2px rgb(0 0 0 / 16%);
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
@mixin thumb {
|
|
19
17
|
appearance: none;
|
|
20
18
|
box-sizing: border-box;
|
|
21
|
-
width: spacing(6);
|
|
22
|
-
height: spacing(6);
|
|
19
|
+
width: var(--bx-slider-thumb-size, #{spacing(6)});
|
|
20
|
+
height: var(--bx-slider-thumb-size, #{spacing(6)});
|
|
23
21
|
border-radius: radius(pill);
|
|
24
22
|
border: 1px solid var(--bx-border-strong);
|
|
25
23
|
background: var(--bx-bg-surface);
|
|
@@ -50,7 +48,38 @@
|
|
|
50
48
|
display: block;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
&::before {
|
|
52
|
+
content: '';
|
|
53
|
+
display: var(--bx-slider-fill-display, block);
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: var(--bx-slider-center-y, 50%);
|
|
56
|
+
left: var(--bx-slider-track-start, 0);
|
|
57
|
+
width: calc(
|
|
58
|
+
var(--bx-slider-thumb-size, #{spacing(6)}) / 2 + var(--bx-slider-position, 0.5) *
|
|
59
|
+
(var(--bx-slider-track-width, 100%) - var(--bx-slider-thumb-size, #{spacing(6)}))
|
|
60
|
+
);
|
|
61
|
+
height: spacing(2);
|
|
62
|
+
transform: translateY(-50%);
|
|
63
|
+
border-radius: radius(pill);
|
|
64
|
+
background: var(--bx-accent);
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
z-index: 1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&:dir(rtl)::before {
|
|
70
|
+
left: auto;
|
|
71
|
+
right: var(--bx-slider-track-start, 0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
input.bx-slider::-webkit-slider-runnable-track {
|
|
75
|
+
background: var(--bx-bg-neutral);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
input.bx-slider::-moz-range-track {
|
|
79
|
+
background: var(--bx-bg-neutral);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// The native thumb remains the hit target; the decorative lens paints over it.
|
|
54
83
|
input.bx-slider::-webkit-slider-thumb {
|
|
55
84
|
background: transparent;
|
|
56
85
|
border-color: transparent;
|
|
@@ -73,11 +102,41 @@
|
|
|
73
102
|
position: absolute;
|
|
74
103
|
top: var(--bx-slider-center-y, 50%);
|
|
75
104
|
left: calc(
|
|
76
|
-
var(--bx-slider-track-start, 0px) +
|
|
77
|
-
|
|
105
|
+
var(--bx-slider-track-start, 0px) +
|
|
106
|
+
var(--bx-slider-physical-position, var(--bx-slider-position, 0.5)) *
|
|
107
|
+
(var(--bx-slider-track-width, 100%) - var(--bx-slider-thumb-size, #{spacing(6)}))
|
|
78
108
|
);
|
|
79
109
|
transform: translateY(-50%);
|
|
80
110
|
pointer-events: none;
|
|
111
|
+
z-index: 2;
|
|
112
|
+
overflow: hidden;
|
|
113
|
+
background:
|
|
114
|
+
radial-gradient(circle at 35% 0%, rgb(255 255 255 / 45%), transparent 65%),
|
|
115
|
+
color-mix(in srgb, var(--bx-bg-surface) 24%, transparent);
|
|
116
|
+
border-color: color-mix(in srgb, var(--bx-text-primary) 35%, var(--bx-border-strong));
|
|
117
|
+
backdrop-filter: blur(var(--bx-slider-lens-blur, 1.5px));
|
|
118
|
+
|
|
119
|
+
--bx-slider-lens-width: calc(
|
|
120
|
+
var(--bx-slider-track-width) * var(--bx-slider-magnification, 1.5)
|
|
121
|
+
);
|
|
122
|
+
--bx-slider-lens-inset: calc(
|
|
123
|
+
var(--bx-slider-thumb-size, #{spacing(6)}) / 2 * var(--bx-slider-magnification, 1.5)
|
|
124
|
+
);
|
|
125
|
+
--bx-slider-lens-travel: calc(
|
|
126
|
+
(var(--bx-slider-track-width) - var(--bx-slider-thumb-size, #{spacing(6)})) *
|
|
127
|
+
var(--bx-slider-magnification, 1.5)
|
|
128
|
+
);
|
|
129
|
+
--bx-slider-lens-start-offset: calc(
|
|
130
|
+
var(--bx-slider-lens-inset) + var(--bx-slider-lens-start, 0) * var(--bx-slider-lens-travel)
|
|
131
|
+
);
|
|
132
|
+
--bx-slider-lens-end-offset: calc(
|
|
133
|
+
var(--bx-slider-lens-inset) + var(--bx-slider-lens-end, var(--bx-slider-position, 0.5)) *
|
|
134
|
+
var(--bx-slider-lens-travel)
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
&:dir(rtl) {
|
|
138
|
+
--bx-slider-physical-position: calc(1 - var(--bx-slider-position, 0.5));
|
|
139
|
+
}
|
|
81
140
|
|
|
82
141
|
&::after {
|
|
83
142
|
@include bx-transition(opacity, 0.2s, ease-out);
|
|
@@ -101,6 +160,38 @@
|
|
|
101
160
|
}
|
|
102
161
|
}
|
|
103
162
|
|
|
163
|
+
// Reuse the rail geometry in CSS instead of sampling screen pixels on drag.
|
|
164
|
+
// A separate rounded fill keeps the magnified selection's end caps curved.
|
|
165
|
+
.bx-slider-lens {
|
|
166
|
+
display: var(--bx-slider-lens-display, block);
|
|
167
|
+
position: absolute;
|
|
168
|
+
top: 50%;
|
|
169
|
+
left: calc(
|
|
170
|
+
var(--bx-slider-thumb-size, #{spacing(6)}) / 2 -
|
|
171
|
+
1px - var(--bx-slider-lens-inset) - var(
|
|
172
|
+
--bx-slider-physical-position,
|
|
173
|
+
var(--bx-slider-position, 0.5)
|
|
174
|
+
) *
|
|
175
|
+
var(--bx-slider-lens-travel)
|
|
176
|
+
);
|
|
177
|
+
width: var(--bx-slider-lens-width);
|
|
178
|
+
height: calc(#{spacing(2)} * var(--bx-slider-magnification, 1.5));
|
|
179
|
+
transform: translateY(-50%);
|
|
180
|
+
border-radius: radius(pill);
|
|
181
|
+
background: var(--bx-slider-lens-track-color, var(--bx-bg-neutral));
|
|
182
|
+
filter: blur(var(--bx-slider-lens-blur, 1.5px));
|
|
183
|
+
|
|
184
|
+
&::after {
|
|
185
|
+
content: '';
|
|
186
|
+
position: absolute;
|
|
187
|
+
inset-block: 0;
|
|
188
|
+
inset-inline: var(--bx-slider-lens-start-offset)
|
|
189
|
+
calc(var(--bx-slider-lens-width) - var(--bx-slider-lens-end-offset));
|
|
190
|
+
background: var(--bx-accent);
|
|
191
|
+
border-radius: inherit;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
104
195
|
input.bx-slider {
|
|
105
196
|
appearance: none;
|
|
106
197
|
width: 100%;
|
|
@@ -127,7 +218,7 @@ input.bx-slider {
|
|
|
127
218
|
&::-webkit-slider-thumb {
|
|
128
219
|
@include thumb;
|
|
129
220
|
|
|
130
|
-
margin-top: calc((#{spacing(2)} - #{spacing(6)}) / 2 - 1px);
|
|
221
|
+
margin-top: calc((#{spacing(2)} - var(--bx-slider-thumb-size, #{spacing(6)})) / 2 - 1px);
|
|
131
222
|
}
|
|
132
223
|
|
|
133
224
|
&::-moz-range-thumb {
|
|
@@ -140,6 +231,10 @@ input.bx-slider {
|
|
|
140
231
|
border-radius: radius(pill);
|
|
141
232
|
}
|
|
142
233
|
|
|
234
|
+
&[readonly] {
|
|
235
|
+
cursor: default;
|
|
236
|
+
}
|
|
237
|
+
|
|
143
238
|
&:disabled {
|
|
144
239
|
opacity: 0.5;
|
|
145
240
|
cursor: not-allowed;
|
|
@@ -147,6 +242,8 @@ input.bx-slider {
|
|
|
147
242
|
}
|
|
148
243
|
|
|
149
244
|
@mixin opaque-thumb {
|
|
245
|
+
--bx-slider-lens-display: none;
|
|
246
|
+
|
|
150
247
|
background: var(--bx-bg-surface);
|
|
151
248
|
backdrop-filter: none;
|
|
152
249
|
}
|
|
@@ -217,3 +314,14 @@ input.bx-slider {
|
|
|
217
314
|
box-shadow: none;
|
|
218
315
|
}
|
|
219
316
|
}
|
|
317
|
+
|
|
318
|
+
.bx-slider-value-label {
|
|
319
|
+
display: block;
|
|
320
|
+
color: var(--bx-text-secondary);
|
|
321
|
+
font-size: 0.75rem;
|
|
322
|
+
text-align: center;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.bx-slider-value-label[hidden] {
|
|
326
|
+
display: none;
|
|
327
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@use 'field-state' as *;
|
|
2
|
+
@use 'mixins' as *;
|
|
2
3
|
|
|
3
4
|
// A projected surface inside a form field receives the complete field material,
|
|
4
5
|
// including its valid focus state, without application-specific effects CSS.
|
|
@@ -20,3 +21,50 @@
|
|
|
20
21
|
outline-color: Mark;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
.bx-native-control {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
inline-size: 100%;
|
|
28
|
+
padding: spacing(3);
|
|
29
|
+
border: 1px solid var(--bx-border-strong);
|
|
30
|
+
border-radius: radius(sm);
|
|
31
|
+
background: var(--bx-bg-neutral);
|
|
32
|
+
color: var(--bx-text-primary);
|
|
33
|
+
font: inherit;
|
|
34
|
+
|
|
35
|
+
&:focus-visible:not([readonly], [aria-readonly='true']),
|
|
36
|
+
&.is-keyboard-focused:focus-visible {
|
|
37
|
+
outline: 2px solid var(--bx-border-brand);
|
|
38
|
+
outline-offset: 2px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&:disabled {
|
|
42
|
+
opacity: 0.6;
|
|
43
|
+
cursor: not-allowed;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&[readonly]:not(:disabled) {
|
|
47
|
+
cursor: default;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&[aria-invalid='true'] {
|
|
51
|
+
border-color: var(--bx-border-danger);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.bx-field-prefix,
|
|
56
|
+
.bx-field-suffix {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
flex: 0 0 auto;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.bx-field-prefix {
|
|
63
|
+
padding-inline: var(--bx-field-adornment-padding, #{spacing(3)})
|
|
64
|
+
var(--bx-field-adornment-gap, #{spacing(2)});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.bx-field-suffix {
|
|
68
|
+
padding-inline: var(--bx-field-adornment-gap, #{spacing(2)})
|
|
69
|
+
var(--bx-field-adornment-padding, #{spacing(3)});
|
|
70
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { DOCUMENT, DestroyRef, Directive, Injectable, InjectionToken, NgZone, PLATFORM_ID, computed, effect, inject, input, isDevMode, signal } from "@angular/core";
|
|
2
|
+
import { DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, NgZone, PLATFORM_ID, afterNextRender, booleanAttribute, computed, effect, inject, input, isDevMode, signal } from "@angular/core";
|
|
3
3
|
import { DOCUMENT as DOCUMENT$1, isPlatformBrowser } from "@angular/common";
|
|
4
4
|
import { fromEvent } from "rxjs";
|
|
5
5
|
import { debounceTime, distinctUntilChanged, map } from "rxjs/operators";
|
|
6
|
-
import { toObservable } from "@angular/core/rxjs-interop";
|
|
6
|
+
import { takeUntilDestroyed, toObservable } from "@angular/core/rxjs-interop";
|
|
7
7
|
import { configureAppearance } from "@filip.mazev/blocks/effects/runtime";
|
|
8
8
|
import { ConnectionPositionPair, FlexibleConnectedPositionStrategy, Overlay } from "@angular/cdk/overlay";
|
|
9
|
+
import { FocusMonitor } from "@angular/cdk/a11y";
|
|
9
10
|
import { NgControl, Validators } from "@angular/forms";
|
|
10
11
|
var DesktopOS;
|
|
11
12
|
(function(DesktopOS) {
|
|
@@ -753,14 +754,13 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
753
754
|
}]
|
|
754
755
|
});
|
|
755
756
|
var BxBaseControl = class BxBaseControl {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
return control?.hasValidator ? control.hasValidator(Validators.required) : false;
|
|
760
|
-
}, ...ngDevMode ? [{ debugName: "isFieldRequired" }] : /* istanbul ignore next */ []);
|
|
757
|
+
focusMonitor = inject(FocusMonitor);
|
|
758
|
+
focusElement = inject(ElementRef).nativeElement;
|
|
759
|
+
destroyRef = inject(DestroyRef);
|
|
761
760
|
internalValue = signal(null, ...ngDevMode ? [{ debugName: "internalValue" }] : /* istanbul ignore next */ []);
|
|
762
761
|
isTouched = signal(false, ...ngDevMode ? [{ debugName: "isTouched" }] : /* istanbul ignore next */ []);
|
|
763
762
|
isDisabled = signal(false, ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
|
|
763
|
+
keyboardFocused = signal(false, ...ngDevMode ? [{ debugName: "keyboardFocused" }] : /* istanbul ignore next */ []);
|
|
764
764
|
ngControl = inject(NgControl, {
|
|
765
765
|
optional: true,
|
|
766
766
|
self: true
|
|
@@ -772,18 +772,31 @@ var BxBaseControl = class BxBaseControl {
|
|
|
772
772
|
ariaLabel = input(void 0, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
773
773
|
errorMessages = input({}, ...ngDevMode ? [{ debugName: "errorMessages" }] : /* istanbul ignore next */ []);
|
|
774
774
|
required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
775
|
+
readonly = input(false, {
|
|
776
|
+
...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
|
|
777
|
+
transform: booleanAttribute
|
|
778
|
+
});
|
|
779
|
+
readOnly = input(false, {
|
|
780
|
+
...ngDevMode ? { debugName: "readOnly" } : /* istanbul ignore next */ {},
|
|
781
|
+
transform: booleanAttribute
|
|
782
|
+
});
|
|
783
|
+
isReadonly = computed(() => this.readonly() || this.readOnly(), ...ngDevMode ? [{ debugName: "isReadonly" }] : /* istanbul ignore next */ []);
|
|
775
784
|
loading = input(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
|
|
776
785
|
disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
777
786
|
onChange = () => {};
|
|
778
787
|
onTouched = () => {};
|
|
779
788
|
constructor() {
|
|
789
|
+
afterNextRender(() => {
|
|
790
|
+
this.focusMonitor.monitor(this.focusElement, true).pipe(takeUntilDestroyed(this.destroyRef)).subscribe((origin) => this.keyboardFocused.set(origin === "keyboard"));
|
|
791
|
+
this.destroyRef.onDestroy(() => this.focusMonitor.stopMonitoring(this.focusElement));
|
|
792
|
+
});
|
|
793
|
+
effect(() => {
|
|
794
|
+
this.isDisabled.set(this.disabled() || this.ngControl?.disabled === true);
|
|
795
|
+
});
|
|
780
796
|
if (this.ngControl) this.ngControl.valueAccessor = this;
|
|
781
797
|
}
|
|
782
798
|
ngOnInit() {
|
|
783
799
|
this.isDisabled.set(this.disabled() || this.ngControl?.disabled === true);
|
|
784
|
-
if (isDevMode() && this.ngControl?.control?.validator) {
|
|
785
|
-
if (!(Object.keys(this.errorMessages()).length > 0)) console.error(`[Blocks UI Strict Mode] The form control for this field has validators, but the [errorMessages] input is empty. You must provide error messages for all applied validators.`);
|
|
786
|
-
}
|
|
787
800
|
}
|
|
788
801
|
writeValue(value) {
|
|
789
802
|
this.internalValue.set(value);
|
|
@@ -798,15 +811,20 @@ var BxBaseControl = class BxBaseControl {
|
|
|
798
811
|
this.isDisabled.set(isDisabled);
|
|
799
812
|
}
|
|
800
813
|
updateValue(value) {
|
|
801
|
-
if (this.isDisabled()) return;
|
|
814
|
+
if (this.isDisabled() || this.isReadonly()) return;
|
|
802
815
|
this.internalValue.set(value);
|
|
803
816
|
this.onChange(value);
|
|
804
817
|
}
|
|
805
818
|
markAsTouched() {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
819
|
+
this.isTouched.set(true);
|
|
820
|
+
this.onTouched();
|
|
821
|
+
}
|
|
822
|
+
onControlPointerDown() {
|
|
823
|
+
if (this.isReadonly()) this.keyboardFocused.set(false);
|
|
824
|
+
}
|
|
825
|
+
isFieldRequired() {
|
|
826
|
+
const control = this.ngControl?.control;
|
|
827
|
+
return this.required() || !!control?.hasValidator?.(Validators.required) || !!control?.hasValidator?.(Validators.requiredTrue);
|
|
810
828
|
}
|
|
811
829
|
get errorMessage() {
|
|
812
830
|
if (this.ngControl?.invalid && (this.ngControl.touched || this.ngControl.dirty)) {
|
|
@@ -815,7 +833,9 @@ var BxBaseControl = class BxBaseControl {
|
|
|
815
833
|
const firstKey = Object.keys(errors)[0];
|
|
816
834
|
const customErrorMap = this.errorMessages();
|
|
817
835
|
if (customErrorMap && customErrorMap[firstKey]) return customErrorMap[firstKey];
|
|
818
|
-
|
|
836
|
+
const error = errors[firstKey];
|
|
837
|
+
if (typeof error === "string") return error;
|
|
838
|
+
if (error && typeof error === "object" && "message" in error && typeof error.message === "string") return error.message;
|
|
819
839
|
if (isDevMode()) console.error(`[Blocks UI Strict Mode] Validation failed for key '${firstKey}', but no message was provided in [errorMessages].`);
|
|
820
840
|
return `[Missing error message: ${firstKey}]`;
|
|
821
841
|
}
|
|
@@ -883,6 +903,20 @@ var BxBaseControl = class BxBaseControl {
|
|
|
883
903
|
isRequired: false,
|
|
884
904
|
transformFunction: null
|
|
885
905
|
},
|
|
906
|
+
readonly: {
|
|
907
|
+
classPropertyName: "readonly",
|
|
908
|
+
publicName: "readonly",
|
|
909
|
+
isSignal: true,
|
|
910
|
+
isRequired: false,
|
|
911
|
+
transformFunction: null
|
|
912
|
+
},
|
|
913
|
+
readOnly: {
|
|
914
|
+
classPropertyName: "readOnly",
|
|
915
|
+
publicName: "readOnly",
|
|
916
|
+
isSignal: true,
|
|
917
|
+
isRequired: false,
|
|
918
|
+
transformFunction: null
|
|
919
|
+
},
|
|
886
920
|
loading: {
|
|
887
921
|
classPropertyName: "loading",
|
|
888
922
|
publicName: "loading",
|
|
@@ -898,6 +932,10 @@ var BxBaseControl = class BxBaseControl {
|
|
|
898
932
|
transformFunction: null
|
|
899
933
|
}
|
|
900
934
|
},
|
|
935
|
+
host: {
|
|
936
|
+
listeners: { "pointerdown": "onControlPointerDown()" },
|
|
937
|
+
properties: { "class.bx-readonly": "isReadonly()" }
|
|
938
|
+
},
|
|
901
939
|
ngImport: i0
|
|
902
940
|
});
|
|
903
941
|
};
|
|
@@ -906,7 +944,13 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
906
944
|
version: "22.2.3",
|
|
907
945
|
ngImport: i0,
|
|
908
946
|
type: BxBaseControl,
|
|
909
|
-
decorators: [{
|
|
947
|
+
decorators: [{
|
|
948
|
+
type: Directive,
|
|
949
|
+
args: [{ host: {
|
|
950
|
+
"[class.bx-readonly]": "isReadonly()",
|
|
951
|
+
"(pointerdown)": "onControlPointerDown()"
|
|
952
|
+
} }]
|
|
953
|
+
}],
|
|
910
954
|
ctorParameters: () => [],
|
|
911
955
|
propDecorators: {
|
|
912
956
|
label: [{
|
|
@@ -965,6 +1009,22 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
965
1009
|
required: false
|
|
966
1010
|
}]
|
|
967
1011
|
}],
|
|
1012
|
+
readonly: [{
|
|
1013
|
+
type: i0.Input,
|
|
1014
|
+
args: [{
|
|
1015
|
+
isSignal: true,
|
|
1016
|
+
alias: "readonly",
|
|
1017
|
+
required: false
|
|
1018
|
+
}]
|
|
1019
|
+
}],
|
|
1020
|
+
readOnly: [{
|
|
1021
|
+
type: i0.Input,
|
|
1022
|
+
args: [{
|
|
1023
|
+
isSignal: true,
|
|
1024
|
+
alias: "readOnly",
|
|
1025
|
+
required: false
|
|
1026
|
+
}]
|
|
1027
|
+
}],
|
|
968
1028
|
loading: [{
|
|
969
1029
|
type: i0.Input,
|
|
970
1030
|
args: [{
|
|
@@ -1271,6 +1331,11 @@ function trackOverlayOrigin(overlay, origin) {
|
|
|
1271
1331
|
host.classList.remove("bx-overlay-tracked");
|
|
1272
1332
|
};
|
|
1273
1333
|
}
|
|
1274
|
-
|
|
1334
|
+
function resolveText(text, adapter, params) {
|
|
1335
|
+
adapter?.version?.();
|
|
1336
|
+
if (text === void 0) return "";
|
|
1337
|
+
return isTextWithKey(text) ? adapter?.translate(text.key, params) ?? text.key : text;
|
|
1338
|
+
}
|
|
1339
|
+
export { BREAKPOINTS, BX_I18N, BxA11yService, BxBaseControl, BxOverlayPositionService, BxShortcutService, DEFAULT_APPEARANCE_CONFIG, DEFAULT_DEBOUNCE_TIME, DesktopOS, DeviceTypeService, FALLBACK_COLOR, MobileOS, PALETTE_NAMES, SCROLL_LOCK_INSTANCE_IDENTIFIER, SEMANTIC_PAIRS, SHADE_NUMBERS, ScrollLockService, THEME_PALETTES, TOKEN_COLOR_DELIMITER, TOKEN_DELIMITER, TOKEN_PREFIX, ThemingService, WindowDimensionsService, getComplementaryToken, inheritOverlayTheme, invertPaletteToken, isOSShortcut, isPaletteToken, isTextWithKey, isThemedColor, resolveText, resolveThemeId, resolveTokenToCssVar, trackOverlayOrigin, uuidv4 };
|
|
1275
1340
|
|
|
1276
1341
|
//# sourceMappingURL=filip.mazev-blocks-core.mjs.map
|