@ojiepermana/angular 22.2.11 → 22.2.14
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/ojiepermana-angular-chart-area.mjs +3 -3
- package/fesm2022/ojiepermana-angular-chart-bar.mjs +3 -3
- package/fesm2022/ojiepermana-angular-chart-core.mjs +34 -34
- package/fesm2022/ojiepermana-angular-chart-line.mjs +3 -3
- package/fesm2022/ojiepermana-angular-chart-pie.mjs +3 -3
- package/fesm2022/ojiepermana-angular-chart-primitives.mjs +33 -33
- package/fesm2022/ojiepermana-angular-chart-radar.mjs +3 -3
- package/fesm2022/ojiepermana-angular-chart-radial.mjs +3 -3
- package/fesm2022/ojiepermana-angular-chart-scatter.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-accordion.mjs +15 -15
- package/fesm2022/ojiepermana-angular-component-alert-dialog.mjs +27 -27
- package/fesm2022/ojiepermana-angular-component-alert.mjs +12 -12
- package/fesm2022/ojiepermana-angular-component-aspect-ratio.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-avatar.mjs +18 -18
- package/fesm2022/ojiepermana-angular-component-badge.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-breadcrumb.mjs +21 -21
- package/fesm2022/ojiepermana-angular-component-button-group.mjs +9 -9
- package/fesm2022/ojiepermana-angular-component-button.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-calendar.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-card.mjs +21 -21
- package/fesm2022/ojiepermana-angular-component-carousel.mjs +18 -18
- package/fesm2022/ojiepermana-angular-component-checkbox.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-collapsible.mjs +12 -12
- package/fesm2022/ojiepermana-angular-component-combobox.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-command.mjs +27 -27
- package/fesm2022/ojiepermana-angular-component-composer.mjs +21 -21
- package/fesm2022/ojiepermana-angular-component-context-menu.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-date-picker.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-dialog.mjs +21 -21
- package/fesm2022/ojiepermana-angular-component-dropdown-menu.mjs +39 -39
- package/fesm2022/ojiepermana-angular-component-editor.mjs +18 -18
- package/fesm2022/ojiepermana-angular-component-empty.mjs +18 -18
- package/fesm2022/ojiepermana-angular-component-form.mjs +36 -36
- package/fesm2022/ojiepermana-angular-component-hover-card.mjs +9 -9
- package/fesm2022/ojiepermana-angular-component-icon.mjs +6 -6
- package/fesm2022/ojiepermana-angular-component-input-group.mjs +18 -18
- package/fesm2022/ojiepermana-angular-component-input-otp.mjs +15 -15
- package/fesm2022/ojiepermana-angular-component-input.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-item.mjs +30 -30
- package/fesm2022/ojiepermana-angular-component-kanban.mjs +27 -27
- package/fesm2022/ojiepermana-angular-component-kbd.mjs +6 -6
- package/fesm2022/ojiepermana-angular-component-label.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-menubar.mjs +12 -12
- package/fesm2022/ojiepermana-angular-component-native-select.mjs +9 -9
- package/fesm2022/ojiepermana-angular-component-navigation-menu.mjs +21 -21
- package/fesm2022/ojiepermana-angular-component-pagination.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-pillbox.mjs +15 -15
- package/fesm2022/ojiepermana-angular-component-popover.mjs +6 -6
- package/fesm2022/ojiepermana-angular-component-progress.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-radio.mjs +6 -6
- package/fesm2022/ojiepermana-angular-component-resizable.mjs +12 -12
- package/fesm2022/ojiepermana-angular-component-scroll-area.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-segmented-control.mjs +9 -7
- package/fesm2022/ojiepermana-angular-component-select.mjs +6 -6
- package/fesm2022/ojiepermana-angular-component-separator.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-sheet.mjs +21 -21
- package/fesm2022/ojiepermana-angular-component-skeleton.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-slider.mjs +6 -6
- package/fesm2022/ojiepermana-angular-component-spinner.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-switch.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-table.mjs +24 -24
- package/fesm2022/ojiepermana-angular-component-tabs.mjs +18 -18
- package/fesm2022/ojiepermana-angular-component-textarea.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-timeline.mjs +18 -18
- package/fesm2022/ojiepermana-angular-component-toast.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-toggle-group.mjs +9 -9
- package/fesm2022/ojiepermana-angular-component-toggle.mjs +3 -3
- package/fesm2022/ojiepermana-angular-component-tooltip.mjs +15 -15
- package/fesm2022/ojiepermana-angular-component-utils-core.mjs +420 -4
- package/fesm2022/ojiepermana-angular-component-utils-scale.mjs +3 -3
- package/fesm2022/ojiepermana-angular-navigation-icon.mjs +3 -3
- package/fesm2022/{ojiepermana-angular-navigation-navigation-badge-count.component-BxWVj145.mjs → ojiepermana-angular-navigation-navigation-badge-count.component-Bx89vXtg.mjs} +3 -3
- package/fesm2022/{ojiepermana-angular-navigation-navigation-dockbar-menu.component-Q6Ef4ut3.mjs → ojiepermana-angular-navigation-navigation-dockbar-menu.component-B2o_omfJ.mjs} +30 -7
- package/fesm2022/{ojiepermana-angular-navigation-navigation-entry-grid.component-XxQv3yxu.mjs → ojiepermana-angular-navigation-navigation-entry-grid.component-CJGBKA8c.mjs} +60 -21
- package/fesm2022/{ojiepermana-angular-navigation-navigation-flyout-menu.component-BBz0IwXv.mjs → ojiepermana-angular-navigation-navigation-flyout-menu.component-CHVjP7ew.mjs} +9 -7
- package/fesm2022/{ojiepermana-angular-navigation-navigation-horizontal.component-aFxLw5XV.mjs → ojiepermana-angular-navigation-navigation-horizontal.component-znRwi38r.mjs} +10 -8
- package/fesm2022/{ojiepermana-angular-navigation-navigation-item.component-DlazoaD2.mjs → ojiepermana-angular-navigation-navigation-item.component-CIy9MVBy.mjs} +182 -55
- package/fesm2022/{ojiepermana-angular-navigation-navigation-list.component-Cgj0SLHr.mjs → ojiepermana-angular-navigation-navigation-list.component-BIQM2uf1.mjs} +24 -4
- package/fesm2022/ojiepermana-angular-navigation-service.mjs +7 -7
- package/fesm2022/ojiepermana-angular-navigation.mjs +90 -66
- package/fesm2022/ojiepermana-angular-theme-component-settings.mjs +88 -23
- package/fesm2022/ojiepermana-angular-theme-layout-services.mjs +7 -7
- package/fesm2022/ojiepermana-angular-theme-layout-wrapper.mjs +54 -30
- package/fesm2022/ojiepermana-angular-theme-layout.mjs +26 -29
- package/fesm2022/ojiepermana-angular-theme-on-fill.mjs +3 -3
- package/fesm2022/ojiepermana-angular-theme-page-core.mjs +3 -3
- package/fesm2022/ojiepermana-angular-theme-page-filter.mjs +6 -6
- package/fesm2022/ojiepermana-angular-theme-page-overview.mjs +3 -3
- package/fesm2022/ojiepermana-angular-theme-page-root.mjs +4 -3
- package/fesm2022/ojiepermana-angular-theme-page-side.mjs +6 -6
- package/fesm2022/ojiepermana-angular-theme-page-slots.mjs +12 -12
- package/fesm2022/ojiepermana-angular-theme-shell-services.mjs +4 -4
- package/fesm2022/ojiepermana-angular-theme-shell.mjs +10 -9
- package/fesm2022/ojiepermana-angular-theme-styles.mjs +109 -178
- package/navigation/README.md +32 -2
- package/package.json +2 -2
- package/theme/component/settings/README.md +15 -0
- package/theme/styles/README.md +71 -1
- package/theme/styles/css/base/components.css +29 -75
- package/theme/styles/css/base/theme.css +3 -3
- package/theme/styles/css/base/tokens.css +8 -0
- package/types/ojiepermana-angular-component-segmented-control.d.ts +3 -3
- package/types/ojiepermana-angular-component-utils-core.d.ts +147 -3
- package/types/ojiepermana-angular-navigation-types.d.ts +2 -0
- package/types/ojiepermana-angular-navigation.d.ts +8 -1
- package/types/ojiepermana-angular-theme-component-settings.d.ts +9 -1
- package/types/ojiepermana-angular-theme-layout-wrapper.d.ts +8 -1
- package/types/ojiepermana-angular-theme-layout.d.ts +0 -1
- package/types/ojiepermana-angular-theme-styles.d.ts +30 -26
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { DOCUMENT } from "@angular/common";
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
|
-
import { DestroyRef, InjectionToken, Service, computed, effect, inject, makeEnvironmentProviders, provideEnvironmentInitializer, signal } from "@angular/core";
|
|
4
|
-
import { documentLocalStorage } from "@ojiepermana/angular/component/utils/core";
|
|
3
|
+
import { DestroyRef, EnvironmentInjector, InjectionToken, Service, computed, effect, inject, makeEnvironmentProviders, provideAppInitializer, provideEnvironmentInitializer, runInInjectionContext, signal } from "@angular/core";
|
|
4
|
+
import { NON_TEXT_CONTRAST_MIN, ON_FILL_INK, StorageCoordinator, TEXT_CONTRAST_MIN, contrastRatio, documentLocalStorage, foregroundFor, foregroundFor as foregroundFor$1, formatHslTriplet, hexToHslTriplet, parseHslTriplet, registerStorageRoot, solveLightnessNearest, storageCoordinator } from "@ojiepermana/angular/component/utils/core";
|
|
5
5
|
function persistedSignal(options) {
|
|
6
6
|
const documentRef = options.documentRef !== void 0 ? options.documentRef : inject(DOCUMENT, { optional: true });
|
|
7
|
-
const storage = documentLocalStorage(documentRef);
|
|
7
|
+
const storage = documentLocalStorage(documentRef, inject(DestroyRef));
|
|
8
8
|
const state = signal(options.parse(storage.read(options.key)), ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
|
|
9
|
+
const unsubscribe = storageCoordinator(documentRef)?.onInvalidation(() => state.set(options.parse(null)));
|
|
10
|
+
if (unsubscribe) inject(DestroyRef).onDestroy(unsubscribe);
|
|
9
11
|
effect(() => {
|
|
10
12
|
const serialized = options.serialize(state());
|
|
11
13
|
if (serialized === null) storage.remove(options.key);
|
|
@@ -68,150 +70,6 @@ function prefersDarkSignal(documentRef) {
|
|
|
68
70
|
}
|
|
69
71
|
return state.asReadonly();
|
|
70
72
|
}
|
|
71
|
-
const TEXT_CONTRAST_MIN = 4.5;
|
|
72
|
-
const NUMBER = String.raw`[+-]?(?:\d+(?:\.\d+)?|\.\d+)`;
|
|
73
|
-
const SEPARATOR = String.raw`(?:\s*,\s*|\s+)`;
|
|
74
|
-
const HSL_TRIPLET = new RegExp(`^\\s*(${NUMBER})(deg|grad|rad|turn)?${SEPARATOR}(${NUMBER})%${SEPARATOR}(${NUMBER})%\\s*$`, "i");
|
|
75
|
-
const HEX_COLOR = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
76
|
-
const DEGREES_PER_UNIT = {
|
|
77
|
-
deg: 1,
|
|
78
|
-
grad: .9,
|
|
79
|
-
rad: 180 / Math.PI,
|
|
80
|
-
turn: 360
|
|
81
|
-
};
|
|
82
|
-
const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
83
|
-
const normalizeHue = (hue) => (hue % 360 + 360) % 360;
|
|
84
|
-
function parseHslTriplet(value) {
|
|
85
|
-
const match = HSL_TRIPLET.exec(value);
|
|
86
|
-
if (!match) return null;
|
|
87
|
-
const [h, s, l] = [
|
|
88
|
-
Number(match[1]),
|
|
89
|
-
Number(match[3]),
|
|
90
|
-
Number(match[4])
|
|
91
|
-
];
|
|
92
|
-
if (![
|
|
93
|
-
h,
|
|
94
|
-
s,
|
|
95
|
-
l
|
|
96
|
-
].every(Number.isFinite)) return null;
|
|
97
|
-
return {
|
|
98
|
-
h: normalizeHue(h * DEGREES_PER_UNIT[match[2]?.toLowerCase() ?? "deg"]),
|
|
99
|
-
s,
|
|
100
|
-
l
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function formatHslTriplet({ h, s, l }) {
|
|
104
|
-
return `${h} ${clamp(Math.round(s), 0, 100)}% ${clamp(Math.round(l), 0, 100)}%`;
|
|
105
|
-
}
|
|
106
|
-
function hexToHslTriplet(value) {
|
|
107
|
-
const exact = hexToHsl(value);
|
|
108
|
-
return exact ? formatHslTriplet({
|
|
109
|
-
h: Math.round(exact.h),
|
|
110
|
-
s: exact.s,
|
|
111
|
-
l: exact.l
|
|
112
|
-
}) : null;
|
|
113
|
-
}
|
|
114
|
-
function hexToHsl(value) {
|
|
115
|
-
const match = HEX_COLOR.exec(value.trim());
|
|
116
|
-
if (!match) return null;
|
|
117
|
-
const digits = match[1];
|
|
118
|
-
const expanded = digits.length === 3 ? digits.split("").map((digit) => digit + digit).join("") : digits;
|
|
119
|
-
const [red, green, blue] = [
|
|
120
|
-
0,
|
|
121
|
-
2,
|
|
122
|
-
4
|
|
123
|
-
].map((offset) => Number.parseInt(expanded.slice(offset, offset + 2), 16) / 255);
|
|
124
|
-
const largest = Math.max(red, green, blue);
|
|
125
|
-
const smallest = Math.min(red, green, blue);
|
|
126
|
-
const delta = largest - smallest;
|
|
127
|
-
const lightness = (largest + smallest) / 2;
|
|
128
|
-
let hue = 0;
|
|
129
|
-
if (delta !== 0) {
|
|
130
|
-
if (largest === red) hue = 60 * (((green - blue) / delta + 6) % 6);
|
|
131
|
-
else if (largest === green) hue = 60 * ((blue - red) / delta + 2);
|
|
132
|
-
else hue = 60 * ((red - green) / delta + 4);
|
|
133
|
-
}
|
|
134
|
-
const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));
|
|
135
|
-
return {
|
|
136
|
-
h: hue,
|
|
137
|
-
s: saturation * 100,
|
|
138
|
-
l: lightness * 100
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function hslToRgb({ h, s, l }) {
|
|
142
|
-
const saturation = clamp(s, 0, 100) / 100;
|
|
143
|
-
const lightness = clamp(l, 0, 100) / 100;
|
|
144
|
-
const k = (n) => (n + h / 30) % 12;
|
|
145
|
-
const a = saturation * Math.min(lightness, 1 - lightness);
|
|
146
|
-
const channel = (n) => lightness - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
147
|
-
return [
|
|
148
|
-
channel(0),
|
|
149
|
-
channel(8),
|
|
150
|
-
channel(4)
|
|
151
|
-
];
|
|
152
|
-
}
|
|
153
|
-
const toLinear = (channel) => channel <= .03928 ? channel / 12.92 : Math.pow((channel + .055) / 1.055, 2.4);
|
|
154
|
-
const toPainted = (channel) => Math.round(clamp(channel, 0, 1) * 255) / 255;
|
|
155
|
-
function relativeLuminance(triplet) {
|
|
156
|
-
const parsed = parseHslTriplet(triplet);
|
|
157
|
-
if (!parsed) return 0;
|
|
158
|
-
const [r, g, b] = hslToRgb(parsed).map(toPainted);
|
|
159
|
-
return .2126 * toLinear(r) + .7152 * toLinear(g) + .0722 * toLinear(b);
|
|
160
|
-
}
|
|
161
|
-
function contrastRatio(a, b) {
|
|
162
|
-
const ya = relativeLuminance(a);
|
|
163
|
-
const yb = relativeLuminance(b);
|
|
164
|
-
return (Math.max(ya, yb) + .05) / (Math.min(ya, yb) + .05);
|
|
165
|
-
}
|
|
166
|
-
function solveLightnessNearest(options) {
|
|
167
|
-
const target = options.min + (options.margin ?? .02);
|
|
168
|
-
const start = Math.round(clamp(options.from, 0, 100));
|
|
169
|
-
for (let delta = 0; delta <= 100; delta += 1) for (const candidate of delta === 0 ? [start] : [start - delta, start + delta]) {
|
|
170
|
-
if (candidate < 0 || candidate > 100) continue;
|
|
171
|
-
const triplet = formatHslTriplet({
|
|
172
|
-
h: options.h,
|
|
173
|
-
s: options.s,
|
|
174
|
-
l: candidate
|
|
175
|
-
});
|
|
176
|
-
if (options.against.every((background) => contrastRatio(triplet, background) >= target)) return triplet;
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
const ON_FILL_INK = Object.freeze({
|
|
181
|
-
light: "0 0% 12%",
|
|
182
|
-
dark: "0 0% 10%"
|
|
183
|
-
});
|
|
184
|
-
const ON_FILL_WHITE = "0 0% 100%";
|
|
185
|
-
function pickFillForeground(fill, dark, min = TEXT_CONTRAST_MIN) {
|
|
186
|
-
const lightRatio = contrastRatio(ON_FILL_WHITE, fill);
|
|
187
|
-
const darkRatio = contrastRatio(dark, fill);
|
|
188
|
-
const preferred = lightRatio >= darkRatio ? ON_FILL_WHITE : dark;
|
|
189
|
-
if (Math.max(lightRatio, darkRatio) >= min) return preferred;
|
|
190
|
-
const ink = parseHslTriplet(dark);
|
|
191
|
-
return solveLightnessNearest({
|
|
192
|
-
h: ink.h,
|
|
193
|
-
s: ink.s,
|
|
194
|
-
against: [fill],
|
|
195
|
-
min,
|
|
196
|
-
from: ink.l
|
|
197
|
-
}) ?? formatHslTriplet({
|
|
198
|
-
h: ink.h,
|
|
199
|
-
s: ink.s,
|
|
200
|
-
l: 0
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
function toFillTriplet(fill) {
|
|
204
|
-
const parsed = parseHslTriplet(fill);
|
|
205
|
-
if (parsed) return `${parsed.h} ${parsed.s}% ${parsed.l}%`;
|
|
206
|
-
const hex = hexToHsl(fill);
|
|
207
|
-
return hex ? `${hex.h} ${hex.s}% ${hex.l}%` : null;
|
|
208
|
-
}
|
|
209
|
-
function foregroundFor(fill, mode = "light") {
|
|
210
|
-
if (typeof fill !== "string") return null;
|
|
211
|
-
const triplet = toFillTriplet(fill.trim());
|
|
212
|
-
if (!triplet) return null;
|
|
213
|
-
return pickFillForeground(triplet, ON_FILL_INK[mode === "dark" ? "dark" : "light"]);
|
|
214
|
-
}
|
|
215
73
|
const THEME_OPTIONS = new InjectionToken("THEME_OPTIONS");
|
|
216
74
|
const THEME_MODES = [
|
|
217
75
|
"light",
|
|
@@ -321,9 +179,9 @@ function hardenBrand(brand) {
|
|
|
321
179
|
color: brand.color,
|
|
322
180
|
foreground: brand.foreground ?? UNMEASURABLE_BRAND_FOREGROUND
|
|
323
181
|
};
|
|
324
|
-
const chosen = foregroundFor(color, "light");
|
|
182
|
+
const chosen = foregroundFor$1(color, "light");
|
|
325
183
|
const explicit = brand.foreground;
|
|
326
|
-
if (explicit !== void 0 && parseHslTriplet(explicit) && contrastRatio(explicit, color) >=
|
|
184
|
+
if (explicit !== void 0 && parseHslTriplet(explicit) && contrastRatio(explicit, color) >= TEXT_CONTRAST_MIN) return {
|
|
327
185
|
color,
|
|
328
186
|
foreground: explicit
|
|
329
187
|
};
|
|
@@ -335,12 +193,12 @@ function hardenBrand(brand) {
|
|
|
335
193
|
function brandRing(color, background) {
|
|
336
194
|
const parsed = parseHslTriplet(color);
|
|
337
195
|
if (!parsed) return null;
|
|
338
|
-
if (contrastRatio(color, background) >=
|
|
196
|
+
if (contrastRatio(color, background) >= NON_TEXT_CONTRAST_MIN) return color;
|
|
339
197
|
return solveLightnessNearest({
|
|
340
198
|
h: parsed.h,
|
|
341
199
|
s: parsed.s,
|
|
342
200
|
against: [background],
|
|
343
|
-
min:
|
|
201
|
+
min: NON_TEXT_CONTRAST_MIN,
|
|
344
202
|
from: parsed.l
|
|
345
203
|
}) ?? color;
|
|
346
204
|
}
|
|
@@ -407,7 +265,7 @@ var ThemeBrandService = class ThemeBrandService {
|
|
|
407
265
|
}
|
|
408
266
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
409
267
|
minVersion: "12.0.0",
|
|
410
|
-
version: "22.2.
|
|
268
|
+
version: "22.2.6",
|
|
411
269
|
ngImport: i0,
|
|
412
270
|
type: ThemeBrandService,
|
|
413
271
|
deps: [],
|
|
@@ -415,14 +273,14 @@ var ThemeBrandService = class ThemeBrandService {
|
|
|
415
273
|
});
|
|
416
274
|
static ɵprov = i0.ɵɵngDeclareService({
|
|
417
275
|
minVersion: "22.0.0",
|
|
418
|
-
version: "22.2.
|
|
276
|
+
version: "22.2.6",
|
|
419
277
|
ngImport: i0,
|
|
420
278
|
type: ThemeBrandService
|
|
421
279
|
});
|
|
422
280
|
};
|
|
423
281
|
i0.ɵɵngDeclareClassMetadata({
|
|
424
282
|
minVersion: "12.0.0",
|
|
425
|
-
version: "22.2.
|
|
283
|
+
version: "22.2.6",
|
|
426
284
|
ngImport: i0,
|
|
427
285
|
type: ThemeBrandService,
|
|
428
286
|
decorators: [{ type: Service }],
|
|
@@ -452,7 +310,7 @@ var ThemeColorService = class ThemeColorService {
|
|
|
452
310
|
}
|
|
453
311
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
454
312
|
minVersion: "12.0.0",
|
|
455
|
-
version: "22.2.
|
|
313
|
+
version: "22.2.6",
|
|
456
314
|
ngImport: i0,
|
|
457
315
|
type: ThemeColorService,
|
|
458
316
|
deps: [],
|
|
@@ -460,14 +318,14 @@ var ThemeColorService = class ThemeColorService {
|
|
|
460
318
|
});
|
|
461
319
|
static ɵprov = i0.ɵɵngDeclareService({
|
|
462
320
|
minVersion: "22.0.0",
|
|
463
|
-
version: "22.2.
|
|
321
|
+
version: "22.2.6",
|
|
464
322
|
ngImport: i0,
|
|
465
323
|
type: ThemeColorService
|
|
466
324
|
});
|
|
467
325
|
};
|
|
468
326
|
i0.ɵɵngDeclareClassMetadata({
|
|
469
327
|
minVersion: "12.0.0",
|
|
470
|
-
version: "22.2.
|
|
328
|
+
version: "22.2.6",
|
|
471
329
|
ngImport: i0,
|
|
472
330
|
type: ThemeColorService,
|
|
473
331
|
decorators: [{ type: Service }]
|
|
@@ -493,7 +351,7 @@ var ThemeModeService = class ThemeModeService {
|
|
|
493
351
|
}
|
|
494
352
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
495
353
|
minVersion: "12.0.0",
|
|
496
|
-
version: "22.2.
|
|
354
|
+
version: "22.2.6",
|
|
497
355
|
ngImport: i0,
|
|
498
356
|
type: ThemeModeService,
|
|
499
357
|
deps: [],
|
|
@@ -501,14 +359,14 @@ var ThemeModeService = class ThemeModeService {
|
|
|
501
359
|
});
|
|
502
360
|
static ɵprov = i0.ɵɵngDeclareService({
|
|
503
361
|
minVersion: "22.0.0",
|
|
504
|
-
version: "22.2.
|
|
362
|
+
version: "22.2.6",
|
|
505
363
|
ngImport: i0,
|
|
506
364
|
type: ThemeModeService
|
|
507
365
|
});
|
|
508
366
|
};
|
|
509
367
|
i0.ɵɵngDeclareClassMetadata({
|
|
510
368
|
minVersion: "12.0.0",
|
|
511
|
-
version: "22.2.
|
|
369
|
+
version: "22.2.6",
|
|
512
370
|
ngImport: i0,
|
|
513
371
|
type: ThemeModeService,
|
|
514
372
|
decorators: [{ type: Service }]
|
|
@@ -536,7 +394,7 @@ var ThemeRadiusService = class ThemeRadiusService {
|
|
|
536
394
|
}
|
|
537
395
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
538
396
|
minVersion: "12.0.0",
|
|
539
|
-
version: "22.2.
|
|
397
|
+
version: "22.2.6",
|
|
540
398
|
ngImport: i0,
|
|
541
399
|
type: ThemeRadiusService,
|
|
542
400
|
deps: [],
|
|
@@ -544,14 +402,14 @@ var ThemeRadiusService = class ThemeRadiusService {
|
|
|
544
402
|
});
|
|
545
403
|
static ɵprov = i0.ɵɵngDeclareService({
|
|
546
404
|
minVersion: "22.0.0",
|
|
547
|
-
version: "22.2.
|
|
405
|
+
version: "22.2.6",
|
|
548
406
|
ngImport: i0,
|
|
549
407
|
type: ThemeRadiusService
|
|
550
408
|
});
|
|
551
409
|
};
|
|
552
410
|
i0.ɵɵngDeclareClassMetadata({
|
|
553
411
|
minVersion: "12.0.0",
|
|
554
|
-
version: "22.2.
|
|
412
|
+
version: "22.2.6",
|
|
555
413
|
ngImport: i0,
|
|
556
414
|
type: ThemeRadiusService,
|
|
557
415
|
decorators: [{ type: Service }]
|
|
@@ -570,7 +428,7 @@ var ThemeSpaceService = class ThemeSpaceService {
|
|
|
570
428
|
}
|
|
571
429
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
572
430
|
minVersion: "12.0.0",
|
|
573
|
-
version: "22.2.
|
|
431
|
+
version: "22.2.6",
|
|
574
432
|
ngImport: i0,
|
|
575
433
|
type: ThemeSpaceService,
|
|
576
434
|
deps: [],
|
|
@@ -578,28 +436,101 @@ var ThemeSpaceService = class ThemeSpaceService {
|
|
|
578
436
|
});
|
|
579
437
|
static ɵprov = i0.ɵɵngDeclareService({
|
|
580
438
|
minVersion: "22.0.0",
|
|
581
|
-
version: "22.2.
|
|
439
|
+
version: "22.2.6",
|
|
582
440
|
ngImport: i0,
|
|
583
441
|
type: ThemeSpaceService
|
|
584
442
|
});
|
|
585
443
|
};
|
|
586
444
|
i0.ɵɵngDeclareClassMetadata({
|
|
587
445
|
minVersion: "12.0.0",
|
|
588
|
-
version: "22.2.
|
|
446
|
+
version: "22.2.6",
|
|
589
447
|
ngImport: i0,
|
|
590
448
|
type: ThemeSpaceService,
|
|
591
449
|
decorators: [{ type: Service }]
|
|
592
450
|
});
|
|
451
|
+
const UI_THEME_RELEASE_VERSION = "22.2.14";
|
|
452
|
+
const THEME_STORAGE_VERSION_KEY = "theme-storage-version";
|
|
453
|
+
function validateThemeStorageReset(options) {
|
|
454
|
+
if ("storageVersion" in options) throw new Error("storageVersion was removed. Migrate to storageReset: { preserveKeys: [] }; the package supplies the version.");
|
|
455
|
+
const reset = options.storageReset;
|
|
456
|
+
if (reset === void 0 || reset === false) return null;
|
|
457
|
+
if (reset === null || typeof reset !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(reset)) || Reflect.ownKeys(reset).some((key) => key !== "preserveKeys")) throw new Error("Use storageReset: { preserveKeys: string[] } or false. Unknown options are not supported.");
|
|
458
|
+
const keys = reset.preserveKeys;
|
|
459
|
+
if (keys !== void 0 && (!Array.isArray(keys) || keys.some((key) => typeof key !== "string"))) throw new Error("storageReset.preserveKeys must be an array of strings.");
|
|
460
|
+
const preserved = new Set(keys);
|
|
461
|
+
if (preserved.has("theme-storage-version")) throw new Error("theme-storage-version is reserved and cannot appear in storageReset.preserveKeys.");
|
|
462
|
+
return preserved;
|
|
463
|
+
}
|
|
464
|
+
var ThemeStorageVersionService = class ThemeStorageVersionService {
|
|
465
|
+
document = inject(DOCUMENT);
|
|
466
|
+
injector = inject(EnvironmentInjector);
|
|
467
|
+
destroyRef = inject(DestroyRef);
|
|
468
|
+
options = inject(THEME_OPTIONS, { optional: true }) ?? {};
|
|
469
|
+
preserved = validateThemeStorageReset(this.options);
|
|
470
|
+
state = signal(this.preserved ? "pending" : "disabled", ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
|
|
471
|
+
coordinator = this.preserved ? new StorageCoordinator(this.document, UI_THEME_RELEASE_VERSION, this.preserved, (status) => this.state.set(status)) : null;
|
|
472
|
+
initialization;
|
|
473
|
+
status = this.state.asReadonly();
|
|
474
|
+
registerRoot(active) {
|
|
475
|
+
if (active !== Boolean(this.coordinator)) throw new Error("Automatic theme storage reset permits only one theme root per Document.");
|
|
476
|
+
const release = registerStorageRoot(this.document, this.coordinator);
|
|
477
|
+
this.destroyRef.onDestroy(release);
|
|
478
|
+
}
|
|
479
|
+
initialize() {
|
|
480
|
+
if (!this.initialization) {
|
|
481
|
+
if (this.coordinator) this.initialization = this.coordinator.initialize(() => this.hydrate());
|
|
482
|
+
else {
|
|
483
|
+
this.hydrate();
|
|
484
|
+
this.initialization = Promise.resolve();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return this.initialization;
|
|
488
|
+
}
|
|
489
|
+
hydrate() {
|
|
490
|
+
if (this.destroyRef.destroyed) return;
|
|
491
|
+
runInInjectionContext(this.injector, () => {
|
|
492
|
+
inject(ThemeModeService);
|
|
493
|
+
inject(ThemeColorService);
|
|
494
|
+
inject(ThemeBrandService);
|
|
495
|
+
inject(ThemeRadiusService);
|
|
496
|
+
inject(ThemeSpaceService);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
500
|
+
minVersion: "12.0.0",
|
|
501
|
+
version: "22.2.6",
|
|
502
|
+
ngImport: i0,
|
|
503
|
+
type: ThemeStorageVersionService,
|
|
504
|
+
deps: [],
|
|
505
|
+
target: i0.ɵɵFactoryTarget.Service
|
|
506
|
+
});
|
|
507
|
+
static ɵprov = i0.ɵɵngDeclareService({
|
|
508
|
+
minVersion: "22.0.0",
|
|
509
|
+
version: "22.2.6",
|
|
510
|
+
ngImport: i0,
|
|
511
|
+
type: ThemeStorageVersionService
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
515
|
+
minVersion: "12.0.0",
|
|
516
|
+
version: "22.2.6",
|
|
517
|
+
ngImport: i0,
|
|
518
|
+
type: ThemeStorageVersionService,
|
|
519
|
+
decorators: [{ type: Service }]
|
|
520
|
+
});
|
|
593
521
|
function provideUiTheme(options = {}) {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
|
|
522
|
+
const active = validateThemeStorageReset(options) !== null;
|
|
523
|
+
return makeEnvironmentProviders([
|
|
524
|
+
{
|
|
525
|
+
provide: THEME_OPTIONS,
|
|
526
|
+
useValue: options
|
|
527
|
+
},
|
|
528
|
+
provideEnvironmentInitializer(() => {
|
|
529
|
+
const storage = inject(ThemeStorageVersionService);
|
|
530
|
+
storage.registerRoot(active);
|
|
531
|
+
if (storage.status() === "disabled") storage.initialize();
|
|
532
|
+
}),
|
|
533
|
+
provideAppInitializer(() => inject(ThemeStorageVersionService).initialize())
|
|
534
|
+
]);
|
|
535
|
+
}
|
|
536
|
+
export { DEFAULT_THEME_COLOR, DEFAULT_THEME_MODE, DEFAULT_THEME_NEUTRAL, DEFAULT_THEME_RADIUS, DEFAULT_THEME_SPACE, ON_FILL_INK, RESOLVED_THEME_MODES, THEME_BRAND_STORAGE_KEY, THEME_COLORS, THEME_COLOR_STORAGE_KEY, THEME_MODES, THEME_MODE_STORAGE_KEY, THEME_NEUTRALS, THEME_NEUTRAL_STORAGE_KEY, THEME_OPTIONS, THEME_RADII, THEME_RADIUS_STORAGE_KEY, THEME_SPACES, THEME_SPACE_STORAGE_KEY, THEME_STORAGE_VERSION_KEY, ThemeBrandService, ThemeColorService, ThemeModeService, ThemeRadiusService, ThemeSpaceService, ThemeStorageVersionService, UI_THEME_RELEASE_VERSION, foregroundFor, htmlAttributeEffect, htmlStylePropertyEffect, isResolvedThemeMode, isThemeColor, isThemeMode, isThemeNeutral, isThemeRadius, isThemeSpace, normalizeThemeColor, normalizeThemeMode, normalizeThemeNeutral, normalizeThemeRadius, normalizeThemeSpace, persistedHtmlAttributeSignal, persistedSignal, prefersDarkSignal, provideUiTheme };
|
package/navigation/README.md
CHANGED
|
@@ -67,9 +67,9 @@ Type dipilih lewat komponen anak deklaratif (`NavigationSidebar`, `NavigationDoc
|
|
|
67
67
|
- `label` on `NavigationFlyout` sets the single trigger label and defaults to `Menu`.
|
|
68
68
|
- `icon` on `NavigationFlyout` renders a Lucide icon on the trigger (the name must be registered with `provideIcons()`); `icon-position` (`start`/`end`) sets its placement and `icon-only` hides the label visually while keeping it as the accessible name (compact mode is always icon-only and falls back to the `menu` icon).
|
|
69
69
|
- `nav-position` on `NavigationNavbar`/`NavigationFlyout` accepts `top` (default) or `bottom`. With `bottom`, the navbar grid panel opens upward with squared bottom corners, and the flyout panel anchors to the container's bottom edge with the tab row docked at the bottom — seamless for bars placed below the content.
|
|
70
|
-
- `nav-appearance` on `NavigationNavbar`/`NavigationFlyout` accepts `flat` or `border-rail` (same vocabulary as the layout's `layout-appearance`). `border-rail` squares the panel (no rounding), frames entry icons with dimmed blueprint-style rail lines plus dashed center cross lines (instead of rounded boxes),
|
|
70
|
+
- `nav-appearance` on `NavigationNavbar`/`NavigationFlyout` accepts `flat` or `border-rail` (same vocabulary as the layout's `layout-appearance`). `border-rail` squares the panel (no rounding), frames entry icons with dimmed blueprint-style rail lines plus dashed center cross lines (instead of rounded boxes), shows tree rails only along the active path, and uses primary-colored text on hover. Horizontal root parents and active leaves retain a full primary background in both appearances.
|
|
71
71
|
- The `navbar` type renders root items inline immediately; clicking a group (hover does not open it) opens a full-width grid panel below the bar with the same flyout-style entries, responsive columns, and nested collapse. Root group triggers intentionally render without a chevron; open state remains available through the trigger styling and `aria-expanded`.
|
|
72
|
-
- The `flyout` type renders one trigger button that opens a floating panel overlaying the parent container exactly (same top position and width, covering the trigger with no visible gap; `display: contents` wrappers are skipped when measuring the container). A `trigger-floating` popover keeps the 22rem / 85vw default through `--nav-flyout-floating-width` and `--nav-flyout-floating-max-width`, while `--nav-flyout-floating-radius` can align its card with a containing shell. Use `trigger-class` only for the floating host/placement and `trigger-button-class` for trigger-specific styling; the latter never leaks into panel items. Add `panel-viewport` when window chrome needs the floating panel fixed to `top: 0` and both viewport edges; these options let desktop chrome place and shape the same interaction without changing the global default. The panel explicitly opts out of native window drag regions so its controls remain clickable inside desktop chrome. Root items with children become the horizontal navigation inside the panel (their `icon` renders in the row), their children render as title/subtitle entries in a responsive grid (1 column on mobile, 2 from `sm`, 3 from `md`, 4 from `lg` and up; `columns` caps the maximum at 1–4), and deeper children render as a vertical collapse below their entry — expanded by default every time the panel opens, collapsible per entry via the chevron, with
|
|
72
|
+
- The `flyout` type renders one trigger button that opens a floating panel overlaying the parent container exactly (same top position and width, covering the trigger with no visible gap; `display: contents` wrappers are skipped when measuring the container). A `trigger-floating` popover keeps the 22rem / 85vw default through `--nav-flyout-floating-width` and `--nav-flyout-floating-max-width`, while `--nav-flyout-floating-radius` can align its card with a containing shell. Use `trigger-class` only for the floating host/placement and `trigger-button-class` for trigger-specific styling; the latter never leaks into panel items. Add `panel-viewport` when window chrome needs the floating panel fixed to `top: 0` and both viewport edges; these options let desktop chrome place and shape the same interaction without changing the global default. The panel explicitly opts out of native window drag regions so its controls remain clickable inside desktop chrome. Root items with children become the horizontal navigation inside the panel (their `icon` renders in the row), their children render as title/subtitle entries in a responsive grid (1 column on mobile, 2 from `sm`, 3 from `md`, 4 from `lg` and up; `columns` caps the maximum at 1–4), and deeper children render as a vertical collapse below their entry — expanded by default every time the panel opens, collapsible per entry via the chevron, with child levels indented by `--nav-indent`, including deeper groups and collapsible branches. The panel closes on `Escape`, outside clicks, the close button, or leaf selection.
|
|
73
73
|
- Items with children render a `chevron_right` icon pinned at the right edge and vertically centered: it points right by default and rotates down (in place, no layout shift) only while open — hover does not move it. This applies to flyout tabs and entries plus collapsible items; navbar root branch triggers are the deliberate exception.
|
|
74
74
|
- Angular Router is supported for internal links through `link`, `queryParams`, `fragment`, `exactMatch`, and `isActiveMatchOptions`.
|
|
75
75
|
- External links can use `href` or `link` with `externalLink: true`.
|
|
@@ -84,6 +84,35 @@ Type dipilih lewat komponen anak deklaratif (`NavigationSidebar`, `NavigationDoc
|
|
|
84
84
|
- `compact` is still supported as a compatibility alias for collapsed vertical sidebars.
|
|
85
85
|
- `nav-sidebar-collapse` on `NavigationSidebar` enables hover-preview behavior for collapsed vertical sidebars.
|
|
86
86
|
- `collapse-tree` accepts `stairs` or `straight` for nested collapsible connector styling.
|
|
87
|
+
- Sidebar `group` headings render as plain labels without an icon or active decoration.
|
|
88
|
+
Descendant links retain their normal active state and heading/list association.
|
|
89
|
+
- Active parents in sidebar and dockbar menus use a primary-filled, bordered icon chip.
|
|
90
|
+
Active leaf items use `primary` with `primary-foreground`, including their subtitle and icon.
|
|
91
|
+
The label and chevron of a parent stay on the navigation background, with no active row fill or border.
|
|
92
|
+
The icon uses `primary-foreground`, the same contrast-tested foreground-on-fill pair as
|
|
93
|
+
other primary surfaces: white on dark fills, theme ink on light fills. Group headings
|
|
94
|
+
outside sidebar and the built-in route-aware dockbar header use the same chip. The chip paints outside
|
|
95
|
+
the glyph slot without moving labels, badges, or connector anchors.
|
|
96
|
+
- Navbar, flyout, and the empty layout launcher fill the entire active root tab and
|
|
97
|
+
root entry parent with `primary` and `primary-foreground`. Root entry parents use
|
|
98
|
+
the same glyph slot and rail anchor as recursive children. Child lists meet the
|
|
99
|
+
parent without a margin; the first elbow starts at its bottom edge. The primary
|
|
100
|
+
rail ends at the active descendant without a trailing spur, and uses the shared
|
|
101
|
+
`--nav-rail-radius` for its continuous rounded elbow.
|
|
102
|
+
- Active vertical leaf items use a `primary` background with `primary-foreground` for
|
|
103
|
+
their title, subtitle, and icon. Expanded active stairs parents join their icon chip
|
|
104
|
+
to the child rail continuously, including rows with subtitles. Stairs connectors use
|
|
105
|
+
a continuous elbow with `--nav-rail-radius`, derived from `--radius-md` and capped
|
|
106
|
+
by the available row height and branch width. Radius `none` produces a 90 degree
|
|
107
|
+
corner; other presets curve smoothly, including `full` at compact density.
|
|
108
|
+
- `rail` accepts `default` (the existing full branch rail) or `rail-active` on `Navigation`.
|
|
109
|
+
In sidebar and dockbar menus, `rail-active` draws the vertical path only as far as the
|
|
110
|
+
active child at each depth, with the stairs connector pointing at that child. Open
|
|
111
|
+
branches without active descendants have no rail. Route matches, `activeIds`, and
|
|
112
|
+
`item.active` use the same active state as the menu. It also trims the dotted `straight`
|
|
113
|
+
tree without changing its shape. Active vertical rails and horizontal connectors use
|
|
114
|
+
`primary` in both tree styles; inactive default rails remain neutral. Collapsed menus
|
|
115
|
+
keep their icon layout.
|
|
87
116
|
- `NavigationHeader` is optional, accepts Tailwind classes through `class`, and can render a built-in collapse toggle with `[toggle]="true"`.
|
|
88
117
|
- `NavigationFooter` is optional and accepts Tailwind classes through `class`.
|
|
89
118
|
- `NavigationContent` wraps the active navigation renderer and owns the scrollable region between the optional header and footer slots. It is rendered automatically by the type component when not projected, and accepts `class` when used explicitly.
|
|
@@ -101,6 +130,7 @@ Inputs pada `<Navigation>` (container):
|
|
|
101
130
|
| `data` | `readonly NavigationItem[]` | Source of navigation items. |
|
|
102
131
|
| `ariaLabel` | `string` | Accessible label on the host navigation landmark. |
|
|
103
132
|
| `compact` | `boolean` | Compatibility alias for collapsed-rail item layout. |
|
|
133
|
+
| `rail` | `default \| rail-active` | Extent of parent to child connectors in sidebar and dockbar. |
|
|
104
134
|
| `collapse-tree` | `stairs \| straight` | Controls nested connector styling for collapsible items. |
|
|
105
135
|
| `class` | `string` | Extra classes for the host `nav`. |
|
|
106
136
|
| `itemClass` | `string` | Shared classes applied to rendered nav items. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ojiepermana/angular",
|
|
3
|
-
"version": "22.2.
|
|
3
|
+
"version": "22.2.14",
|
|
4
4
|
"description": "Accessible, tree-shakable Angular 22 design system from ojiepermana: UI components, charts, navigation shells, theme tokens, and an OpenAPI SDK generator.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -508,5 +508,5 @@
|
|
|
508
508
|
"module": "fesm2022/ojiepermana-angular.mjs",
|
|
509
509
|
"typings": "types/ojiepermana-angular.d.ts",
|
|
510
510
|
"type": "module",
|
|
511
|
-
"gitHead": "
|
|
511
|
+
"gitHead": "6543e9e47023dace11af78cd9bcd430406df3e0a"
|
|
512
512
|
}
|
|
@@ -152,3 +152,18 @@ behavior as an `empty` layout. Persist it through
|
|
|
152
152
|
`ThemeSettingsNavigationType`; entering that shell/layout pair normalizes the
|
|
153
153
|
value to `desktop`, while leaving it normalizes to the first valid nav for the
|
|
154
154
|
new combination.
|
|
155
|
+
|
|
156
|
+
Sidebar and dockbar also expose **Nav rail** with **Default** and **rail-active**.
|
|
157
|
+
Default preserves the full branch rail. `rail-active` stops each branch at its
|
|
158
|
+
active child and omits rails from branches with no active descendant. The default
|
|
159
|
+
adapter persists this independent preference under `nav-rail`, retaining it when
|
|
160
|
+
you switch navigation types. Forward it to the shell:
|
|
161
|
+
|
|
162
|
+
```html
|
|
163
|
+
<LayoutWrapperDefault [nav-rail]="settings.navRail()" />
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
For a navigation assembled by hand, bind `[rail]="settings.navRail()"` on
|
|
167
|
+
`Navigation`. Custom adapters can opt into the control by supplying both the
|
|
168
|
+
optional `navRail` signal and `setNavRail(value: NavigationRail)` method. Existing
|
|
169
|
+
adapters without these members keep working and omit this control.
|
package/theme/styles/README.md
CHANGED
|
@@ -9,6 +9,7 @@ import { provideUiTheme } from '@ojiepermana/angular/theme/styles';
|
|
|
9
9
|
export const appConfig = {
|
|
10
10
|
providers: [
|
|
11
11
|
provideUiTheme({
|
|
12
|
+
storageReset: { preserveKeys: ['auth-token'] }, // opsional: reset localStorage saat paket di-upgrade
|
|
12
13
|
mode: 'light',
|
|
13
14
|
color: 'base', // accent: base, red…rose, brand
|
|
14
15
|
neutral: 'base', // gray family: base, slate, gray, zinc, …
|
|
@@ -36,6 +37,75 @@ export const appConfig = {
|
|
|
36
37
|
- Pilihan yang dipersist (`theme-color` / `theme-neutral` / `theme-radius` / `theme-space` /
|
|
37
38
|
`theme-brand`) menang atas default.
|
|
38
39
|
|
|
40
|
+
## Reset localStorage saat upgrade
|
|
41
|
+
|
|
42
|
+
`storageReset` mengaktifkan reset localStorage setiap kali Anda memasang versi paket yang
|
|
43
|
+
lebih baru. Nomor versinya berasal dari paket itu sendiri (`UI_THEME_RELEASE_VERSION`, sama
|
|
44
|
+
dengan `version` di `package.json` paket), jadi Anda tidak perlu menyalin angka apa pun.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
provideUiTheme({
|
|
48
|
+
storageReset: { preserveKeys: ['auth-token', 'selected-company'] },
|
|
49
|
+
mode: 'light',
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- Opsi tidak diisi, atau `false`: fitur mati, persistensi berjalan seperti biasa.
|
|
54
|
+
- `{}` atau `{ preserveKeys: [] }`: fitur aktif tanpa key yang dilindungi, jadi seluruh
|
|
55
|
+
localStorage pada origin ikut dihapus.
|
|
56
|
+
- `preserveKeys` dicocokkan persis dan peka huruf besar kecil. Tidak ada wildcard atau
|
|
57
|
+
prefix. Key yang dilindungi tidak dibaca dan tidak ditulis selama reset, nilainya tetap utuh.
|
|
58
|
+
- `theme-storage-version` adalah penanda versi milik library. Key ini tidak boleh ada di
|
|
59
|
+
`preserveKeys`; config seperti itu ditolak.
|
|
60
|
+
- Config yang salah bentuk (bukan objek biasa, properti tidak dikenal, `preserveKeys` bukan
|
|
61
|
+
array string) ditolak dengan error saat aplikasi dimulai, sebelum storage disentuh.
|
|
62
|
+
|
|
63
|
+
Cara kerjanya, dibandingkan per angka `MAJOR.MINOR.PATCH`:
|
|
64
|
+
|
|
65
|
+
| Penanda tersimpan | Hasil |
|
|
66
|
+
| ----------------------- | -------------------------------------------------------------------------------- |
|
|
67
|
+
| Lebih lama dari paket | Semua key selain `preserveKeys` dihapus, lalu versi baru dicatat (`reset`) |
|
|
68
|
+
| Sama dengan paket | Tidak ada yang dihapus (`ready`) |
|
|
69
|
+
| Hilang atau tidak valid | Versi paket dicatat tanpa menghapus apa pun (`adopted`) |
|
|
70
|
+
| Lebih baru dari paket | Tidak ada yang dihapus, penanda tidak diturunkan, tema memakai default (`stale`) |
|
|
71
|
+
|
|
72
|
+
Penanda baru ditulis paling akhir, setelah semua penghapusan berhasil. Session storage,
|
|
73
|
+
cookie, dan IndexedDB tidak disentuh.
|
|
74
|
+
|
|
75
|
+
### Tab lain dan kegagalan
|
|
76
|
+
|
|
77
|
+
- Reset dan semua penulisan preferensi library memakai satu Web Lock per origin
|
|
78
|
+
(`ui-theme-storage-reset`), jadi dua tab yang dibuka bersamaan hanya mereset sekali.
|
|
79
|
+
- Tab lama yang melihat penanda lebih baru berhenti menyimpan preferensi, lalu memuat ulang
|
|
80
|
+
sendiri. Input yang belum disimpan di tab itu bisa hilang. Jika server masih menyajikan bundle
|
|
81
|
+
lama setelah reload, tab itu tetap memakai default tanpa reload berulang.
|
|
82
|
+
- Jika storage diblokir, Web Locks tidak tersedia (`unsupported`), lock menunggu lebih dari dua
|
|
83
|
+
detik, atau penghapusan gagal (`failed`), aplikasi tetap berjalan dengan default tema Anda
|
|
84
|
+
dan penanda tidak dimajukan. Bootstrap berikutnya mencoba lagi. Pada SSR statusnya
|
|
85
|
+
`unavailable`.
|
|
86
|
+
- Koordinasi ini hanya berlaku untuk penulisan lewat library. Kode aplikasi Anda yang menulis
|
|
87
|
+
localStorage langsung, atau tab yang masih memuat versi sebelum fitur ini, tidak ikut lock.
|
|
88
|
+
Beberapa aplikasi pada origin yang sama berbagi satu penanda, jadi config mereka sebaiknya sama.
|
|
89
|
+
|
|
90
|
+
### Status dan urutan bootstrap
|
|
91
|
+
|
|
92
|
+
`ThemeStorageVersionService.status` adalah signal berisi `disabled`, `pending`, `ready`,
|
|
93
|
+
`adopted`, `reset`, `stale`, `unavailable`, `unsupported`, atau `failed`. Status ini tidak
|
|
94
|
+
memuat nilai localStorage apa pun. `initialize()` dipanggil otomatis oleh provider; memanggilnya
|
|
95
|
+
lagi mengembalikan Promise yang sama.
|
|
96
|
+
|
|
97
|
+
Saat fitur aktif, preferensi tema baru dibaca setelah reset selesai. Jika Anda membaca atau
|
|
98
|
+
menulis preferensi library di dalam `provideAppInitializer` sendiri, tunggu dulu
|
|
99
|
+
`inject(ThemeStorageVersionService).initialize()`. Pembacaan selama status masih `pending`
|
|
100
|
+
ditolak dengan error. Fitur aktif juga hanya mengizinkan satu `provideUiTheme` per dokumen;
|
|
101
|
+
root kedua ditolak.
|
|
102
|
+
|
|
103
|
+
### Migrasi dari `storageVersion`
|
|
104
|
+
|
|
105
|
+
Opsi `storageVersion` manual dihapus dan sekarang ditolak dengan pesan migrasi. Ganti
|
|
106
|
+
`storageVersion: '22.2.11'` dengan `storageReset: { preserveKeys: [] }`, lalu tambahkan key
|
|
107
|
+
yang ingin Anda pertahankan, misalnya token login.
|
|
108
|
+
|
|
39
109
|
## Default Behavior
|
|
40
110
|
|
|
41
111
|
- `provideUiTheme()` tidak melakukan request jaringan eksternal apa pun dan tidak memuat font ikon:
|
|
@@ -101,7 +171,7 @@ WCAG, bukan menebak dari rentang hue. Aturannya:
|
|
|
101
171
|
|
|
102
172
|
A brand the consumer picks at runtime is held to the same rules, and split the
|
|
103
173
|
same way. `ThemeBrandService.setBrand()` measures it with the same WCAG formula
|
|
104
|
-
(`theme-contrast.ts`, a port of `scripts/generators/theme-contrast.mjs`) before storing it:
|
|
174
|
+
(`component/utils/core/theme-contrast.ts`, a port of `scripts/generators/theme-contrast.mjs`) before storing it:
|
|
105
175
|
|
|
106
176
|
- `--brand` itself is never moved. Like a generated `--primary`, the fill keeps
|
|
107
177
|
the lightness it was chosen with, so `theme-color='brand'` ships the colour the
|