@aeris-ui/core 22.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/fesm2022/aeris-ui-core-accordion.mjs +412 -0
- package/fesm2022/aeris-ui-core-accordion.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-animate-on-scroll.mjs +107 -0
- package/fesm2022/aeris-ui-core-animate-on-scroll.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-auto-complete.mjs +754 -0
- package/fesm2022/aeris-ui-core-auto-complete.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-auto-focus.mjs +63 -0
- package/fesm2022/aeris-ui-core-auto-focus.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-avatar.mjs +133 -0
- package/fesm2022/aeris-ui-core-avatar.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-badge.mjs +163 -0
- package/fesm2022/aeris-ui-core-badge.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-block-ui.mjs +139 -0
- package/fesm2022/aeris-ui-core-block-ui.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-breadcrumb.mjs +433 -0
- package/fesm2022/aeris-ui-core-breadcrumb.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-button-group.mjs +39 -0
- package/fesm2022/aeris-ui-core-button-group.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-button.mjs +246 -0
- package/fesm2022/aeris-ui-core-button.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-card.mjs +134 -0
- package/fesm2022/aeris-ui-core-card.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-carousel.mjs +542 -0
- package/fesm2022/aeris-ui-core-carousel.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-cascade-select.mjs +673 -0
- package/fesm2022/aeris-ui-core-cascade-select.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-chart.mjs +296 -0
- package/fesm2022/aeris-ui-core-chart.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-checkbox.mjs +220 -0
- package/fesm2022/aeris-ui-core-checkbox.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-chip.mjs +200 -0
- package/fesm2022/aeris-ui-core-chip.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-class-names.mjs +67 -0
- package/fesm2022/aeris-ui-core-class-names.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-color-picker.mjs +1192 -0
- package/fesm2022/aeris-ui-core-color-picker.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-compare.mjs +508 -0
- package/fesm2022/aeris-ui-core-compare.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-confirm-dialog.mjs +818 -0
- package/fesm2022/aeris-ui-core-confirm-dialog.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-confirm-popup.mjs +1010 -0
- package/fesm2022/aeris-ui-core-confirm-popup.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-context-menu.mjs +720 -0
- package/fesm2022/aeris-ui-core-context-menu.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-date-picker.mjs +1471 -0
- package/fesm2022/aeris-ui-core-date-picker.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-dialog.mjs +574 -0
- package/fesm2022/aeris-ui-core-dialog.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-divider.mjs +51 -0
- package/fesm2022/aeris-ui-core-divider.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-drawer.mjs +549 -0
- package/fesm2022/aeris-ui-core-drawer.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-dynamic-dialog.mjs +333 -0
- package/fesm2022/aeris-ui-core-dynamic-dialog.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-editor.mjs +1548 -0
- package/fesm2022/aeris-ui-core-editor.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-file-upload.mjs +965 -0
- package/fesm2022/aeris-ui-core-file-upload.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-filter-service.mjs +304 -0
- package/fesm2022/aeris-ui-core-filter-service.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-fluid.mjs +23 -0
- package/fesm2022/aeris-ui-core-fluid.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-focus-trap.mjs +185 -0
- package/fesm2022/aeris-ui-core-focus-trap.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-galleria.mjs +1657 -0
- package/fesm2022/aeris-ui-core-galleria.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-glass.mjs +35 -0
- package/fesm2022/aeris-ui-core-glass.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-icon-field.mjs +113 -0
- package/fesm2022/aeris-ui-core-icon-field.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-inplace.mjs +243 -0
- package/fesm2022/aeris-ui-core-inplace.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-input-group.mjs +110 -0
- package/fesm2022/aeris-ui-core-input-group.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-input-mask.mjs +343 -0
- package/fesm2022/aeris-ui-core-input-mask.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-input-number.mjs +497 -0
- package/fesm2022/aeris-ui-core-input-number.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-input-otp.mjs +361 -0
- package/fesm2022/aeris-ui-core-input-otp.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-input-text.mjs +226 -0
- package/fesm2022/aeris-ui-core-input-text.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-key-filter.mjs +208 -0
- package/fesm2022/aeris-ui-core-key-filter.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-mega-menu.mjs +835 -0
- package/fesm2022/aeris-ui-core-mega-menu.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-menu.mjs +796 -0
- package/fesm2022/aeris-ui-core-menu.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-menubar.mjs +729 -0
- package/fesm2022/aeris-ui-core-menubar.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-message.mjs +225 -0
- package/fesm2022/aeris-ui-core-message.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-meter-group.mjs +377 -0
- package/fesm2022/aeris-ui-core-meter-group.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-multi-select.mjs +1033 -0
- package/fesm2022/aeris-ui-core-multi-select.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-order-list.mjs +351 -0
- package/fesm2022/aeris-ui-core-order-list.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-organization-chart.mjs +382 -0
- package/fesm2022/aeris-ui-core-organization-chart.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-paginator.mjs +254 -0
- package/fesm2022/aeris-ui-core-paginator.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-panel.mjs +352 -0
- package/fesm2022/aeris-ui-core-panel.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-password.mjs +479 -0
- package/fesm2022/aeris-ui-core-password.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-pick-list.mjs +939 -0
- package/fesm2022/aeris-ui-core-pick-list.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-popover.mjs +535 -0
- package/fesm2022/aeris-ui-core-popover.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-progress-bar.mjs +260 -0
- package/fesm2022/aeris-ui-core-progress-bar.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-progress-spinner.mjs +218 -0
- package/fesm2022/aeris-ui-core-progress-spinner.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-radio-button.mjs +194 -0
- package/fesm2022/aeris-ui-core-radio-button.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-rating.mjs +385 -0
- package/fesm2022/aeris-ui-core-rating.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-scroll-panel.mjs +211 -0
- package/fesm2022/aeris-ui-core-scroll-panel.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-scroll-top.mjs +94 -0
- package/fesm2022/aeris-ui-core-scroll-top.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-select.mjs +1134 -0
- package/fesm2022/aeris-ui-core-select.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-skeleton.mjs +47 -0
- package/fesm2022/aeris-ui-core-skeleton.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-slider.mjs +724 -0
- package/fesm2022/aeris-ui-core-slider.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-speed-dial.mjs +589 -0
- package/fesm2022/aeris-ui-core-speed-dial.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-split-button.mjs +532 -0
- package/fesm2022/aeris-ui-core-split-button.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-splitter.mjs +488 -0
- package/fesm2022/aeris-ui-core-splitter.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-stepper.mjs +437 -0
- package/fesm2022/aeris-ui-core-stepper.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-style-class.mjs +344 -0
- package/fesm2022/aeris-ui-core-style-class.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-table.mjs +1580 -0
- package/fesm2022/aeris-ui-core-table.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-tabs.mjs +438 -0
- package/fesm2022/aeris-ui-core-tabs.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-textarea.mjs +349 -0
- package/fesm2022/aeris-ui-core-textarea.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-theme-builder.mjs +1565 -0
- package/fesm2022/aeris-ui-core-theme-builder.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-theming.mjs +150 -0
- package/fesm2022/aeris-ui-core-theming.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-tiered-menu.mjs +718 -0
- package/fesm2022/aeris-ui-core-tiered-menu.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-timeline.mjs +278 -0
- package/fesm2022/aeris-ui-core-timeline.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-toast.mjs +422 -0
- package/fesm2022/aeris-ui-core-toast.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-toggle-switch.mjs +202 -0
- package/fesm2022/aeris-ui-core-toggle-switch.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-toolbar.mjs +136 -0
- package/fesm2022/aeris-ui-core-toolbar.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-tooltip.mjs +365 -0
- package/fesm2022/aeris-ui-core-tooltip.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-tree-select.mjs +995 -0
- package/fesm2022/aeris-ui-core-tree-select.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-tree-table.mjs +1600 -0
- package/fesm2022/aeris-ui-core-tree-table.mjs.map +1 -0
- package/fesm2022/aeris-ui-core-tree.mjs +962 -0
- package/fesm2022/aeris-ui-core-tree.mjs.map +1 -0
- package/fesm2022/aeris-ui-core.mjs +360 -0
- package/fesm2022/aeris-ui-core.mjs.map +1 -0
- package/package.json +432 -0
- package/schematics/aeris-setup.schema.json +52 -0
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/schema.json +64 -0
- package/schematics/runtime/package.json +3 -0
- package/schematics/runtime/schematics/ng-add/index.js +13 -0
- package/schematics/runtime/schematics/ng-add/index.js.map +1 -0
- package/schematics/runtime/schematics/ng-add/options.js +338 -0
- package/schematics/runtime/schematics/ng-add/options.js.map +1 -0
- package/schematics/runtime/schematics/ng-add/schema.js +3 -0
- package/schematics/runtime/schematics/ng-add/schema.js.map +1 -0
- package/schematics/runtime/schematics/ng-add/workspace.js +273 -0
- package/schematics/runtime/schematics/ng-add/workspace.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-color-derivation.js +12 -0
- package/schematics/runtime/theme-builder/aeris-color-derivation.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-color.js +263 -0
- package/schematics/runtime/theme-builder/aeris-color.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-contrast.js +245 -0
- package/schematics/runtime/theme-builder/aeris-contrast.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-foundation.js +47 -0
- package/schematics/runtime/theme-builder/aeris-foundation.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-semantic-tones.js +121 -0
- package/schematics/runtime/theme-builder/aeris-semantic-tones.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-theme-generator.js +238 -0
- package/schematics/runtime/theme-builder/aeris-theme-generator.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-theme-resolver.js +101 -0
- package/schematics/runtime/theme-builder/aeris-theme-resolver.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-theme-tokens.js +82 -0
- package/schematics/runtime/theme-builder/aeris-theme-tokens.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-theme-validation.js +183 -0
- package/schematics/runtime/theme-builder/aeris-theme-validation.js.map +1 -0
- package/schematics/runtime/theme-builder/aeris-theme.js +322 -0
- package/schematics/runtime/theme-builder/aeris-theme.js.map +1 -0
- package/schematics/runtime/theme-builder/public-api.js +17 -0
- package/schematics/runtime/theme-builder/public-api.js.map +1 -0
- package/styles/_index.scss +1 -0
- package/styles/_tokens.scss +13 -0
- package/styles/aeris.css +555 -0
- package/styles/controls.css +169 -0
- package/tools/aeris-theme.mjs +149 -0
- package/tools/aeris-theme.schema.json +143 -0
- package/types/aeris-ui-core-accordion.d.ts +101 -0
- package/types/aeris-ui-core-animate-on-scroll.d.ts +34 -0
- package/types/aeris-ui-core-auto-complete.d.ts +154 -0
- package/types/aeris-ui-core-auto-focus.d.ts +17 -0
- package/types/aeris-ui-core-avatar.d.ts +44 -0
- package/types/aeris-ui-core-badge.d.ts +48 -0
- package/types/aeris-ui-core-block-ui.d.ts +28 -0
- package/types/aeris-ui-core-breadcrumb.d.ts +104 -0
- package/types/aeris-ui-core-button-group.d.ts +17 -0
- package/types/aeris-ui-core-button.d.ts +71 -0
- package/types/aeris-ui-core-card.d.ts +43 -0
- package/types/aeris-ui-core-carousel.d.ts +126 -0
- package/types/aeris-ui-core-cascade-select.d.ts +130 -0
- package/types/aeris-ui-core-chart.d.ts +92 -0
- package/types/aeris-ui-core-checkbox.d.ts +55 -0
- package/types/aeris-ui-core-chip.d.ts +56 -0
- package/types/aeris-ui-core-class-names.d.ts +21 -0
- package/types/aeris-ui-core-color-picker.d.ts +149 -0
- package/types/aeris-ui-core-compare.d.ts +109 -0
- package/types/aeris-ui-core-confirm-dialog.d.ts +263 -0
- package/types/aeris-ui-core-confirm-popup.d.ts +281 -0
- package/types/aeris-ui-core-context-menu.d.ts +156 -0
- package/types/aeris-ui-core-date-picker.d.ts +226 -0
- package/types/aeris-ui-core-dialog.d.ts +124 -0
- package/types/aeris-ui-core-divider.d.ts +21 -0
- package/types/aeris-ui-core-drawer.d.ts +119 -0
- package/types/aeris-ui-core-dynamic-dialog.d.ts +148 -0
- package/types/aeris-ui-core-editor.d.ts +130 -0
- package/types/aeris-ui-core-file-upload.d.ts +199 -0
- package/types/aeris-ui-core-filter-service.d.ts +54 -0
- package/types/aeris-ui-core-fluid.d.ts +10 -0
- package/types/aeris-ui-core-focus-trap.d.ts +32 -0
- package/types/aeris-ui-core-galleria.d.ts +273 -0
- package/types/aeris-ui-core-glass.d.ts +17 -0
- package/types/aeris-ui-core-icon-field.d.ts +36 -0
- package/types/aeris-ui-core-inplace.d.ts +68 -0
- package/types/aeris-ui-core-input-group.d.ts +38 -0
- package/types/aeris-ui-core-input-mask.d.ts +73 -0
- package/types/aeris-ui-core-input-number.d.ts +87 -0
- package/types/aeris-ui-core-input-otp.d.ts +88 -0
- package/types/aeris-ui-core-input-text.d.ts +63 -0
- package/types/aeris-ui-core-key-filter.d.ts +41 -0
- package/types/aeris-ui-core-mega-menu.d.ts +130 -0
- package/types/aeris-ui-core-menu.d.ts +182 -0
- package/types/aeris-ui-core-menubar.d.ts +145 -0
- package/types/aeris-ui-core-message.d.ts +65 -0
- package/types/aeris-ui-core-meter-group.d.ts +100 -0
- package/types/aeris-ui-core-multi-select.d.ts +193 -0
- package/types/aeris-ui-core-order-list.d.ts +73 -0
- package/types/aeris-ui-core-organization-chart.d.ts +85 -0
- package/types/aeris-ui-core-paginator.d.ts +39 -0
- package/types/aeris-ui-core-panel.d.ts +85 -0
- package/types/aeris-ui-core-password.d.ts +110 -0
- package/types/aeris-ui-core-pick-list.d.ts +193 -0
- package/types/aeris-ui-core-popover.d.ts +112 -0
- package/types/aeris-ui-core-progress-bar.d.ts +81 -0
- package/types/aeris-ui-core-progress-spinner.d.ts +51 -0
- package/types/aeris-ui-core-radio-button.d.ts +51 -0
- package/types/aeris-ui-core-rating.d.ts +80 -0
- package/types/aeris-ui-core-scroll-panel.d.ts +66 -0
- package/types/aeris-ui-core-scroll-top.d.ts +29 -0
- package/types/aeris-ui-core-select.d.ts +223 -0
- package/types/aeris-ui-core-skeleton.d.ts +18 -0
- package/types/aeris-ui-core-slider.d.ts +117 -0
- package/types/aeris-ui-core-speed-dial.d.ts +119 -0
- package/types/aeris-ui-core-split-button.d.ts +122 -0
- package/types/aeris-ui-core-splitter.d.ts +113 -0
- package/types/aeris-ui-core-stepper.d.ts +99 -0
- package/types/aeris-ui-core-style-class.d.ts +73 -0
- package/types/aeris-ui-core-table.d.ts +333 -0
- package/types/aeris-ui-core-tabs.d.ts +82 -0
- package/types/aeris-ui-core-textarea.d.ts +80 -0
- package/types/aeris-ui-core-theme-builder.d.ts +499 -0
- package/types/aeris-ui-core-theming.d.ts +47 -0
- package/types/aeris-ui-core-tiered-menu.d.ts +152 -0
- package/types/aeris-ui-core-timeline.d.ts +80 -0
- package/types/aeris-ui-core-toast.d.ts +127 -0
- package/types/aeris-ui-core-toggle-switch.d.ts +52 -0
- package/types/aeris-ui-core-toolbar.d.ts +47 -0
- package/types/aeris-ui-core-tooltip.d.ts +92 -0
- package/types/aeris-ui-core-tree-select.d.ts +187 -0
- package/types/aeris-ui-core-tree-table.d.ts +311 -0
- package/types/aeris-ui-core-tree.d.ts +179 -0
- package/types/aeris-ui-core.d.ts +85 -0
|
@@ -0,0 +1,1565 @@
|
|
|
1
|
+
const AERIS_MONOCHROME_LIGHT_PRIMARY_TONE = {
|
|
2
|
+
base: '#111111',
|
|
3
|
+
boundary: '#111111',
|
|
4
|
+
hover: '#242424',
|
|
5
|
+
active: '#050505',
|
|
6
|
+
onBase: '#ffffff',
|
|
7
|
+
onHover: '#ffffff',
|
|
8
|
+
onActive: '#ffffff',
|
|
9
|
+
text: '#111111',
|
|
10
|
+
soft: '#f1f1f1',
|
|
11
|
+
onSoft: '#111111',
|
|
12
|
+
};
|
|
13
|
+
const AERIS_MONOCHROME_DARK_PRIMARY_TONE = {
|
|
14
|
+
base: '#f5f5f5',
|
|
15
|
+
boundary: '#f5f5f5',
|
|
16
|
+
hover: '#ffffff',
|
|
17
|
+
active: '#e7e7e7',
|
|
18
|
+
onBase: '#090909',
|
|
19
|
+
onHover: '#090909',
|
|
20
|
+
onActive: '#090909',
|
|
21
|
+
text: '#f5f5f5',
|
|
22
|
+
soft: '#1b1b1b',
|
|
23
|
+
onSoft: '#ffffff',
|
|
24
|
+
};
|
|
25
|
+
const AERIS_MONOCHROME_LIGHT_SECONDARY_TONE = {
|
|
26
|
+
base: '#565656',
|
|
27
|
+
boundary: '#565656',
|
|
28
|
+
hover: '#464646',
|
|
29
|
+
active: '#363636',
|
|
30
|
+
onBase: '#ffffff',
|
|
31
|
+
onHover: '#ffffff',
|
|
32
|
+
onActive: '#ffffff',
|
|
33
|
+
text: '#454545',
|
|
34
|
+
soft: '#ededed',
|
|
35
|
+
onSoft: '#242424',
|
|
36
|
+
};
|
|
37
|
+
const AERIS_MONOCHROME_DARK_SECONDARY_TONE = {
|
|
38
|
+
base: '#b8b8b8',
|
|
39
|
+
boundary: '#b8b8b8',
|
|
40
|
+
hover: '#c8c8c8',
|
|
41
|
+
active: '#a8a8a8',
|
|
42
|
+
onBase: '#090909',
|
|
43
|
+
onHover: '#090909',
|
|
44
|
+
onActive: '#090909',
|
|
45
|
+
text: '#d0d0d0',
|
|
46
|
+
soft: '#262626',
|
|
47
|
+
onSoft: '#f5f5f5',
|
|
48
|
+
};
|
|
49
|
+
const AERIS_MONOCHROME_LIGHT_CONTRAST_TONE = {
|
|
50
|
+
base: '#ffffff',
|
|
51
|
+
boundary: '#111111',
|
|
52
|
+
hover: '#f1f1f1',
|
|
53
|
+
active: '#e3e3e3',
|
|
54
|
+
onBase: '#111111',
|
|
55
|
+
onHover: '#111111',
|
|
56
|
+
onActive: '#111111',
|
|
57
|
+
text: '#111111',
|
|
58
|
+
soft: '#f1f1f1',
|
|
59
|
+
onSoft: '#111111',
|
|
60
|
+
};
|
|
61
|
+
const AERIS_MONOCHROME_DARK_CONTRAST_TONE = {
|
|
62
|
+
base: '#090909',
|
|
63
|
+
boundary: '#f5f5f5',
|
|
64
|
+
hover: '#181818',
|
|
65
|
+
active: '#242424',
|
|
66
|
+
onBase: '#ffffff',
|
|
67
|
+
onHover: '#ffffff',
|
|
68
|
+
onActive: '#ffffff',
|
|
69
|
+
text: '#f5f5f5',
|
|
70
|
+
soft: '#1b1b1b',
|
|
71
|
+
onSoft: '#ffffff',
|
|
72
|
+
};
|
|
73
|
+
const AERIS_MONOCHROME_LIGHT_STATUS_TONES = {
|
|
74
|
+
success: {
|
|
75
|
+
base: '#2f6b46',
|
|
76
|
+
hover: '#285c3c',
|
|
77
|
+
active: '#214f34',
|
|
78
|
+
onBase: '#ffffff',
|
|
79
|
+
onHover: '#ffffff',
|
|
80
|
+
onActive: '#ffffff',
|
|
81
|
+
text: '#24573a',
|
|
82
|
+
soft: '#edf5ef',
|
|
83
|
+
onSoft: '#214f34',
|
|
84
|
+
},
|
|
85
|
+
info: {
|
|
86
|
+
base: '#2f6178',
|
|
87
|
+
hover: '#285368',
|
|
88
|
+
active: '#214758',
|
|
89
|
+
onBase: '#ffffff',
|
|
90
|
+
onHover: '#ffffff',
|
|
91
|
+
onActive: '#ffffff',
|
|
92
|
+
text: '#264f62',
|
|
93
|
+
soft: '#edf4f7',
|
|
94
|
+
onSoft: '#214758',
|
|
95
|
+
},
|
|
96
|
+
warning: {
|
|
97
|
+
base: '#c38600',
|
|
98
|
+
hover: '#bd8200',
|
|
99
|
+
active: '#b87d00',
|
|
100
|
+
onBase: '#211600',
|
|
101
|
+
onHover: '#211600',
|
|
102
|
+
onActive: '#211600',
|
|
103
|
+
text: '#8a6100',
|
|
104
|
+
soft: '#fff5d6',
|
|
105
|
+
onSoft: '#704e00',
|
|
106
|
+
},
|
|
107
|
+
danger: {
|
|
108
|
+
base: '#c81e2a',
|
|
109
|
+
hover: '#b51b26',
|
|
110
|
+
active: '#a21822',
|
|
111
|
+
onBase: '#ffffff',
|
|
112
|
+
onHover: '#ffffff',
|
|
113
|
+
onActive: '#ffffff',
|
|
114
|
+
text: '#a31722',
|
|
115
|
+
soft: '#fff0f1',
|
|
116
|
+
onSoft: '#81131a',
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const AERIS_MONOCHROME_DARK_STATUS_TONES = {
|
|
120
|
+
success: {
|
|
121
|
+
base: '#9fd3ae',
|
|
122
|
+
hover: '#b5dfc0',
|
|
123
|
+
active: '#8bc69c',
|
|
124
|
+
onBase: '#0b1a10',
|
|
125
|
+
onHover: '#0b1a10',
|
|
126
|
+
onActive: '#0b1a10',
|
|
127
|
+
text: '#9fd3ae',
|
|
128
|
+
soft: '#17271d',
|
|
129
|
+
onSoft: '#b5dfc0',
|
|
130
|
+
},
|
|
131
|
+
info: {
|
|
132
|
+
base: '#9ecbe0',
|
|
133
|
+
hover: '#b4d8e8',
|
|
134
|
+
active: '#88bdd6',
|
|
135
|
+
onBase: '#091923',
|
|
136
|
+
onHover: '#091923',
|
|
137
|
+
onActive: '#091923',
|
|
138
|
+
text: '#9ecbe0',
|
|
139
|
+
soft: '#17242a',
|
|
140
|
+
onSoft: '#b4d8e8',
|
|
141
|
+
},
|
|
142
|
+
warning: {
|
|
143
|
+
base: '#facc15',
|
|
144
|
+
hover: '#ffdb4d',
|
|
145
|
+
active: '#e7b900',
|
|
146
|
+
onBase: '#211600',
|
|
147
|
+
onHover: '#211600',
|
|
148
|
+
onActive: '#211600',
|
|
149
|
+
text: '#facc15',
|
|
150
|
+
soft: '#2c2508',
|
|
151
|
+
onSoft: '#ffdb4d',
|
|
152
|
+
},
|
|
153
|
+
danger: {
|
|
154
|
+
base: '#ff5c68',
|
|
155
|
+
hover: '#ff7b84',
|
|
156
|
+
active: '#e84955',
|
|
157
|
+
onBase: '#260609',
|
|
158
|
+
onHover: '#260609',
|
|
159
|
+
onActive: '#260609',
|
|
160
|
+
text: '#ff5c68',
|
|
161
|
+
soft: '#301416',
|
|
162
|
+
onSoft: '#ff8f97',
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
/** Accessible Aeris starter themes that can be passed directly to provideAeris(). */
|
|
166
|
+
const AERIS_THEME_PRESETS = {
|
|
167
|
+
earth: {
|
|
168
|
+
palette: {
|
|
169
|
+
surface: '#e8dfe0',
|
|
170
|
+
primary: '#879566',
|
|
171
|
+
secondary: '#80939b',
|
|
172
|
+
accent: '#dab692',
|
|
173
|
+
contrast: '#8f5b34',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
coastal: {
|
|
177
|
+
palette: {
|
|
178
|
+
surface: '#dfe8ee',
|
|
179
|
+
primary: '#7196b4',
|
|
180
|
+
secondary: '#6d9992',
|
|
181
|
+
accent: '#d8ad70',
|
|
182
|
+
contrast: '#31536a',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
orchid: {
|
|
186
|
+
palette: {
|
|
187
|
+
surface: '#e9e1ec',
|
|
188
|
+
primary: '#9579b2',
|
|
189
|
+
secondary: '#b68194',
|
|
190
|
+
accent: '#d1a570',
|
|
191
|
+
contrast: '#5c4b6b',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
monochrome: {
|
|
195
|
+
palette: {
|
|
196
|
+
surface: '#f4f4f4',
|
|
197
|
+
primary: '#111111',
|
|
198
|
+
secondary: '#1f1f1f',
|
|
199
|
+
accent: '#f8f8f8',
|
|
200
|
+
contrast: '#050505',
|
|
201
|
+
},
|
|
202
|
+
light: {
|
|
203
|
+
accent: '#111111',
|
|
204
|
+
page: '#f7f7f7',
|
|
205
|
+
surface: '#ffffff',
|
|
206
|
+
surface2: '#f3f3f3',
|
|
207
|
+
surface3: '#e8e8e8',
|
|
208
|
+
interactiveHover: '#e8e8e8',
|
|
209
|
+
text: '#111111',
|
|
210
|
+
text2: '#242424',
|
|
211
|
+
text3: '#454545',
|
|
212
|
+
border: '#767676',
|
|
213
|
+
borderStrong: '#111111',
|
|
214
|
+
focus: '#111111',
|
|
215
|
+
shadowXs: '0 1px 2px rgb(0 0 0 / 10%)',
|
|
216
|
+
shadowSm: '0 2px 5px rgb(0 0 0 / 14%)',
|
|
217
|
+
tones: {
|
|
218
|
+
primary: AERIS_MONOCHROME_LIGHT_PRIMARY_TONE,
|
|
219
|
+
secondary: AERIS_MONOCHROME_LIGHT_SECONDARY_TONE,
|
|
220
|
+
...AERIS_MONOCHROME_LIGHT_STATUS_TONES,
|
|
221
|
+
contrast: AERIS_MONOCHROME_LIGHT_CONTRAST_TONE,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
dark: {
|
|
225
|
+
accent: '#f5f5f5',
|
|
226
|
+
page: '#070707',
|
|
227
|
+
surface: '#0c0c0c',
|
|
228
|
+
surface2: '#151515',
|
|
229
|
+
surface3: '#202020',
|
|
230
|
+
interactiveHover: '#292929',
|
|
231
|
+
text: '#f8f8f8',
|
|
232
|
+
text2: '#ededed',
|
|
233
|
+
text3: '#d0d0d0',
|
|
234
|
+
border: '#a3a3a3',
|
|
235
|
+
borderStrong: '#ffffff',
|
|
236
|
+
focus: '#ffffff',
|
|
237
|
+
shadowXs: '0 1px 2px rgb(0 0 0 / 48%)',
|
|
238
|
+
shadowSm: '0 2px 6px rgb(0 0 0 / 62%)',
|
|
239
|
+
tones: {
|
|
240
|
+
primary: AERIS_MONOCHROME_DARK_PRIMARY_TONE,
|
|
241
|
+
secondary: AERIS_MONOCHROME_DARK_SECONDARY_TONE,
|
|
242
|
+
...AERIS_MONOCHROME_DARK_STATUS_TONES,
|
|
243
|
+
contrast: AERIS_MONOCHROME_DARK_CONTRAST_TONE,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
const AERIS_DENSITY_PRESETS = {
|
|
249
|
+
compact: {
|
|
250
|
+
controlHeight: '2.125rem',
|
|
251
|
+
controlPaddingX: '0.625rem',
|
|
252
|
+
itemHeight: '2rem',
|
|
253
|
+
itemPaddingY: '0.375rem',
|
|
254
|
+
itemPaddingX: '0.625rem',
|
|
255
|
+
gap: '0.375rem',
|
|
256
|
+
iconSize: '0.9375rem',
|
|
257
|
+
},
|
|
258
|
+
medium: {
|
|
259
|
+
controlHeight: '2.625rem',
|
|
260
|
+
controlPaddingX: '0.75rem',
|
|
261
|
+
itemHeight: '2.5rem',
|
|
262
|
+
itemPaddingY: '0.5rem',
|
|
263
|
+
itemPaddingX: '0.75rem',
|
|
264
|
+
gap: '0.5rem',
|
|
265
|
+
iconSize: '1rem',
|
|
266
|
+
},
|
|
267
|
+
comfortable: {
|
|
268
|
+
controlHeight: '3.125rem',
|
|
269
|
+
controlPaddingX: '0.875rem',
|
|
270
|
+
itemHeight: '2.875rem',
|
|
271
|
+
itemPaddingY: '0.625rem',
|
|
272
|
+
itemPaddingX: '0.875rem',
|
|
273
|
+
gap: '0.625rem',
|
|
274
|
+
iconSize: '1.0625rem',
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
const AERIS_RADIUS_PRESETS = {
|
|
278
|
+
soft: {
|
|
279
|
+
sm: '0.25rem',
|
|
280
|
+
md: '0.375rem',
|
|
281
|
+
lg: '0.625rem',
|
|
282
|
+
xl: '0.875rem',
|
|
283
|
+
control: '0.25rem',
|
|
284
|
+
pill: '999px',
|
|
285
|
+
},
|
|
286
|
+
rounded: {
|
|
287
|
+
sm: '0.4375rem',
|
|
288
|
+
md: '0.6875rem',
|
|
289
|
+
lg: '1.125rem',
|
|
290
|
+
xl: '1.5rem',
|
|
291
|
+
control: '0.4375rem',
|
|
292
|
+
pill: '999px',
|
|
293
|
+
},
|
|
294
|
+
pill: {
|
|
295
|
+
sm: '0.75rem',
|
|
296
|
+
md: '1.125rem',
|
|
297
|
+
lg: '1.875rem',
|
|
298
|
+
xl: '2.25rem',
|
|
299
|
+
control: '999px',
|
|
300
|
+
pill: '999px',
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
const AERIS_DEFAULT_THEME = {
|
|
304
|
+
palette: {
|
|
305
|
+
...AERIS_THEME_PRESETS.earth.palette,
|
|
306
|
+
mist: AERIS_THEME_PRESETS.earth.palette.surface,
|
|
307
|
+
sage: AERIS_THEME_PRESETS.earth.palette.primary,
|
|
308
|
+
cloud: AERIS_THEME_PRESETS.earth.palette.secondary,
|
|
309
|
+
sand: AERIS_THEME_PRESETS.earth.palette.accent,
|
|
310
|
+
umber: AERIS_THEME_PRESETS.earth.palette.contrast,
|
|
311
|
+
},
|
|
312
|
+
light: {},
|
|
313
|
+
dark: {},
|
|
314
|
+
radius: 'rounded',
|
|
315
|
+
radii: AERIS_RADIUS_PRESETS,
|
|
316
|
+
density: 'medium',
|
|
317
|
+
densities: AERIS_DENSITY_PRESETS,
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const ACHROMATIC_CHROMA = 0.01;
|
|
321
|
+
const GAMUT_SEARCH_STEPS = 24;
|
|
322
|
+
const SRGB_GAMUT_TOLERANCE = 0.000_000_1;
|
|
323
|
+
function parseAerisColor(value) {
|
|
324
|
+
const color = value.trim().toLowerCase();
|
|
325
|
+
if (color === 'black')
|
|
326
|
+
return { red: 0, green: 0, blue: 0 };
|
|
327
|
+
if (color === 'white')
|
|
328
|
+
return { red: 255, green: 255, blue: 255 };
|
|
329
|
+
if (color.startsWith('#'))
|
|
330
|
+
return parseHex(color);
|
|
331
|
+
if (color.startsWith('rgb(') || color.startsWith('rgba('))
|
|
332
|
+
return parseRgb(color);
|
|
333
|
+
if (color.startsWith('hsl(') || color.startsWith('hsla('))
|
|
334
|
+
return parseHsl(color);
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
function mixAerisColor(from, to, amount) {
|
|
338
|
+
const weight = clampUnit(amount);
|
|
339
|
+
const start = parseAerisColor(from);
|
|
340
|
+
const end = parseAerisColor(to);
|
|
341
|
+
if (!start || !end) {
|
|
342
|
+
const startWeight = formatPercentage((1 - weight) * 100);
|
|
343
|
+
return `color-mix(in oklch, ${from} ${startWeight}%, ${to})`;
|
|
344
|
+
}
|
|
345
|
+
return formatAerisHex(mixAerisRgb(start, end, weight));
|
|
346
|
+
}
|
|
347
|
+
function aerisContrastRatio(first, second) {
|
|
348
|
+
const firstColor = parseAerisColor(first);
|
|
349
|
+
const secondColor = parseAerisColor(second);
|
|
350
|
+
if (!firstColor || !secondColor)
|
|
351
|
+
return null;
|
|
352
|
+
return aerisRgbContrastRatio(firstColor, secondColor);
|
|
353
|
+
}
|
|
354
|
+
function aerisRgbContrastRatio(first, second) {
|
|
355
|
+
const firstLuminance = relativeLuminance(first);
|
|
356
|
+
const secondLuminance = relativeLuminance(second);
|
|
357
|
+
const lighter = Math.max(firstLuminance, secondLuminance);
|
|
358
|
+
const darker = Math.min(firstLuminance, secondLuminance);
|
|
359
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
360
|
+
}
|
|
361
|
+
function mixAerisRgb(from, to, amount) {
|
|
362
|
+
const weight = clampUnit(amount);
|
|
363
|
+
if (weight === 0)
|
|
364
|
+
return { ...from };
|
|
365
|
+
if (weight === 1)
|
|
366
|
+
return { ...to };
|
|
367
|
+
const start = oklabToOklch(rgbToOklab(from));
|
|
368
|
+
const end = oklabToOklch(rgbToOklab(to));
|
|
369
|
+
const mixed = {
|
|
370
|
+
lightness: interpolate(start.lightness, end.lightness, weight),
|
|
371
|
+
chroma: interpolate(start.chroma, end.chroma, weight),
|
|
372
|
+
hue: interpolateHue(start.hue, end.hue, weight),
|
|
373
|
+
};
|
|
374
|
+
return oklchToGamutMappedRgb(mixed);
|
|
375
|
+
}
|
|
376
|
+
function formatAerisHex(color) {
|
|
377
|
+
const channel = (value) => Math.round(clampChannel(value)).toString(16).padStart(2, '0');
|
|
378
|
+
return `#${channel(color.red)}${channel(color.green)}${channel(color.blue)}`;
|
|
379
|
+
}
|
|
380
|
+
function relativeLuminance(color) {
|
|
381
|
+
const linear = (value) => {
|
|
382
|
+
const channel = value / 255;
|
|
383
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
384
|
+
};
|
|
385
|
+
return 0.2126 * linear(color.red) + 0.7152 * linear(color.green) + 0.0722 * linear(color.blue);
|
|
386
|
+
}
|
|
387
|
+
function rgbToOklab(color) {
|
|
388
|
+
const red = srgbToLinear(clampChannel(color.red) / 255);
|
|
389
|
+
const green = srgbToLinear(clampChannel(color.green) / 255);
|
|
390
|
+
const blue = srgbToLinear(clampChannel(color.blue) / 255);
|
|
391
|
+
const l = 0.4122214708 * red + 0.5363325363 * green + 0.0514459929 * blue;
|
|
392
|
+
const m = 0.2119034982 * red + 0.6806995451 * green + 0.1073969566 * blue;
|
|
393
|
+
const s = 0.0883024619 * red + 0.2817188376 * green + 0.6299787005 * blue;
|
|
394
|
+
const lRoot = Math.cbrt(l);
|
|
395
|
+
const mRoot = Math.cbrt(m);
|
|
396
|
+
const sRoot = Math.cbrt(s);
|
|
397
|
+
return {
|
|
398
|
+
lightness: 0.2104542553 * lRoot + 0.793617785 * mRoot - 0.0040720468 * sRoot,
|
|
399
|
+
a: 1.9779984951 * lRoot - 2.428592205 * mRoot + 0.4505937099 * sRoot,
|
|
400
|
+
b: 0.0259040371 * lRoot + 0.7827717662 * mRoot - 0.808675766 * sRoot,
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function oklabToOklch(color) {
|
|
404
|
+
const chroma = Math.hypot(color.a, color.b);
|
|
405
|
+
const achromatic = chroma < ACHROMATIC_CHROMA;
|
|
406
|
+
return {
|
|
407
|
+
lightness: color.lightness,
|
|
408
|
+
chroma: achromatic ? 0 : chroma,
|
|
409
|
+
hue: achromatic ? null : normalizeHue((Math.atan2(color.b, color.a) * 180) / Math.PI),
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function oklchToGamutMappedRgb(color) {
|
|
413
|
+
const direct = oklchToSrgb(color);
|
|
414
|
+
if (isInSrgbGamut(direct))
|
|
415
|
+
return toRgbChannels(direct);
|
|
416
|
+
let minimumChroma = 0;
|
|
417
|
+
let maximumChroma = color.chroma;
|
|
418
|
+
let mapped = oklchToSrgb({ ...color, chroma: minimumChroma });
|
|
419
|
+
for (let step = 0; step < GAMUT_SEARCH_STEPS; step += 1) {
|
|
420
|
+
const chroma = (minimumChroma + maximumChroma) / 2;
|
|
421
|
+
const candidate = oklchToSrgb({ ...color, chroma });
|
|
422
|
+
if (isInSrgbGamut(candidate)) {
|
|
423
|
+
minimumChroma = chroma;
|
|
424
|
+
mapped = candidate;
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
maximumChroma = chroma;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return toRgbChannels(mapped);
|
|
431
|
+
}
|
|
432
|
+
function oklchToSrgb(color) {
|
|
433
|
+
const hueRadians = ((color.hue ?? 0) * Math.PI) / 180;
|
|
434
|
+
const a = color.chroma * Math.cos(hueRadians);
|
|
435
|
+
const b = color.chroma * Math.sin(hueRadians);
|
|
436
|
+
const lRoot = color.lightness + 0.3963377774 * a + 0.2158037573 * b;
|
|
437
|
+
const mRoot = color.lightness - 0.1055613458 * a - 0.0638541728 * b;
|
|
438
|
+
const sRoot = color.lightness - 0.0894841775 * a - 1.291485548 * b;
|
|
439
|
+
const l = lRoot ** 3;
|
|
440
|
+
const m = mRoot ** 3;
|
|
441
|
+
const s = sRoot ** 3;
|
|
442
|
+
return [
|
|
443
|
+
linearToSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
|
|
444
|
+
linearToSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
|
|
445
|
+
linearToSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
|
|
446
|
+
];
|
|
447
|
+
}
|
|
448
|
+
function interpolateHue(from, to, amount) {
|
|
449
|
+
if (from === null)
|
|
450
|
+
return to;
|
|
451
|
+
if (to === null)
|
|
452
|
+
return from;
|
|
453
|
+
const difference = ((to - from + 540) % 360) - 180;
|
|
454
|
+
return normalizeHue(from + difference * amount);
|
|
455
|
+
}
|
|
456
|
+
function srgbToLinear(channel) {
|
|
457
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
458
|
+
}
|
|
459
|
+
function linearToSrgb(channel) {
|
|
460
|
+
return channel <= 0.0031308 ? channel * 12.92 : 1.055 * channel ** (1 / 2.4) - 0.055;
|
|
461
|
+
}
|
|
462
|
+
function isInSrgbGamut(color) {
|
|
463
|
+
return color.every((channel) => channel >= -SRGB_GAMUT_TOLERANCE && channel <= 1 + SRGB_GAMUT_TOLERANCE);
|
|
464
|
+
}
|
|
465
|
+
function toRgbChannels(color) {
|
|
466
|
+
return {
|
|
467
|
+
red: clampUnit(color[0]) * 255,
|
|
468
|
+
green: clampUnit(color[1]) * 255,
|
|
469
|
+
blue: clampUnit(color[2]) * 255,
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function interpolate(from, to, amount) {
|
|
473
|
+
return from + (to - from) * amount;
|
|
474
|
+
}
|
|
475
|
+
function normalizeHue(hue) {
|
|
476
|
+
return ((hue % 360) + 360) % 360;
|
|
477
|
+
}
|
|
478
|
+
function formatPercentage(value) {
|
|
479
|
+
return Number(value.toFixed(4)).toString();
|
|
480
|
+
}
|
|
481
|
+
function parseHex(value) {
|
|
482
|
+
const hex = value.slice(1);
|
|
483
|
+
if (!/^[\da-f]{3}([\da-f]{3})?$/i.test(hex))
|
|
484
|
+
return null;
|
|
485
|
+
const normalized = hex.length === 3 ? [...hex].map((character) => character.repeat(2)).join('') : hex;
|
|
486
|
+
return {
|
|
487
|
+
red: Number.parseInt(normalized.slice(0, 2), 16),
|
|
488
|
+
green: Number.parseInt(normalized.slice(2, 4), 16),
|
|
489
|
+
blue: Number.parseInt(normalized.slice(4, 6), 16),
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function parseRgb(value) {
|
|
493
|
+
const functionalValue = splitFunctionalColor(value);
|
|
494
|
+
if (!functionalValue)
|
|
495
|
+
return null;
|
|
496
|
+
const body = functionalValue.channels;
|
|
497
|
+
if (!body)
|
|
498
|
+
return null;
|
|
499
|
+
const channels = body.replaceAll(',', ' ').split(/\s+/).filter(Boolean);
|
|
500
|
+
if (channels.length !== 3)
|
|
501
|
+
return null;
|
|
502
|
+
const parsed = channels.map((channel) => {
|
|
503
|
+
const numeric = Number.parseFloat(channel);
|
|
504
|
+
if (!Number.isFinite(numeric))
|
|
505
|
+
return Number.NaN;
|
|
506
|
+
return channel.endsWith('%') ? numeric * 2.55 : numeric;
|
|
507
|
+
});
|
|
508
|
+
if (parsed.some((channel) => !Number.isFinite(channel)))
|
|
509
|
+
return null;
|
|
510
|
+
return {
|
|
511
|
+
red: clampChannel(parsed[0]),
|
|
512
|
+
green: clampChannel(parsed[1]),
|
|
513
|
+
blue: clampChannel(parsed[2]),
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function parseHsl(value) {
|
|
517
|
+
const functionalValue = splitFunctionalColor(value);
|
|
518
|
+
if (!functionalValue)
|
|
519
|
+
return null;
|
|
520
|
+
const body = functionalValue.channels;
|
|
521
|
+
if (!body)
|
|
522
|
+
return null;
|
|
523
|
+
const channels = body.replaceAll(',', ' ').split(/\s+/).filter(Boolean);
|
|
524
|
+
if (channels.length !== 3 || !channels[1]?.endsWith('%') || !channels[2]?.endsWith('%')) {
|
|
525
|
+
return null;
|
|
526
|
+
}
|
|
527
|
+
const hue = Number.parseFloat(channels[0]);
|
|
528
|
+
const saturation = Number.parseFloat(channels[1]) / 100;
|
|
529
|
+
const lightness = Number.parseFloat(channels[2]) / 100;
|
|
530
|
+
if (![hue, saturation, lightness].every(Number.isFinite))
|
|
531
|
+
return null;
|
|
532
|
+
const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
533
|
+
const section = (((hue % 360) + 360) % 360) / 60;
|
|
534
|
+
const secondary = chroma * (1 - Math.abs((section % 2) - 1));
|
|
535
|
+
const [red, green, blue] = section < 1
|
|
536
|
+
? [chroma, secondary, 0]
|
|
537
|
+
: section < 2
|
|
538
|
+
? [secondary, chroma, 0]
|
|
539
|
+
: section < 3
|
|
540
|
+
? [0, chroma, secondary]
|
|
541
|
+
: section < 4
|
|
542
|
+
? [0, secondary, chroma]
|
|
543
|
+
: section < 5
|
|
544
|
+
? [secondary, 0, chroma]
|
|
545
|
+
: [chroma, 0, secondary];
|
|
546
|
+
const match = lightness - chroma / 2;
|
|
547
|
+
return {
|
|
548
|
+
red: clampChannel((red + match) * 255),
|
|
549
|
+
green: clampChannel((green + match) * 255),
|
|
550
|
+
blue: clampChannel((blue + match) * 255),
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function splitFunctionalColor(value) {
|
|
554
|
+
const body = value.slice(value.indexOf('(') + 1, -1);
|
|
555
|
+
const [channels, alpha, ...remainder] = body.split('/').map((part) => part.trim());
|
|
556
|
+
if (!channels || remainder.length > 0)
|
|
557
|
+
return null;
|
|
558
|
+
if (alpha !== undefined && !isOpaqueAlpha(alpha))
|
|
559
|
+
return null;
|
|
560
|
+
return { channels };
|
|
561
|
+
}
|
|
562
|
+
function isOpaqueAlpha(value) {
|
|
563
|
+
const numeric = Number.parseFloat(value);
|
|
564
|
+
if (!Number.isFinite(numeric))
|
|
565
|
+
return false;
|
|
566
|
+
return value.endsWith('%') ? numeric === 100 : numeric === 1;
|
|
567
|
+
}
|
|
568
|
+
function clampChannel(value) {
|
|
569
|
+
return Math.min(255, Math.max(0, value));
|
|
570
|
+
}
|
|
571
|
+
function clampUnit(value) {
|
|
572
|
+
return Math.min(1, Math.max(0, value));
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Version of the deterministic algorithm used to derive Aeris color tokens.
|
|
577
|
+
*
|
|
578
|
+
* A change to an existing derived color for the same complete theme input must
|
|
579
|
+
* increment this value. Build-time configurations can pin the version to make
|
|
580
|
+
* an intentional regeneration step explicit during upgrades.
|
|
581
|
+
*/
|
|
582
|
+
const AERIS_COLOR_DERIVATION_VERSION = 1;
|
|
583
|
+
|
|
584
|
+
const LIGHT_TEXT = '#222222';
|
|
585
|
+
const LIGHT_TEXT_SECONDARY = '#555555';
|
|
586
|
+
const LIGHT_TEXT_TERTIARY = '#707070';
|
|
587
|
+
const DARK_TEXT = '#f4f4f4';
|
|
588
|
+
const DARK_TEXT_SECONDARY = '#c5c5c5';
|
|
589
|
+
const DARK_TEXT_TERTIARY = '#9d9d9d';
|
|
590
|
+
/** Resolves palette-aware surfaces and borders while keeping ordinary text achromatic. */
|
|
591
|
+
function resolveAerisFoundation(theme, mode) {
|
|
592
|
+
const scheme = theme[mode];
|
|
593
|
+
const surfaceSeed = theme.palette.surface;
|
|
594
|
+
const borderSeed = theme.palette.secondary;
|
|
595
|
+
if (mode === 'light') {
|
|
596
|
+
const surface2 = scheme.surface2 ?? mixAerisColor('#f7f6f2', surfaceSeed, 0.24);
|
|
597
|
+
return {
|
|
598
|
+
page: scheme.page ?? mixAerisColor('#faf9f7', surfaceSeed, 0.18),
|
|
599
|
+
surface: scheme.surface ?? '#ffffff',
|
|
600
|
+
surface2,
|
|
601
|
+
surface3: scheme.surface3 ?? mixAerisColor('#f1f0eb', surfaceSeed, 0.42),
|
|
602
|
+
interactiveHover: scheme.interactiveHover ?? mixAerisColor(surface2, theme.palette.primary, 0.1),
|
|
603
|
+
text: scheme.text ?? LIGHT_TEXT,
|
|
604
|
+
text2: scheme.text2 ?? LIGHT_TEXT_SECONDARY,
|
|
605
|
+
text3: scheme.text3 ?? LIGHT_TEXT_TERTIARY,
|
|
606
|
+
border: scheme.border ?? mixAerisColor('#5f625d', borderSeed, 0.42),
|
|
607
|
+
borderStrong: scheme.borderStrong ?? mixAerisColor('#444842', borderSeed, 0.3),
|
|
608
|
+
focus: scheme.focus ?? mixAerisColor('#1d2119', theme.palette.primary, 0.5),
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
const surface2 = scheme.surface2 ?? mixAerisColor('#171b22', surfaceSeed, 0.008);
|
|
612
|
+
return {
|
|
613
|
+
page: scheme.page ?? mixAerisColor('#090b0f', surfaceSeed, 0.004),
|
|
614
|
+
surface: scheme.surface ?? mixAerisColor('#101318', surfaceSeed, 0.006),
|
|
615
|
+
surface2,
|
|
616
|
+
surface3: scheme.surface3 ?? mixAerisColor('#202632', surfaceSeed, 0.01),
|
|
617
|
+
interactiveHover: scheme.interactiveHover ?? mixAerisColor(surface2, theme.palette.primary, 0.12),
|
|
618
|
+
text: scheme.text ?? DARK_TEXT,
|
|
619
|
+
text2: scheme.text2 ?? DARK_TEXT_SECONDARY,
|
|
620
|
+
text3: scheme.text3 ?? DARK_TEXT_TERTIARY,
|
|
621
|
+
border: scheme.border ?? mixAerisColor('#70746d', borderSeed, 0.35),
|
|
622
|
+
borderStrong: scheme.borderStrong ?? mixAerisColor('#8d9289', borderSeed, 0.3),
|
|
623
|
+
focus: scheme.focus ?? mixAerisColor('#ffffff', theme.palette.primary, 0.56),
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
const AERIS_SEMANTIC_TONE_NAMES = [
|
|
628
|
+
'primary',
|
|
629
|
+
'secondary',
|
|
630
|
+
'success',
|
|
631
|
+
'info',
|
|
632
|
+
'warning',
|
|
633
|
+
'danger',
|
|
634
|
+
'contrast',
|
|
635
|
+
];
|
|
636
|
+
const LIGHT_BASES = {
|
|
637
|
+
success: '#52744d',
|
|
638
|
+
info: '#4f7180',
|
|
639
|
+
warning: '#c38600',
|
|
640
|
+
danger: '#c81e2a',
|
|
641
|
+
};
|
|
642
|
+
const DARK_BASES = {
|
|
643
|
+
success: '#91b78a',
|
|
644
|
+
info: '#91b7c8',
|
|
645
|
+
warning: '#facc15',
|
|
646
|
+
danger: '#ff5c68',
|
|
647
|
+
};
|
|
648
|
+
const DARK_FOREGROUND = '#111411';
|
|
649
|
+
const LIGHT_FOREGROUND = '#ffffff';
|
|
650
|
+
const REQUIRED_TEXT_CONTRAST = 4.5;
|
|
651
|
+
const LIGHT_HOVER_MIX = 0.04;
|
|
652
|
+
const LIGHT_ACTIVE_MIX = 0.05;
|
|
653
|
+
const DARK_HOVER_MIX = 0.2;
|
|
654
|
+
const DARK_ACTIVE_MIX = 0.28;
|
|
655
|
+
function resolveAerisSemanticTones(theme, mode) {
|
|
656
|
+
const scheme = theme[mode];
|
|
657
|
+
const surface = resolveSurface(theme, scheme, mode);
|
|
658
|
+
const result = {};
|
|
659
|
+
for (const name of AERIS_SEMANTIC_TONE_NAMES) {
|
|
660
|
+
const overrides = scheme.tones?.[name] ?? {};
|
|
661
|
+
const base = overrides.base ?? defaultBase(theme, mode, name);
|
|
662
|
+
const boundary = overrides.boundary ?? base;
|
|
663
|
+
const hover = overrides.hover ?? deriveState(base, mode, stateMix(mode, 'hover'));
|
|
664
|
+
const active = overrides.active ?? deriveState(base, mode, stateMix(mode, 'active'));
|
|
665
|
+
const soft = overrides.soft ?? mixAerisColor(surface, base, mode === 'dark' ? 0.2 : 0.14);
|
|
666
|
+
const text = overrides.text ?? ensureTextContrast(base, surface, mode);
|
|
667
|
+
const onBase = overrides.onBase ?? contrastingForeground(base);
|
|
668
|
+
const onHover = overrides.onHover ?? contrastingForeground(hover, onBase);
|
|
669
|
+
const onActive = overrides.onActive ?? contrastingForeground(active, onHover);
|
|
670
|
+
const onSoft = overrides.onSoft ?? ensureTextContrast(text, soft, mode);
|
|
671
|
+
result[name] = {
|
|
672
|
+
base,
|
|
673
|
+
boundary,
|
|
674
|
+
hover,
|
|
675
|
+
active,
|
|
676
|
+
onBase,
|
|
677
|
+
onHover,
|
|
678
|
+
onActive,
|
|
679
|
+
text,
|
|
680
|
+
soft,
|
|
681
|
+
onSoft,
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
return result;
|
|
685
|
+
}
|
|
686
|
+
function defaultBase(theme, mode, name) {
|
|
687
|
+
const fixed = (mode === 'dark' ? DARK_BASES : LIGHT_BASES)[name];
|
|
688
|
+
if (fixed)
|
|
689
|
+
return fixed;
|
|
690
|
+
const seed = name === 'primary'
|
|
691
|
+
? theme.palette.primary
|
|
692
|
+
: name === 'secondary'
|
|
693
|
+
? theme.palette.secondary
|
|
694
|
+
: theme.palette.contrast;
|
|
695
|
+
if (mode === 'light')
|
|
696
|
+
return seed;
|
|
697
|
+
return mixAerisColor(seed, LIGHT_FOREGROUND, name === 'contrast' ? 0.29 : 0.22);
|
|
698
|
+
}
|
|
699
|
+
function resolveSurface(theme, scheme, mode) {
|
|
700
|
+
if (scheme.surface)
|
|
701
|
+
return scheme.surface;
|
|
702
|
+
return mode === 'light'
|
|
703
|
+
? LIGHT_FOREGROUND
|
|
704
|
+
: mixAerisColor('#1f221c', theme.palette.surface, 0.02);
|
|
705
|
+
}
|
|
706
|
+
function deriveState(base, mode, amount) {
|
|
707
|
+
return mixAerisColor(base, mode === 'light' ? DARK_FOREGROUND : LIGHT_FOREGROUND, amount);
|
|
708
|
+
}
|
|
709
|
+
function stateMix(mode, state) {
|
|
710
|
+
if (mode === 'light')
|
|
711
|
+
return state === 'hover' ? LIGHT_HOVER_MIX : LIGHT_ACTIVE_MIX;
|
|
712
|
+
return state === 'hover' ? DARK_HOVER_MIX : DARK_ACTIVE_MIX;
|
|
713
|
+
}
|
|
714
|
+
function contrastingForeground(color, fallback = DARK_FOREGROUND) {
|
|
715
|
+
const background = parseAerisColor(color);
|
|
716
|
+
if (!background)
|
|
717
|
+
return fallback;
|
|
718
|
+
const fallbackColor = parseAerisColor(fallback);
|
|
719
|
+
if (fallbackColor && aerisRgbContrastRatio(background, fallbackColor) >= REQUIRED_TEXT_CONTRAST) {
|
|
720
|
+
return fallback;
|
|
721
|
+
}
|
|
722
|
+
const darkContrast = aerisRgbContrastRatio(background, parseAerisColor(DARK_FOREGROUND));
|
|
723
|
+
const lightContrast = aerisRgbContrastRatio(background, parseAerisColor(LIGHT_FOREGROUND));
|
|
724
|
+
return lightContrast > darkContrast ? LIGHT_FOREGROUND : DARK_FOREGROUND;
|
|
725
|
+
}
|
|
726
|
+
function ensureTextContrast(color, background, mode) {
|
|
727
|
+
const foreground = parseAerisColor(color);
|
|
728
|
+
const surface = parseAerisColor(background);
|
|
729
|
+
if (!foreground || !surface)
|
|
730
|
+
return color;
|
|
731
|
+
if (aerisRgbContrastRatio(foreground, surface) >= REQUIRED_TEXT_CONTRAST)
|
|
732
|
+
return color;
|
|
733
|
+
const target = parseAerisColor(mode === 'light' ? DARK_FOREGROUND : LIGHT_FOREGROUND);
|
|
734
|
+
for (let amount = 0.05; amount <= 1; amount += 0.05) {
|
|
735
|
+
const candidate = mixAerisRgb(foreground, target, amount);
|
|
736
|
+
if (aerisRgbContrastRatio(candidate, surface) >= REQUIRED_TEXT_CONTRAST) {
|
|
737
|
+
return formatAerisHex(candidate);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return formatAerisHex(target);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const TONE_NAMES = [
|
|
744
|
+
'primary',
|
|
745
|
+
'secondary',
|
|
746
|
+
'success',
|
|
747
|
+
'info',
|
|
748
|
+
'warning',
|
|
749
|
+
'danger',
|
|
750
|
+
'contrast',
|
|
751
|
+
];
|
|
752
|
+
function auditAerisThemeContrast(theme, mode) {
|
|
753
|
+
const scheme = resolveSchemeColors(theme, mode);
|
|
754
|
+
const tones = resolveAerisSemanticTones(theme, mode);
|
|
755
|
+
const checks = [
|
|
756
|
+
createCheck({
|
|
757
|
+
id: 'text-page',
|
|
758
|
+
label: 'Primary text on page',
|
|
759
|
+
description: 'Default body content against the application page.',
|
|
760
|
+
category: 'text',
|
|
761
|
+
kind: 'text',
|
|
762
|
+
foreground: scheme.text,
|
|
763
|
+
background: scheme.page,
|
|
764
|
+
requiredRatio: 4.5,
|
|
765
|
+
guidance: 'Increase the difference between the text and page colors.',
|
|
766
|
+
}),
|
|
767
|
+
createCheck({
|
|
768
|
+
id: 'text-surface',
|
|
769
|
+
label: 'Primary text on surface',
|
|
770
|
+
description: 'Default content inside cards, panels, and overlays.',
|
|
771
|
+
category: 'text',
|
|
772
|
+
kind: 'text',
|
|
773
|
+
foreground: scheme.text,
|
|
774
|
+
background: scheme.surface,
|
|
775
|
+
requiredRatio: 4.5,
|
|
776
|
+
guidance: 'Increase the difference between the text and surface colors.',
|
|
777
|
+
}),
|
|
778
|
+
createCheck({
|
|
779
|
+
id: 'text-secondary-surface',
|
|
780
|
+
label: 'Secondary text on surface',
|
|
781
|
+
description: 'Supporting descriptions and metadata on a primary surface.',
|
|
782
|
+
category: 'text',
|
|
783
|
+
kind: 'text',
|
|
784
|
+
foreground: scheme.text2,
|
|
785
|
+
background: scheme.surface,
|
|
786
|
+
requiredRatio: 4.5,
|
|
787
|
+
guidance: 'Strengthen the secondary text color without reducing hierarchy.',
|
|
788
|
+
}),
|
|
789
|
+
createCheck({
|
|
790
|
+
id: 'text-tertiary-surface',
|
|
791
|
+
label: 'Tertiary text on surface',
|
|
792
|
+
description: 'Low-emphasis visible text on a primary surface.',
|
|
793
|
+
category: 'text',
|
|
794
|
+
kind: 'text',
|
|
795
|
+
foreground: scheme.text3,
|
|
796
|
+
background: scheme.surface,
|
|
797
|
+
requiredRatio: 4.5,
|
|
798
|
+
guidance: 'Darken or lighten the tertiary text until it remains readable.',
|
|
799
|
+
}),
|
|
800
|
+
createCheck({
|
|
801
|
+
id: 'text-secondary-raised',
|
|
802
|
+
label: 'Secondary text on raised surface',
|
|
803
|
+
description: 'Supporting content against the secondary surface layer.',
|
|
804
|
+
category: 'text',
|
|
805
|
+
kind: 'text',
|
|
806
|
+
foreground: scheme.text2,
|
|
807
|
+
background: scheme.surface2,
|
|
808
|
+
requiredRatio: 4.5,
|
|
809
|
+
guidance: 'Increase secondary text contrast against the raised surface.',
|
|
810
|
+
}),
|
|
811
|
+
createCheck({
|
|
812
|
+
id: 'text-interactive-hover',
|
|
813
|
+
label: 'Primary text on neutral hover',
|
|
814
|
+
description: 'Default item content against the shared neutral interactive hover surface.',
|
|
815
|
+
category: 'interaction',
|
|
816
|
+
kind: 'text',
|
|
817
|
+
foreground: scheme.text,
|
|
818
|
+
background: scheme.interactiveHover,
|
|
819
|
+
requiredRatio: 4.5,
|
|
820
|
+
guidance: 'Adjust interactiveHover until default content remains readable.',
|
|
821
|
+
}),
|
|
822
|
+
...TONE_NAMES.flatMap((name) => interactionChecks(name, tones[name], scheme.surface)),
|
|
823
|
+
createCheck({
|
|
824
|
+
id: 'focus-surface',
|
|
825
|
+
label: 'Focus indicator on surface',
|
|
826
|
+
description: 'Focus token against cards, controls, and overlay surfaces.',
|
|
827
|
+
category: 'focus',
|
|
828
|
+
kind: 'non-text',
|
|
829
|
+
foreground: scheme.focus,
|
|
830
|
+
background: scheme.surface,
|
|
831
|
+
requiredRatio: 3,
|
|
832
|
+
guidance: 'Strengthen the focus color against the primary surface.',
|
|
833
|
+
}),
|
|
834
|
+
createCheck({
|
|
835
|
+
id: 'focus-page',
|
|
836
|
+
label: 'Focus indicator on page',
|
|
837
|
+
description: 'Focus token against the application page background.',
|
|
838
|
+
category: 'focus',
|
|
839
|
+
kind: 'non-text',
|
|
840
|
+
foreground: scheme.focus,
|
|
841
|
+
background: scheme.page,
|
|
842
|
+
requiredRatio: 3,
|
|
843
|
+
guidance: 'Strengthen the focus color against the page background.',
|
|
844
|
+
}),
|
|
845
|
+
createCheck({
|
|
846
|
+
id: 'border-surface',
|
|
847
|
+
label: 'Standard border on surface',
|
|
848
|
+
description: 'Default structural boundary against a primary surface.',
|
|
849
|
+
category: 'boundary',
|
|
850
|
+
kind: 'non-text',
|
|
851
|
+
foreground: scheme.border,
|
|
852
|
+
background: scheme.surface,
|
|
853
|
+
requiredRatio: 3,
|
|
854
|
+
guidance: 'Use the stronger border token when the boundary identifies a control.',
|
|
855
|
+
}),
|
|
856
|
+
createCheck({
|
|
857
|
+
id: 'border-strong-surface',
|
|
858
|
+
label: 'Control border on surface',
|
|
859
|
+
description: 'Strong border used to identify interactive controls.',
|
|
860
|
+
category: 'boundary',
|
|
861
|
+
kind: 'non-text',
|
|
862
|
+
foreground: scheme.borderStrong,
|
|
863
|
+
background: scheme.surface,
|
|
864
|
+
requiredRatio: 3,
|
|
865
|
+
guidance: 'Increase the strong border contrast against the primary surface.',
|
|
866
|
+
}),
|
|
867
|
+
createCheck({
|
|
868
|
+
id: 'border-strong-raised',
|
|
869
|
+
label: 'Control border on raised surface',
|
|
870
|
+
description: 'Strong border used on the secondary surface layer.',
|
|
871
|
+
category: 'boundary',
|
|
872
|
+
kind: 'non-text',
|
|
873
|
+
foreground: scheme.borderStrong,
|
|
874
|
+
background: scheme.surface2,
|
|
875
|
+
requiredRatio: 3,
|
|
876
|
+
guidance: 'Increase the strong border contrast against the raised surface.',
|
|
877
|
+
}),
|
|
878
|
+
...TONE_NAMES.map((name) => createCheck({
|
|
879
|
+
id: `${name}-boundary`,
|
|
880
|
+
label: `${titleCase(name)} control boundary`,
|
|
881
|
+
description: `Solid ${name} controls against a primary surface.`,
|
|
882
|
+
category: 'boundary',
|
|
883
|
+
kind: 'non-text',
|
|
884
|
+
foreground: tones[name].boundary,
|
|
885
|
+
background: scheme.surface,
|
|
886
|
+
requiredRatio: 3,
|
|
887
|
+
guidance: `Adjust tones.${name}.boundary so solid controls remain identifiable.`,
|
|
888
|
+
})),
|
|
889
|
+
];
|
|
890
|
+
const passed = checks.filter((check) => check.status === 'pass').length;
|
|
891
|
+
const failed = checks.filter((check) => check.status === 'fail').length;
|
|
892
|
+
const unresolved = checks.filter((check) => check.status === 'unresolved').length;
|
|
893
|
+
const resolvedTotal = passed + failed;
|
|
894
|
+
return {
|
|
895
|
+
mode,
|
|
896
|
+
checks,
|
|
897
|
+
passed,
|
|
898
|
+
failed,
|
|
899
|
+
unresolved,
|
|
900
|
+
total: checks.length,
|
|
901
|
+
score: resolvedTotal > 0 ? Math.round((passed / resolvedTotal) * 100) : 0,
|
|
902
|
+
status: failed > 0 ? 'fail' : unresolved > 0 ? 'unresolved' : 'pass',
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
function interactionChecks(name, tone, surface) {
|
|
906
|
+
const label = titleCase(name);
|
|
907
|
+
return [
|
|
908
|
+
createCheck({
|
|
909
|
+
id: `${name}-base-content`,
|
|
910
|
+
label: `${label} solid content`,
|
|
911
|
+
description: 'Text and icons on the default solid background.',
|
|
912
|
+
category: 'interaction',
|
|
913
|
+
kind: 'text',
|
|
914
|
+
foreground: tone.onBase,
|
|
915
|
+
background: tone.base,
|
|
916
|
+
requiredRatio: 4.5,
|
|
917
|
+
guidance: `Set tones.${name}.onBase to a more contrasting foreground.`,
|
|
918
|
+
}),
|
|
919
|
+
createCheck({
|
|
920
|
+
id: `${name}-hover-content`,
|
|
921
|
+
label: `${label} hover content`,
|
|
922
|
+
description: 'Text and icons on the hover background.',
|
|
923
|
+
category: 'interaction',
|
|
924
|
+
kind: 'text',
|
|
925
|
+
foreground: tone.onHover,
|
|
926
|
+
background: tone.hover,
|
|
927
|
+
requiredRatio: 4.5,
|
|
928
|
+
guidance: `Adjust tones.${name}.hover or tones.${name}.onHover.`,
|
|
929
|
+
}),
|
|
930
|
+
createCheck({
|
|
931
|
+
id: `${name}-active-content`,
|
|
932
|
+
label: `${label} pressed content`,
|
|
933
|
+
description: 'Text and icons on the pressed background.',
|
|
934
|
+
category: 'interaction',
|
|
935
|
+
kind: 'text',
|
|
936
|
+
foreground: tone.onActive,
|
|
937
|
+
background: tone.active,
|
|
938
|
+
requiredRatio: 4.5,
|
|
939
|
+
guidance: `Adjust tones.${name}.active or tones.${name}.onActive.`,
|
|
940
|
+
}),
|
|
941
|
+
createCheck({
|
|
942
|
+
id: `${name}-text-surface`,
|
|
943
|
+
label: `${label} text treatment`,
|
|
944
|
+
description: 'Outline, text, and link content on a primary surface.',
|
|
945
|
+
category: 'interaction',
|
|
946
|
+
kind: 'text',
|
|
947
|
+
foreground: tone.text,
|
|
948
|
+
background: surface,
|
|
949
|
+
requiredRatio: 4.5,
|
|
950
|
+
guidance: `Set tones.${name}.text to a readable surface foreground.`,
|
|
951
|
+
}),
|
|
952
|
+
createCheck({
|
|
953
|
+
id: `${name}-soft-content`,
|
|
954
|
+
label: `${label} soft content`,
|
|
955
|
+
description: 'Text and icons on the low-emphasis semantic background.',
|
|
956
|
+
category: 'interaction',
|
|
957
|
+
kind: 'text',
|
|
958
|
+
foreground: tone.onSoft,
|
|
959
|
+
background: tone.soft,
|
|
960
|
+
requiredRatio: 4.5,
|
|
961
|
+
guidance: `Adjust tones.${name}.soft or tones.${name}.onSoft.`,
|
|
962
|
+
}),
|
|
963
|
+
];
|
|
964
|
+
}
|
|
965
|
+
function createCheck(definition) {
|
|
966
|
+
const ratio = aerisContrastRatio(definition.foreground, definition.background);
|
|
967
|
+
const status = ratio === null ? 'unresolved' : ratio >= definition.requiredRatio ? 'pass' : 'fail';
|
|
968
|
+
return {
|
|
969
|
+
...definition,
|
|
970
|
+
criterion: definition.kind === 'text' ? '1.4.3' : '1.4.11',
|
|
971
|
+
ratio,
|
|
972
|
+
status,
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
function resolveSchemeColors(theme, mode) {
|
|
976
|
+
return resolveAerisFoundation(theme, mode);
|
|
977
|
+
}
|
|
978
|
+
function titleCase(value) {
|
|
979
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/** Resolves an optional theme override against the complete Aeris defaults. */
|
|
983
|
+
function resolveAerisTheme(theme) {
|
|
984
|
+
return {
|
|
985
|
+
...AERIS_DEFAULT_THEME,
|
|
986
|
+
...theme,
|
|
987
|
+
palette: {
|
|
988
|
+
...AERIS_DEFAULT_THEME.palette,
|
|
989
|
+
...normalizeAerisPalette(theme?.palette),
|
|
990
|
+
},
|
|
991
|
+
light: {
|
|
992
|
+
...AERIS_DEFAULT_THEME.light,
|
|
993
|
+
...theme?.light,
|
|
994
|
+
tones: mergeAerisSemanticTones(AERIS_DEFAULT_THEME.light.tones, theme?.light?.tones),
|
|
995
|
+
},
|
|
996
|
+
dark: {
|
|
997
|
+
...AERIS_DEFAULT_THEME.dark,
|
|
998
|
+
...theme?.dark,
|
|
999
|
+
tones: mergeAerisSemanticTones(AERIS_DEFAULT_THEME.dark.tones, theme?.dark?.tones),
|
|
1000
|
+
},
|
|
1001
|
+
densities: {
|
|
1002
|
+
...AERIS_DEFAULT_THEME.densities,
|
|
1003
|
+
...theme?.densities,
|
|
1004
|
+
},
|
|
1005
|
+
radii: {
|
|
1006
|
+
...AERIS_DEFAULT_THEME.radii,
|
|
1007
|
+
...theme?.radii,
|
|
1008
|
+
},
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
/** Deeply merges a runtime update into an already resolved Aeris theme. */
|
|
1012
|
+
function mergeAerisTheme(theme, update) {
|
|
1013
|
+
return {
|
|
1014
|
+
...theme,
|
|
1015
|
+
...update,
|
|
1016
|
+
palette: {
|
|
1017
|
+
...theme.palette,
|
|
1018
|
+
...normalizeAerisPalette(update.palette),
|
|
1019
|
+
},
|
|
1020
|
+
light: {
|
|
1021
|
+
...theme.light,
|
|
1022
|
+
...update.light,
|
|
1023
|
+
tones: mergeAerisSemanticTones(theme.light.tones, update.light?.tones),
|
|
1024
|
+
},
|
|
1025
|
+
dark: {
|
|
1026
|
+
...theme.dark,
|
|
1027
|
+
...update.dark,
|
|
1028
|
+
tones: mergeAerisSemanticTones(theme.dark.tones, update.dark?.tones),
|
|
1029
|
+
},
|
|
1030
|
+
densities: {
|
|
1031
|
+
...theme.densities,
|
|
1032
|
+
...update.densities,
|
|
1033
|
+
},
|
|
1034
|
+
radii: {
|
|
1035
|
+
...theme.radii,
|
|
1036
|
+
...update.radii,
|
|
1037
|
+
},
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
function resolveAerisDensity(theme) {
|
|
1041
|
+
return theme.densities[theme.density] ?? AERIS_DEFAULT_THEME.densities['medium'];
|
|
1042
|
+
}
|
|
1043
|
+
function resolveAerisRadius(theme) {
|
|
1044
|
+
return theme.radii[theme.radius] ?? AERIS_DEFAULT_THEME.radii['rounded'];
|
|
1045
|
+
}
|
|
1046
|
+
function mergeAerisSemanticTones(current, updates) {
|
|
1047
|
+
if (!current && !updates)
|
|
1048
|
+
return undefined;
|
|
1049
|
+
return Object.fromEntries(AERIS_SEMANTIC_TONE_NAMES.map((name) => [
|
|
1050
|
+
name,
|
|
1051
|
+
{
|
|
1052
|
+
...current?.[name],
|
|
1053
|
+
...updates?.[name],
|
|
1054
|
+
},
|
|
1055
|
+
]));
|
|
1056
|
+
}
|
|
1057
|
+
function normalizeAerisPalette(palette) {
|
|
1058
|
+
if (!palette)
|
|
1059
|
+
return {};
|
|
1060
|
+
const surface = palette.surface ?? palette.mist;
|
|
1061
|
+
const primary = palette.primary ?? palette.sage;
|
|
1062
|
+
const secondary = palette.secondary ?? palette.cloud;
|
|
1063
|
+
const accent = palette.accent ?? palette.sand;
|
|
1064
|
+
const contrast = palette.contrast ?? palette.umber;
|
|
1065
|
+
return {
|
|
1066
|
+
...palette,
|
|
1067
|
+
...(surface ? { surface, mist: surface } : {}),
|
|
1068
|
+
...(primary ? { primary, sage: primary } : {}),
|
|
1069
|
+
...(secondary ? { secondary, cloud: secondary } : {}),
|
|
1070
|
+
...(accent ? { accent, sand: accent } : {}),
|
|
1071
|
+
...(contrast ? { contrast, umber: contrast } : {}),
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
const FOUNDATION_TOKENS = [
|
|
1076
|
+
['page', '--aeris-page'],
|
|
1077
|
+
['surface', '--aeris-surface'],
|
|
1078
|
+
['surface2', '--aeris-surface-2'],
|
|
1079
|
+
['surface3', '--aeris-surface-3'],
|
|
1080
|
+
['interactiveHover', '--aeris-interactive-hover'],
|
|
1081
|
+
['text', '--aeris-text'],
|
|
1082
|
+
['text2', '--aeris-text-2'],
|
|
1083
|
+
['text3', '--aeris-text-3'],
|
|
1084
|
+
['border', '--aeris-border'],
|
|
1085
|
+
['borderStrong', '--aeris-border-strong'],
|
|
1086
|
+
['focus', '--aeris-focus'],
|
|
1087
|
+
];
|
|
1088
|
+
const DENSITY_TOKENS = [
|
|
1089
|
+
['controlHeight', '--aeris-control-height'],
|
|
1090
|
+
['controlPaddingX', '--aeris-control-padding-x'],
|
|
1091
|
+
['itemHeight', '--aeris-item-height'],
|
|
1092
|
+
['itemPaddingY', '--aeris-item-padding-y'],
|
|
1093
|
+
['itemPaddingX', '--aeris-item-padding-x'],
|
|
1094
|
+
['gap', '--aeris-density-gap'],
|
|
1095
|
+
['iconSize', '--aeris-icon-size'],
|
|
1096
|
+
];
|
|
1097
|
+
const RADIUS_TOKENS = [
|
|
1098
|
+
['sm', '--aeris-radius-sm'],
|
|
1099
|
+
['md', '--aeris-radius-md'],
|
|
1100
|
+
['lg', '--aeris-radius-lg'],
|
|
1101
|
+
['xl', '--aeris-radius-xl'],
|
|
1102
|
+
['control', '--aeris-radius-control'],
|
|
1103
|
+
['pill', '--aeris-radius-pill'],
|
|
1104
|
+
];
|
|
1105
|
+
/** Resolves the ordered CSS custom properties used by runtime and generated Aeris themes. */
|
|
1106
|
+
function resolveAerisThemeTokens(theme, mode) {
|
|
1107
|
+
const tokens = {};
|
|
1108
|
+
for (const [name, value] of Object.entries(theme.palette)) {
|
|
1109
|
+
tokens[`--aeris-palette-${name}`] = value;
|
|
1110
|
+
}
|
|
1111
|
+
const foundation = resolveAerisFoundation(theme, mode);
|
|
1112
|
+
for (const [property, token] of FOUNDATION_TOKENS) {
|
|
1113
|
+
tokens[token] = foundation[property];
|
|
1114
|
+
}
|
|
1115
|
+
tokens['--aeris-accent'] = theme[mode].accent ?? theme.palette.accent;
|
|
1116
|
+
if (theme[mode].shadowXs)
|
|
1117
|
+
tokens['--aeris-shadow-xs'] = theme[mode].shadowXs;
|
|
1118
|
+
if (theme[mode].shadowSm)
|
|
1119
|
+
tokens['--aeris-shadow-sm'] = theme[mode].shadowSm;
|
|
1120
|
+
const tones = resolveAerisSemanticTones(theme, mode);
|
|
1121
|
+
for (const name of AERIS_SEMANTIC_TONE_NAMES) {
|
|
1122
|
+
const tone = tones[name];
|
|
1123
|
+
tokens[`--aeris-${name}`] = tone.base;
|
|
1124
|
+
tokens[`--aeris-${name}-boundary`] = tone.boundary;
|
|
1125
|
+
tokens[`--aeris-${name}-hover`] = tone.hover;
|
|
1126
|
+
tokens[`--aeris-${name}-active`] = tone.active;
|
|
1127
|
+
tokens[`--aeris-on-${name}`] = tone.onBase;
|
|
1128
|
+
tokens[`--aeris-on-${name}-hover`] = tone.onHover;
|
|
1129
|
+
tokens[`--aeris-on-${name}-active`] = tone.onActive;
|
|
1130
|
+
tokens[`--aeris-${name}-text`] = tone.text;
|
|
1131
|
+
tokens[`--aeris-${name}-soft`] = tone.soft;
|
|
1132
|
+
tokens[`--aeris-on-${name}-soft`] = tone.onSoft;
|
|
1133
|
+
tokens[`--aeris-${name}-contrast`] = tone.onBase;
|
|
1134
|
+
}
|
|
1135
|
+
tokens['--aeris-primary-contrast'] = tones.primary.onBase;
|
|
1136
|
+
const density = resolveAerisDensity(theme);
|
|
1137
|
+
for (const [property, token] of DENSITY_TOKENS) {
|
|
1138
|
+
const value = density[property];
|
|
1139
|
+
if (value)
|
|
1140
|
+
tokens[token] = value;
|
|
1141
|
+
}
|
|
1142
|
+
const radius = resolveAerisRadius(theme);
|
|
1143
|
+
for (const [property, token] of RADIUS_TOKENS) {
|
|
1144
|
+
const value = radius[property];
|
|
1145
|
+
if (value)
|
|
1146
|
+
tokens[token] = value;
|
|
1147
|
+
}
|
|
1148
|
+
return tokens;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
class AerisThemeGenerationError extends Error {
|
|
1152
|
+
issues;
|
|
1153
|
+
constructor(issues) {
|
|
1154
|
+
super(`Aeris theme generation failed with ${issues.length} issue${issues.length === 1 ? '' : 's'}.`);
|
|
1155
|
+
this.name = 'AerisThemeGenerationError';
|
|
1156
|
+
this.issues = issues;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
const DEFAULT_SELECTOR = ':root';
|
|
1160
|
+
const GENERATED_BANNER = `/*! Generated by Aeris UI; color derivation v${AERIS_COLOR_DERIVATION_VERSION}. Edit the theme source, not this file. */`;
|
|
1161
|
+
/** Resolves, validates, and serializes a complete Aeris theme into deterministic CSS. */
|
|
1162
|
+
function compileAerisTheme(themeOverride = {}, options = {}) {
|
|
1163
|
+
const selector = options.selector?.trim() || DEFAULT_SELECTOR;
|
|
1164
|
+
const generation = resolveGenerationOptions(options);
|
|
1165
|
+
const theme = resolveAerisTheme(themeOverride);
|
|
1166
|
+
const lightTokens = resolveAerisThemeTokens(theme, 'light');
|
|
1167
|
+
const darkTokens = resolveAerisThemeTokens(theme, 'dark');
|
|
1168
|
+
const contrast = {
|
|
1169
|
+
light: auditAerisThemeContrast(theme, 'light'),
|
|
1170
|
+
dark: auditAerisThemeContrast(theme, 'dark'),
|
|
1171
|
+
};
|
|
1172
|
+
const issues = [
|
|
1173
|
+
...validateGeneration(selector, theme, lightTokens, darkTokens, contrast, generation),
|
|
1174
|
+
];
|
|
1175
|
+
if (options.expectedDerivationVersion !== undefined &&
|
|
1176
|
+
options.expectedDerivationVersion !== AERIS_COLOR_DERIVATION_VERSION) {
|
|
1177
|
+
issues.unshift({
|
|
1178
|
+
code: 'derivation-version-mismatch',
|
|
1179
|
+
message: `This configuration expects color derivation v${options.expectedDerivationVersion}, but the installed Aeris package provides v${AERIS_COLOR_DERIVATION_VERSION}. Review the theme changes, then update the configured derivation version before regenerating CSS.`,
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
if (issues.length)
|
|
1183
|
+
throw new AerisThemeGenerationError(issues);
|
|
1184
|
+
return {
|
|
1185
|
+
derivationVersion: AERIS_COLOR_DERIVATION_VERSION,
|
|
1186
|
+
css: serializeThemeCss(lightTokens, darkTokens, selector, options, generation),
|
|
1187
|
+
theme,
|
|
1188
|
+
lightTokens,
|
|
1189
|
+
darkTokens,
|
|
1190
|
+
contrast,
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
/** Convenience API for callers that only need the generated stylesheet. */
|
|
1194
|
+
function generateAerisThemeCss(themeOverride = {}, options = {}) {
|
|
1195
|
+
return compileAerisTheme(themeOverride, options).css;
|
|
1196
|
+
}
|
|
1197
|
+
function validateGeneration(selector, theme, lightTokens, darkTokens, contrast, generation) {
|
|
1198
|
+
const issues = [];
|
|
1199
|
+
if (!isSafeSelector(selector)) {
|
|
1200
|
+
issues.push({
|
|
1201
|
+
code: 'invalid-selector',
|
|
1202
|
+
message: 'selector must be one non-empty CSS selector without commas, braces, or semicolons.',
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
if (!generation.valid) {
|
|
1206
|
+
issues.push({
|
|
1207
|
+
code: 'invalid-default-mode',
|
|
1208
|
+
message: generation.message,
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
if (!theme.densities[theme.density]) {
|
|
1212
|
+
issues.push({
|
|
1213
|
+
code: 'invalid-density',
|
|
1214
|
+
message: `The density preset "${theme.density}" is not defined in theme.densities.`,
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
if (!theme.radii[theme.radius]) {
|
|
1218
|
+
issues.push({
|
|
1219
|
+
code: 'invalid-radius',
|
|
1220
|
+
message: `The radius preset "${theme.radius}" is not defined in theme.radii.`,
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
const modes = generation.schemes === 'both'
|
|
1224
|
+
? [
|
|
1225
|
+
['light', lightTokens],
|
|
1226
|
+
['dark', darkTokens],
|
|
1227
|
+
]
|
|
1228
|
+
: [
|
|
1229
|
+
[generation.schemes, generation.schemes === 'light' ? lightTokens : darkTokens],
|
|
1230
|
+
];
|
|
1231
|
+
for (const [mode, tokens] of modes) {
|
|
1232
|
+
for (const [token, value] of Object.entries(tokens)) {
|
|
1233
|
+
if (!isSafeCssValue$1(value)) {
|
|
1234
|
+
issues.push({
|
|
1235
|
+
code: 'invalid-css-value',
|
|
1236
|
+
message: `${token} contains characters that cannot be emitted safely.`,
|
|
1237
|
+
mode,
|
|
1238
|
+
token,
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
if (generation.validateContrast) {
|
|
1243
|
+
for (const check of contrast[mode].checks) {
|
|
1244
|
+
if (check.status === 'fail') {
|
|
1245
|
+
issues.push({
|
|
1246
|
+
code: 'contrast-failed',
|
|
1247
|
+
message: `${check.label} is ${check.ratio?.toFixed(2)}:1; ${check.requiredRatio}:1 is required.`,
|
|
1248
|
+
mode,
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
else if (check.status === 'unresolved') {
|
|
1252
|
+
issues.push({
|
|
1253
|
+
code: 'contrast-unresolved',
|
|
1254
|
+
message: `${check.label} could not be evaluated from static colors.`,
|
|
1255
|
+
mode,
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
return issues;
|
|
1262
|
+
}
|
|
1263
|
+
function serializeThemeCss(lightTokens, darkTokens, selector, options, generation) {
|
|
1264
|
+
if (generation.schemes !== 'both') {
|
|
1265
|
+
const mode = generation.schemes;
|
|
1266
|
+
const tokens = Object.entries(mode === 'light' ? lightTokens : darkTokens);
|
|
1267
|
+
const rule = formatRule([selector], tokens, mode, options.minify ?? false);
|
|
1268
|
+
return finalizeCss([rule], options);
|
|
1269
|
+
}
|
|
1270
|
+
const includeSystemMode = generation.includeSystemMode;
|
|
1271
|
+
const common = [];
|
|
1272
|
+
const light = [];
|
|
1273
|
+
const dark = [];
|
|
1274
|
+
for (const [token, lightValue] of Object.entries(lightTokens)) {
|
|
1275
|
+
const darkValue = darkTokens[token];
|
|
1276
|
+
if (darkValue === lightValue)
|
|
1277
|
+
common.push([token, lightValue]);
|
|
1278
|
+
else
|
|
1279
|
+
light.push([token, lightValue]);
|
|
1280
|
+
}
|
|
1281
|
+
for (const [token, darkValue] of Object.entries(darkTokens)) {
|
|
1282
|
+
if (!(token in lightTokens))
|
|
1283
|
+
dark.push([token, darkValue]);
|
|
1284
|
+
else if (lightTokens[token] !== darkValue) {
|
|
1285
|
+
dark.push([token, darkValue]);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
const lightSelectors = [`${selector}[data-aeris-theme='light']`];
|
|
1289
|
+
const darkSelectors = [`${selector}[data-aeris-theme='dark']`];
|
|
1290
|
+
if (generation.defaultMode === 'light' || generation.defaultMode === 'system') {
|
|
1291
|
+
lightSelectors.unshift(selector);
|
|
1292
|
+
}
|
|
1293
|
+
else {
|
|
1294
|
+
darkSelectors.unshift(selector);
|
|
1295
|
+
}
|
|
1296
|
+
if (includeSystemMode)
|
|
1297
|
+
lightSelectors.push(`${selector}[data-aeris-theme='system']`);
|
|
1298
|
+
const rules = [
|
|
1299
|
+
formatRule([selector], common, undefined, options.minify ?? false),
|
|
1300
|
+
formatRule(lightSelectors, light, 'light', options.minify ?? false),
|
|
1301
|
+
formatRule(darkSelectors, dark, 'dark', options.minify ?? false),
|
|
1302
|
+
];
|
|
1303
|
+
if (includeSystemMode) {
|
|
1304
|
+
const systemSelectors = [`${selector}[data-aeris-theme='system']`];
|
|
1305
|
+
if (generation.defaultMode === 'system') {
|
|
1306
|
+
systemSelectors.unshift(`${selector}:not([data-aeris-theme])`);
|
|
1307
|
+
}
|
|
1308
|
+
const systemRule = formatRule(systemSelectors, dark, 'dark', options.minify ?? false);
|
|
1309
|
+
rules.push(formatMediaRule(systemRule, options.minify ?? false));
|
|
1310
|
+
}
|
|
1311
|
+
return finalizeCss(rules, options);
|
|
1312
|
+
}
|
|
1313
|
+
function finalizeCss(rules, options) {
|
|
1314
|
+
const minify = options.minify ?? false;
|
|
1315
|
+
const banner = options.banner ?? true;
|
|
1316
|
+
const output = rules.filter(Boolean).join(minify ? '' : '\n\n');
|
|
1317
|
+
if (minify || !banner)
|
|
1318
|
+
return `${output}${minify ? '' : '\n'}`;
|
|
1319
|
+
return `${GENERATED_BANNER}\n${output}\n`;
|
|
1320
|
+
}
|
|
1321
|
+
function resolveGenerationOptions(options) {
|
|
1322
|
+
const schemes = options.schemes ?? 'both';
|
|
1323
|
+
const validSchemes = schemes === 'both' || schemes === 'light' || schemes === 'dark';
|
|
1324
|
+
const includeSystemMode = schemes === 'both' && (options.includeSystemMode ?? true);
|
|
1325
|
+
const validateContrast = options.validateContrast ?? true;
|
|
1326
|
+
const defaultMode = options.defaultMode ??
|
|
1327
|
+
(schemes === 'both' ? (includeSystemMode ? 'system' : 'light') : schemes);
|
|
1328
|
+
const validDefaultMode = defaultMode === 'system' || defaultMode === 'light' || defaultMode === 'dark';
|
|
1329
|
+
const valid = validSchemes &&
|
|
1330
|
+
validDefaultMode &&
|
|
1331
|
+
((schemes === 'both' && (defaultMode !== 'system' || includeSystemMode)) ||
|
|
1332
|
+
schemes === defaultMode);
|
|
1333
|
+
return {
|
|
1334
|
+
schemes,
|
|
1335
|
+
defaultMode,
|
|
1336
|
+
includeSystemMode,
|
|
1337
|
+
validateContrast,
|
|
1338
|
+
valid,
|
|
1339
|
+
message: !validSchemes
|
|
1340
|
+
? 'schemes must be "both", "light", or "dark".'
|
|
1341
|
+
: !validDefaultMode
|
|
1342
|
+
? 'defaultMode must be "system", "light", or "dark".'
|
|
1343
|
+
: schemes === 'both'
|
|
1344
|
+
? 'defaultMode="system" requires system-mode generation to be enabled.'
|
|
1345
|
+
: `defaultMode must be "${schemes}" when only the ${schemes} scheme is generated.`,
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
function formatRule(selectors, tokens, colorScheme, minify) {
|
|
1349
|
+
if (!tokens.length && !colorScheme)
|
|
1350
|
+
return '';
|
|
1351
|
+
if (minify) {
|
|
1352
|
+
const declarations = [
|
|
1353
|
+
...(colorScheme ? [`color-scheme:${colorScheme}`] : []),
|
|
1354
|
+
...tokens.map(([token, value]) => `${token}:${value}`),
|
|
1355
|
+
];
|
|
1356
|
+
return `${selectors.join(',')}{${declarations.join(';')}}`;
|
|
1357
|
+
}
|
|
1358
|
+
const declarations = [
|
|
1359
|
+
...(colorScheme ? [` color-scheme: ${colorScheme};`] : []),
|
|
1360
|
+
...tokens.map(([token, value]) => ` ${token}: ${value};`),
|
|
1361
|
+
];
|
|
1362
|
+
return `${selectors.join(',\n')} {\n${declarations.join('\n')}\n}`;
|
|
1363
|
+
}
|
|
1364
|
+
function formatMediaRule(rule, minify) {
|
|
1365
|
+
if (minify)
|
|
1366
|
+
return `@media(prefers-color-scheme:dark){${rule}}`;
|
|
1367
|
+
return `@media (prefers-color-scheme: dark) {\n${rule
|
|
1368
|
+
.split('\n')
|
|
1369
|
+
.map((line) => ` ${line}`)
|
|
1370
|
+
.join('\n')}\n}`;
|
|
1371
|
+
}
|
|
1372
|
+
function isSafeSelector(selector) {
|
|
1373
|
+
return selector.length > 0 && !/[{},;\r\n]/.test(selector);
|
|
1374
|
+
}
|
|
1375
|
+
function isSafeCssValue$1(value) {
|
|
1376
|
+
return value.length > 0 && !/[;{}\r\n]/.test(value);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
const SCHEME_COLOR_PROPERTIES = [
|
|
1380
|
+
'accent',
|
|
1381
|
+
'page',
|
|
1382
|
+
'surface',
|
|
1383
|
+
'surface2',
|
|
1384
|
+
'surface3',
|
|
1385
|
+
'interactiveHover',
|
|
1386
|
+
'text',
|
|
1387
|
+
'text2',
|
|
1388
|
+
'text3',
|
|
1389
|
+
'border',
|
|
1390
|
+
'borderStrong',
|
|
1391
|
+
'focus',
|
|
1392
|
+
];
|
|
1393
|
+
const TONE_PROPERTIES = [
|
|
1394
|
+
'base',
|
|
1395
|
+
'boundary',
|
|
1396
|
+
'hover',
|
|
1397
|
+
'active',
|
|
1398
|
+
'onBase',
|
|
1399
|
+
'onHover',
|
|
1400
|
+
'onActive',
|
|
1401
|
+
'text',
|
|
1402
|
+
'soft',
|
|
1403
|
+
'onSoft',
|
|
1404
|
+
];
|
|
1405
|
+
/**
|
|
1406
|
+
* Validates a runtime or build-time theme without reading the DOM.
|
|
1407
|
+
*
|
|
1408
|
+
* Errors identify values Aeris cannot safely apply or accessibility checks
|
|
1409
|
+
* known to fail. Warnings identify colors that require rendered/manual review.
|
|
1410
|
+
*/
|
|
1411
|
+
function validateAerisTheme(themeOverride = {}) {
|
|
1412
|
+
const theme = resolveAerisTheme(themeOverride);
|
|
1413
|
+
const issues = [];
|
|
1414
|
+
validateThemeSelection(theme, issues);
|
|
1415
|
+
const values = collectThemeCssValues(theme);
|
|
1416
|
+
let canAuditColors = true;
|
|
1417
|
+
for (const entry of values) {
|
|
1418
|
+
if (isSafeCssValue(entry.value))
|
|
1419
|
+
continue;
|
|
1420
|
+
if (entry.affectsColorResolution)
|
|
1421
|
+
canAuditColors = false;
|
|
1422
|
+
issues.push({
|
|
1423
|
+
code: 'invalid-css-value',
|
|
1424
|
+
severity: 'error',
|
|
1425
|
+
path: entry.path,
|
|
1426
|
+
message: `${entry.path} must be a non-empty CSS value without braces, semicolons, or line breaks.`,
|
|
1427
|
+
guidance: 'Replace it with a valid CSS color, length, radius, or shadow value.',
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
if (canAuditColors) {
|
|
1431
|
+
for (const mode of ['light', 'dark']) {
|
|
1432
|
+
const contrast = auditAerisThemeContrast(theme, mode);
|
|
1433
|
+
for (const check of contrast.checks) {
|
|
1434
|
+
if (check.status === 'pass')
|
|
1435
|
+
continue;
|
|
1436
|
+
const unresolved = check.status === 'unresolved';
|
|
1437
|
+
issues.push({
|
|
1438
|
+
code: unresolved ? 'contrast-unresolved' : 'contrast-failed',
|
|
1439
|
+
severity: unresolved ? 'warning' : 'error',
|
|
1440
|
+
mode,
|
|
1441
|
+
path: `contrast.${mode}.${check.id}`,
|
|
1442
|
+
ratio: check.ratio,
|
|
1443
|
+
requiredRatio: check.requiredRatio,
|
|
1444
|
+
message: unresolved
|
|
1445
|
+
? `${check.label} could not be evaluated from static colors.`
|
|
1446
|
+
: `${check.label} is ${check.ratio?.toFixed(2)}:1; WCAG ${check.criterion} requires ${check.requiredRatio}:1.`,
|
|
1447
|
+
guidance: unresolved
|
|
1448
|
+
? `${check.guidance} Static analysis supports opaque HEX, RGB, and HSL colors; verify CSS variables, named colors, and newer color functions in their rendered context.`
|
|
1449
|
+
: check.guidance,
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
const errors = issues.filter(({ severity }) => severity === 'error');
|
|
1455
|
+
const warnings = issues.filter(({ severity }) => severity === 'warning');
|
|
1456
|
+
return {
|
|
1457
|
+
status: errors.length ? 'error' : warnings.length ? 'warning' : 'valid',
|
|
1458
|
+
valid: errors.length === 0,
|
|
1459
|
+
issues,
|
|
1460
|
+
errors,
|
|
1461
|
+
warnings,
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
function validateThemeSelection(theme, issues) {
|
|
1465
|
+
if (theme.direction !== undefined && theme.direction !== 'ltr' && theme.direction !== 'rtl') {
|
|
1466
|
+
issues.push({
|
|
1467
|
+
code: 'invalid-direction',
|
|
1468
|
+
severity: 'error',
|
|
1469
|
+
path: 'direction',
|
|
1470
|
+
message: `direction must be "ltr" or "rtl"; received "${String(theme.direction)}".`,
|
|
1471
|
+
guidance: 'Use ltr for left-to-right content or rtl for right-to-left content.',
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
if (!theme.densities[theme.density]) {
|
|
1475
|
+
issues.push({
|
|
1476
|
+
code: 'missing-density',
|
|
1477
|
+
severity: 'error',
|
|
1478
|
+
path: 'density',
|
|
1479
|
+
message: `The selected density "${theme.density}" is not registered in theme.densities.`,
|
|
1480
|
+
guidance: 'Select a built-in density or register a scale with the same name.',
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
if (!theme.radii[theme.radius]) {
|
|
1484
|
+
issues.push({
|
|
1485
|
+
code: 'missing-radius',
|
|
1486
|
+
severity: 'error',
|
|
1487
|
+
path: 'radius',
|
|
1488
|
+
message: `The selected radius "${theme.radius}" is not registered in theme.radii.`,
|
|
1489
|
+
guidance: 'Select a built-in corner style or register a radius scale with the same name.',
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
function collectThemeCssValues(theme) {
|
|
1494
|
+
const values = [
|
|
1495
|
+
cssValue('palette.surface', theme.palette.surface, true),
|
|
1496
|
+
cssValue('palette.primary', theme.palette.primary, true),
|
|
1497
|
+
cssValue('palette.secondary', theme.palette.secondary, true),
|
|
1498
|
+
cssValue('palette.accent', theme.palette.accent, true),
|
|
1499
|
+
cssValue('palette.contrast', theme.palette.contrast, true),
|
|
1500
|
+
];
|
|
1501
|
+
for (const mode of ['light', 'dark']) {
|
|
1502
|
+
const scheme = theme[mode];
|
|
1503
|
+
for (const property of SCHEME_COLOR_PROPERTIES) {
|
|
1504
|
+
const value = scheme[property];
|
|
1505
|
+
if (value !== undefined)
|
|
1506
|
+
values.push(cssValue(`${mode}.${property}`, value, true));
|
|
1507
|
+
}
|
|
1508
|
+
if (scheme.shadowXs !== undefined) {
|
|
1509
|
+
values.push(cssValue(`${mode}.shadowXs`, scheme.shadowXs, false));
|
|
1510
|
+
}
|
|
1511
|
+
if (scheme.shadowSm !== undefined) {
|
|
1512
|
+
values.push(cssValue(`${mode}.shadowSm`, scheme.shadowSm, false));
|
|
1513
|
+
}
|
|
1514
|
+
for (const toneName of AERIS_SEMANTIC_TONE_NAMES) {
|
|
1515
|
+
const tone = scheme.tones?.[toneName];
|
|
1516
|
+
if (!tone)
|
|
1517
|
+
continue;
|
|
1518
|
+
for (const property of TONE_PROPERTIES) {
|
|
1519
|
+
const value = tone[property];
|
|
1520
|
+
if (value !== undefined) {
|
|
1521
|
+
values.push(cssValue(`${mode}.tones.${toneName}.${property}`, value, true));
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
for (const [name, scale] of Object.entries(theme.densities)) {
|
|
1527
|
+
if (!isRecord(scale)) {
|
|
1528
|
+
values.push(cssValue(`densities.${name}`, scale, false));
|
|
1529
|
+
continue;
|
|
1530
|
+
}
|
|
1531
|
+
for (const [property, value] of Object.entries(scale)) {
|
|
1532
|
+
values.push(cssValue(`densities.${name}.${property}`, value, false));
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
for (const [name, scale] of Object.entries(theme.radii)) {
|
|
1536
|
+
if (!isRecord(scale)) {
|
|
1537
|
+
values.push(cssValue(`radii.${name}`, scale, false));
|
|
1538
|
+
continue;
|
|
1539
|
+
}
|
|
1540
|
+
for (const [property, value] of Object.entries(scale)) {
|
|
1541
|
+
values.push(cssValue(`radii.${name}.${property}`, value, false));
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
return values;
|
|
1545
|
+
}
|
|
1546
|
+
function cssValue(path, value, affectsColorResolution) {
|
|
1547
|
+
return { path, value, affectsColorResolution };
|
|
1548
|
+
}
|
|
1549
|
+
function isSafeCssValue(value) {
|
|
1550
|
+
return typeof value === 'string' && value.trim().length > 0 && !/[;{}\r\n]/.test(value);
|
|
1551
|
+
}
|
|
1552
|
+
function isRecord(value) {
|
|
1553
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* Framework-independent Aeris theme compiler APIs for Node.js build scripts and browser tooling.
|
|
1558
|
+
*/
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Generated bundle index. Do not edit.
|
|
1562
|
+
*/
|
|
1563
|
+
|
|
1564
|
+
export { AERIS_COLOR_DERIVATION_VERSION, AERIS_DEFAULT_THEME, AERIS_DENSITY_PRESETS, AERIS_RADIUS_PRESETS, AERIS_SEMANTIC_TONE_NAMES, AERIS_THEME_PRESETS, AerisThemeGenerationError, aerisContrastRatio, aerisRgbContrastRatio, auditAerisThemeContrast, compileAerisTheme, formatAerisHex, generateAerisThemeCss, mergeAerisTheme, mixAerisColor, mixAerisRgb, parseAerisColor, resolveAerisDensity, resolveAerisFoundation, resolveAerisRadius, resolveAerisSemanticTones, resolveAerisTheme, resolveAerisThemeTokens, validateAerisTheme };
|
|
1565
|
+
//# sourceMappingURL=aeris-ui-core-theme-builder.mjs.map
|