@epilot/spark-ui 0.31.1 → 0.32.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/dist/button-B_RNHEc7.d.ts +52 -0
- package/dist/button-DBcEcIMk.d.cts +52 -0
- package/dist/cn-DzRH6EW_.d.cts +4 -0
- package/dist/cn-DzRH6EW_.d.ts +4 -0
- package/dist/components/accordion.cjs +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.cjs +1 -1
- package/dist/components/alert-dialog.d.cts +1 -1
- package/dist/components/alert-dialog.d.ts +1 -1
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/attachment.cjs +2 -2
- package/dist/components/attachment.d.cts +3 -3
- package/dist/components/attachment.d.ts +3 -3
- package/dist/components/attachment.js +2 -2
- package/dist/components/autocomplete.cjs +9 -7
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.d.cts +4 -10
- package/dist/components/autocomplete.d.ts +4 -10
- package/dist/components/autocomplete.js +9 -7
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.js +1 -1
- package/dist/components/badge.cjs +1 -1
- package/dist/components/badge.js +2 -2
- package/dist/components/banner.cjs +1 -1
- package/dist/components/banner.js +1 -1
- package/dist/components/bar-chart.cjs +1 -1
- package/dist/components/bar-chart.js +2 -2
- package/dist/components/box.cjs +2 -2
- package/dist/components/box.cjs.map +1 -1
- package/dist/components/box.js +3 -3
- package/dist/components/box.js.map +1 -1
- package/dist/components/breadcrumbs.cjs +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/bubble.cjs +2 -2
- package/dist/components/bubble.d.cts +2 -2
- package/dist/components/bubble.d.ts +2 -2
- package/dist/components/bubble.js +2 -2
- package/dist/components/button-group.cjs +1 -1
- package/dist/components/button-group.js +2 -2
- package/dist/components/button.cjs +13 -30
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +3 -36
- package/dist/components/button.d.ts +3 -36
- package/dist/components/button.js +14 -31
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.cjs +32 -4
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.d.cts +2 -2
- package/dist/components/calendar.d.ts +2 -2
- package/dist/components/calendar.js +34 -6
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/card.cjs +6 -5
- package/dist/components/card.cjs.map +1 -1
- package/dist/components/card.d.cts +9 -8
- package/dist/components/card.d.ts +9 -8
- package/dist/components/card.js +7 -6
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-card.cjs +157 -65
- package/dist/components/checkbox-card.cjs.map +1 -1
- package/dist/components/checkbox-card.d.cts +38 -18
- package/dist/components/checkbox-card.d.ts +38 -18
- package/dist/components/checkbox-card.js +155 -66
- package/dist/components/checkbox-card.js.map +1 -1
- package/dist/components/checkbox-group.cjs +1 -1
- package/dist/components/checkbox-group.js +2 -2
- package/dist/components/checkbox.cjs +5 -18
- package/dist/components/checkbox.cjs.map +1 -1
- package/dist/components/checkbox.js +7 -20
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/combobox.cjs +2 -1
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.js +2 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/dialog.cjs +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.cjs +1 -1
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/dropzone.cjs +224 -0
- package/dist/components/dropzone.cjs.map +1 -0
- package/dist/components/dropzone.d.cts +66 -0
- package/dist/components/dropzone.d.ts +66 -0
- package/dist/components/dropzone.js +215 -0
- package/dist/components/dropzone.js.map +1 -0
- package/dist/components/empty-state.cjs +1 -1
- package/dist/components/empty-state.d.cts +1 -1
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/empty-state.js +1 -1
- package/dist/components/entity-card.cjs +1 -1
- package/dist/components/entity-card.js +1 -1
- package/dist/components/field.cjs +69 -11
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +16 -3
- package/dist/components/field.d.ts +16 -3
- package/dist/components/field.js +68 -11
- package/dist/components/field.js.map +1 -1
- package/dist/components/hero-metric.cjs +1 -1
- package/dist/components/hero-metric.js +1 -1
- package/dist/components/icon.js +1 -1
- package/dist/components/image-carousel.cjs +183 -0
- package/dist/components/image-carousel.cjs.map +1 -0
- package/dist/components/image-carousel.d.cts +54 -0
- package/dist/components/image-carousel.d.ts +54 -0
- package/dist/components/image-carousel.js +174 -0
- package/dist/components/image-carousel.js.map +1 -0
- package/dist/components/info-block.cjs +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/info-block.js +1 -1
- package/dist/components/input-date-time.cjs +16 -202
- package/dist/components/input-date-time.cjs.map +1 -1
- package/dist/components/input-date-time.d.cts +14 -31
- package/dist/components/input-date-time.d.ts +14 -31
- package/dist/components/input-date-time.js +15 -202
- package/dist/components/input-date-time.js.map +1 -1
- package/dist/components/input-date.cjs +14 -146
- package/dist/components/input-date.cjs.map +1 -1
- package/dist/components/input-date.d.cts +11 -19
- package/dist/components/input-date.d.ts +11 -19
- package/dist/components/input-date.js +13 -146
- package/dist/components/input-date.js.map +1 -1
- package/dist/components/input-group.cjs +4 -3
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +2 -30
- package/dist/components/input-group.d.ts +2 -30
- package/dist/components/input-group.js +3 -2
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.cjs +3 -3
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +3 -3
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.cjs +4 -2
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.cts +2 -12
- package/dist/components/input.d.ts +2 -12
- package/dist/components/input.js +4 -2
- package/dist/components/input.js.map +1 -1
- package/dist/components/line-chart.cjs +2 -2
- package/dist/components/line-chart.js +3 -3
- package/dist/components/list.cjs +2 -2
- package/dist/components/list.js +2 -2
- package/dist/components/marker.cjs +2 -2
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +2 -2
- package/dist/components/message-scroller.cjs +1 -1
- package/dist/components/message-scroller.d.cts +1 -1
- package/dist/components/message-scroller.d.ts +1 -1
- package/dist/components/message-scroller.js +2 -2
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.d.cts +2 -2
- package/dist/components/page-header.d.ts +2 -2
- package/dist/components/page-header.js +1 -1
- package/dist/components/pagination.cjs +124 -0
- package/dist/components/pagination.cjs.map +1 -0
- package/dist/components/pagination.d.cts +42 -0
- package/dist/components/pagination.d.ts +42 -0
- package/dist/components/pagination.js +115 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/period-tabs.cjs +1 -1
- package/dist/components/period-tabs.d.cts +1 -1
- package/dist/components/period-tabs.d.ts +1 -1
- package/dist/components/period-tabs.js +1 -1
- package/dist/components/pill.cjs +43 -24
- package/dist/components/pill.cjs.map +1 -1
- package/dist/components/pill.d.cts +13 -3
- package/dist/components/pill.d.ts +13 -3
- package/dist/components/pill.js +44 -26
- package/dist/components/pill.js.map +1 -1
- package/dist/components/popover.cjs +1 -1
- package/dist/components/popover.d.cts +2 -29
- package/dist/components/popover.d.ts +2 -29
- package/dist/components/popover.js +1 -1
- package/dist/components/power-history-chart.cjs +2 -2
- package/dist/components/power-history-chart.js +3 -3
- package/dist/components/power-network.cjs +1 -1
- package/dist/components/power-network.js +2 -2
- package/dist/components/progress.cjs +126 -13
- package/dist/components/progress.cjs.map +1 -1
- package/dist/components/progress.d.cts +19 -10
- package/dist/components/progress.d.ts +19 -10
- package/dist/components/progress.js +126 -15
- package/dist/components/progress.js.map +1 -1
- package/dist/components/radio-card-group.cjs +137 -70
- package/dist/components/radio-card-group.cjs.map +1 -1
- package/dist/components/radio-card-group.d.cts +37 -15
- package/dist/components/radio-card-group.d.ts +37 -15
- package/dist/components/radio-card-group.js +135 -71
- package/dist/components/radio-card-group.js.map +1 -1
- package/dist/components/radio.cjs +1 -1
- package/dist/components/radio.js +2 -2
- package/dist/components/schedule-list.cjs +1 -1
- package/dist/components/schedule-list.js +1 -1
- package/dist/components/select.cjs +11 -4
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +1 -0
- package/dist/components/select.d.ts +1 -0
- package/dist/components/select.js +11 -4
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +1 -1
- package/dist/components/separator.js +1 -1
- package/dist/components/sheet.cjs +1 -1
- package/dist/components/sheet.js +1 -1
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/solar-forecast-chart.js +1 -1
- package/dist/components/spark-home.js +1 -1
- package/dist/components/step-indicator.cjs +128 -0
- package/dist/components/step-indicator.cjs.map +1 -0
- package/dist/components/step-indicator.d.cts +25 -0
- package/dist/components/step-indicator.d.ts +25 -0
- package/dist/components/step-indicator.js +124 -0
- package/dist/components/step-indicator.js.map +1 -0
- package/dist/components/stepper.cjs +3 -2
- package/dist/components/stepper.cjs.map +1 -1
- package/dist/components/stepper.d.cts +1 -2
- package/dist/components/stepper.d.ts +1 -2
- package/dist/components/stepper.js +3 -2
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch-group.cjs +1 -1
- package/dist/components/switch-group.js +2 -2
- package/dist/components/switch.js +1 -1
- package/dist/components/table.cjs +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.cjs +3 -3
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.js +2 -2
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.cjs +8 -2
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.js +8 -2
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.cjs +1 -1
- package/dist/components/theme.js +2 -2
- package/dist/components/time-picker.cjs +3 -38
- package/dist/components/time-picker.cjs.map +1 -1
- package/dist/components/time-picker.js +1 -36
- package/dist/components/time-picker.js.map +1 -1
- package/dist/components/toast.cjs +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/tooltip.cjs +3 -2
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.d.cts +3 -2
- package/dist/components/tooltip.d.ts +3 -2
- package/dist/components/tooltip.js +3 -2
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/trace.cjs +1 -1
- package/dist/components/trace.js +1 -1
- package/dist/hooks/use-isomorphic-layout-effect.cjs +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.cjs.map +1 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.cts +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +9 -0
- package/dist/hooks/use-isomorphic-layout-effect.js +8 -0
- package/dist/hooks/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/input-BZFPU-j4.d.cts +14 -0
- package/dist/input-group-5lh67qyY.d.cts +32 -0
- package/dist/input-group-Bc9_sPPN.d.ts +32 -0
- package/dist/input-zB3zmz9J.d.ts +14 -0
- package/dist/lib/accent-theme.cjs +46 -22
- package/dist/lib/accent-theme.cjs.map +1 -1
- package/dist/lib/accent-theme.js +26 -1
- package/dist/lib/accent-theme.js.map +1 -1
- package/dist/lib/calendar-field.cjs +11 -0
- package/dist/lib/calendar-field.cjs.map +1 -0
- package/dist/lib/calendar-field.d.cts +18 -0
- package/dist/lib/calendar-field.d.ts +18 -0
- package/dist/lib/calendar-field.js +8 -0
- package/dist/lib/calendar-field.js.map +1 -0
- package/dist/lib/calendar-lists.cjs +86 -97
- package/dist/lib/calendar-lists.cjs.map +1 -1
- package/dist/lib/calendar-lists.d.cts +30 -2
- package/dist/lib/calendar-lists.d.ts +30 -2
- package/dist/lib/calendar-lists.js +85 -97
- package/dist/lib/calendar-lists.js.map +1 -1
- package/dist/lib/card-control.cjs +18 -0
- package/dist/lib/card-control.cjs.map +1 -0
- package/dist/lib/card-control.d.cts +10 -0
- package/dist/lib/card-control.d.ts +10 -0
- package/dist/lib/card-control.js +17 -0
- package/dist/lib/card-control.js.map +1 -0
- package/dist/lib/checkbox-box.cjs +30 -0
- package/dist/lib/checkbox-box.cjs.map +1 -0
- package/dist/lib/checkbox-box.d.cts +13 -0
- package/dist/lib/checkbox-box.d.ts +13 -0
- package/dist/lib/checkbox-box.js +27 -0
- package/dist/lib/checkbox-box.js.map +1 -0
- package/dist/lib/container-chrome.cjs +8 -1
- package/dist/lib/container-chrome.cjs.map +1 -1
- package/dist/lib/container-chrome.d.cts +4 -2
- package/dist/lib/container-chrome.d.ts +4 -2
- package/dist/lib/container-chrome.js +8 -2
- package/dist/lib/container-chrome.js.map +1 -1
- package/dist/lib/date-field-input.cjs +121 -0
- package/dist/lib/date-field-input.cjs.map +1 -0
- package/dist/lib/date-field-input.d.cts +14 -0
- package/dist/lib/date-field-input.d.ts +14 -0
- package/dist/lib/date-field-input.js +118 -0
- package/dist/lib/date-field-input.js.map +1 -0
- package/dist/lib/date-field-time-list.cjs +81 -0
- package/dist/lib/date-field-time-list.cjs.map +1 -0
- package/dist/lib/date-field-time-list.d.cts +18 -0
- package/dist/lib/date-field-time-list.d.ts +18 -0
- package/dist/lib/date-field-time-list.js +77 -0
- package/dist/lib/date-field-time-list.js.map +1 -0
- package/dist/lib/date-field.cjs +183 -0
- package/dist/lib/date-field.cjs.map +1 -0
- package/dist/lib/date-field.d.cts +76 -0
- package/dist/lib/date-field.d.ts +76 -0
- package/dist/lib/date-field.js +177 -0
- package/dist/lib/date-field.js.map +1 -0
- package/dist/lib/date-time-mask.cjs +148 -102
- package/dist/lib/date-time-mask.cjs.map +1 -1
- package/dist/lib/date-time-mask.d.cts +21 -3
- package/dist/lib/date-time-mask.d.ts +21 -3
- package/dist/lib/date-time-mask.js +142 -103
- package/dist/lib/date-time-mask.js.map +1 -1
- package/dist/lib/generate-radix-colors.cjs +64 -5
- package/dist/lib/generate-radix-colors.cjs.map +1 -1
- package/dist/lib/generate-radix-colors.js +61 -1
- package/dist/lib/generate-radix-colors.js.map +1 -1
- package/dist/lib/input-box-variants.cjs +3 -3
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +1 -1
- package/dist/lib/input-box-variants.d.ts +1 -1
- package/dist/lib/input-box-variants.js +3 -3
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/mask-hint.cjs +15 -0
- package/dist/lib/mask-hint.cjs.map +1 -0
- package/dist/lib/mask-hint.d.cts +10 -0
- package/dist/lib/mask-hint.d.ts +10 -0
- package/dist/lib/mask-hint.js +14 -0
- package/dist/lib/mask-hint.js.map +1 -0
- package/dist/lib/option-list.cjs +71 -0
- package/dist/lib/option-list.cjs.map +1 -0
- package/dist/lib/option-list.d.cts +4 -0
- package/dist/lib/option-list.d.ts +4 -0
- package/dist/lib/option-list.js +67 -0
- package/dist/lib/option-list.js.map +1 -0
- package/dist/lib/time-grid.cjs +34 -0
- package/dist/lib/time-grid.cjs.map +1 -0
- package/dist/lib/time-grid.d.cts +9 -0
- package/dist/lib/time-grid.d.ts +9 -0
- package/dist/lib/time-grid.js +31 -0
- package/dist/lib/time-grid.js.map +1 -0
- package/dist/lib/toggle-group-context.d.cts +1 -1
- package/dist/lib/toggle-group-context.d.ts +1 -1
- package/dist/option-list-CxhR_DGq.d.cts +34 -0
- package/dist/option-list-CxhR_DGq.d.ts +34 -0
- package/dist/popover-DmcqNOkO.d.cts +31 -0
- package/dist/popover-DmcqNOkO.d.ts +31 -0
- package/dist/styles/spark-default.css +21 -0
- package/dist/styles/theme.css +2 -1
- package/dist/utils/cn.d.cts +1 -1
- package/dist/utils/cn.d.ts +1 -1
- package/package.json +3 -3
- package/dist/calendar-lists-CTby2kR5.d.cts +0 -27
- package/dist/calendar-lists-DoloqsCN.d.ts +0 -27
- package/dist/lib/calendar-day-button.cjs +0 -23
- package/dist/lib/calendar-day-button.cjs.map +0 -1
- package/dist/lib/calendar-day-button.d.cts +0 -14
- package/dist/lib/calendar-day-button.d.ts +0 -14
- package/dist/lib/calendar-day-button.js +0 -20
- package/dist/lib/calendar-day-button.js.map +0 -1
- package/dist/lib/input-date-parts.cjs +0 -155
- package/dist/lib/input-date-parts.cjs.map +0 -1
- package/dist/lib/input-date-parts.d.cts +0 -53
- package/dist/lib/input-date-parts.d.ts +0 -53
- package/dist/lib/input-date-parts.js +0 -148
- package/dist/lib/input-date-parts.js.map +0 -1
- package/dist/lib/scroll-within.cjs +0 -27
- package/dist/lib/scroll-within.cjs.map +0 -1
- package/dist/lib/scroll-within.d.cts +0 -14
- package/dist/lib/scroll-within.d.ts +0 -14
- package/dist/lib/scroll-within.js +0 -25
- package/dist/lib/scroll-within.js.map +0 -1
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { apply, applyPaste, dateStatus, formatDate, isDateMaskKey, parseDate } from "ictus";
|
|
3
|
-
import {
|
|
3
|
+
import { applyDateTime, applyDateTimePaste as applyDateTimePaste$1, dateTimeStatus as dateTimeStatus$1, formatDateTime as formatDateTime$1, isDateTimeMaskKey as isDateTimeMaskKey$1, parseDateTime as parseDateTime$1 } from "ictus/datetime";
|
|
4
|
+
import { formatTime } from "ictus/time";
|
|
4
5
|
//#region src/lib/date-time-mask.ts
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})
|
|
12
|
-
const
|
|
6
|
+
const joiner = ", ";
|
|
7
|
+
const datePart = (text) => text.split(joiner)[0] ?? "";
|
|
8
|
+
const timeStartOf = (value) => {
|
|
9
|
+
const at = value.indexOf(joiner);
|
|
10
|
+
return at === -1 ? -1 : at + 2;
|
|
11
|
+
};
|
|
12
|
+
function dropEmptyTime({ caret, value }) {
|
|
13
|
+
const at = value.indexOf(joiner);
|
|
14
|
+
if (at === -1 || /\d/.test(value.slice(at))) return {
|
|
15
|
+
caret,
|
|
16
|
+
value
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
caret: Math.min(caret, at),
|
|
20
|
+
value: value.slice(0, at)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
13
23
|
/** Keys the mask consumes; any other printable key is ignored. */
|
|
14
24
|
function isDateTimeMaskKey(key, withTime = false) {
|
|
15
|
-
return
|
|
25
|
+
return withTime ? isDateTimeMaskKey$1(key) : isDateMaskKey(key);
|
|
16
26
|
}
|
|
17
27
|
function stepOverSeparators(value, caret, key) {
|
|
18
28
|
const isSeparator = (char) => char !== void 0 && !/\d/.test(char);
|
|
@@ -21,127 +31,156 @@ function stepOverSeparators(value, caret, key) {
|
|
|
21
31
|
if (key === "Delete") while (at < value.length && isSeparator(value[at])) at++;
|
|
22
32
|
return at;
|
|
23
33
|
}
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
/** One keystroke through the date (and time) mask: the next value and caret. */
|
|
35
|
+
function applyDateTimeMask({ caret, key, selectionEnd, separator, value, withTime = false }) {
|
|
36
|
+
const collapsed = selectionEnd === void 0 || selectionEnd === caret;
|
|
37
|
+
const at = collapsed ? stepOverSeparators(value, caret, key) : caret;
|
|
38
|
+
const edit = {
|
|
26
39
|
value,
|
|
27
|
-
caret,
|
|
28
|
-
selectionEnd
|
|
40
|
+
caret: at,
|
|
41
|
+
selectionEnd: collapsed ? at : selectionEnd
|
|
42
|
+
};
|
|
43
|
+
if (!withTime) return apply({
|
|
44
|
+
...edit,
|
|
29
45
|
key,
|
|
30
46
|
separator
|
|
31
47
|
});
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
return dropEmptyTime(applyDateTime({
|
|
49
|
+
...edit,
|
|
50
|
+
joiner,
|
|
35
51
|
key,
|
|
36
52
|
separator
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
/** One keystroke through the date (and time) mask: the next value and caret. */
|
|
40
|
-
function applyDateTimeMask({ caret, key, selectionEnd, separator, value, withTime = false }) {
|
|
41
|
-
if (!withTime) return applyDate(value, caret, key, separator, selectionEnd);
|
|
42
|
-
const { date, time } = splitValue(value);
|
|
43
|
-
const end = selectionEnd ?? caret;
|
|
44
|
-
const dateComplete = date.length === DATE_LENGTH;
|
|
45
|
-
if (end !== caret && caret < DATE_LENGTH && end > DATE_LENGTH) return applyDate(date, caret, key, separator, DATE_LENGTH);
|
|
46
|
-
if (!(caret > DATE_LENGTH || caret === DATE_LENGTH && dateComplete && key !== "Backspace")) {
|
|
47
|
-
const next = applyDate(date, caret, key, separator, end !== caret ? end : void 0);
|
|
48
|
-
return {
|
|
49
|
-
value: join(next.value, time),
|
|
50
|
-
caret: next.caret
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return applyTimePart({
|
|
54
|
-
caret,
|
|
55
|
-
date,
|
|
56
|
-
end,
|
|
57
|
-
key,
|
|
58
|
-
separator,
|
|
59
|
-
time,
|
|
60
|
-
value
|
|
61
|
-
});
|
|
53
|
+
}));
|
|
62
54
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
const next = applyTime({
|
|
79
|
-
value: time,
|
|
80
|
-
caret: hasSelection ? timeCaret : stepOverSeparators(time, timeCaret, key),
|
|
81
|
-
selectionEnd: hasSelection ? timeEnd : void 0,
|
|
82
|
-
key
|
|
83
|
-
});
|
|
84
|
-
return {
|
|
85
|
-
value: join(date, next.value),
|
|
86
|
-
caret: TIME_START + next.caret
|
|
87
|
-
};
|
|
55
|
+
const TWELVE_HOUR = /(\d{1,2}):(\d{2})(?::\d{2})?\s*([ap])\.?\s*m\.?(?![a-z])/i;
|
|
56
|
+
const TIME_ONLY = /^\d{1,2}:\d{2}(?::\d{2})?$/;
|
|
57
|
+
const DATE_AND_TIME = /^\S+[\s,T]+\d{1,2}:\d{2}/;
|
|
58
|
+
const FULL_DATE = /^[^:]*(?:\d\D*){8}$/;
|
|
59
|
+
function readPasted(pasted) {
|
|
60
|
+
const text = pasted.trim();
|
|
61
|
+
const match = TWELVE_HOUR.exec(text);
|
|
62
|
+
if (!match) return text.replace(/\s*\p{L}+\.?$/u, "");
|
|
63
|
+
const [found, hours = "", minutes = "", meridiem = ""] = match;
|
|
64
|
+
const hour = Number(hours);
|
|
65
|
+
if (hour < 1 || hour > 12) return void 0;
|
|
66
|
+
const dayHour = hour % 12 + (meridiem.toLowerCase() === "p" ? 12 : 0);
|
|
67
|
+
return text.replace(found, `${dayHour}:${minutes}`);
|
|
88
68
|
}
|
|
89
|
-
/** Pasted text through the mask, e.g. `24.11.2026 14:30` or `24/11/2026`. */
|
|
69
|
+
/** Pasted text through the mask, e.g. `24.11.2026 14:30`, `2026-11-24T14:30`, `2:30 PM` or `24/11/2026`. */
|
|
90
70
|
function applyDateTimePaste({ caret, pasted, selectionEnd, separator, value, withTime = false }) {
|
|
91
|
-
|
|
92
|
-
if (!withTime || !timePart) return applyPaste({
|
|
71
|
+
if (!withTime) return applyPaste({
|
|
93
72
|
value,
|
|
94
73
|
caret,
|
|
95
74
|
selectionEnd,
|
|
96
|
-
pasted
|
|
75
|
+
pasted,
|
|
97
76
|
separator
|
|
98
77
|
});
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
separator
|
|
104
|
-
}).value;
|
|
105
|
-
const time = applyTimePaste({
|
|
106
|
-
value: "",
|
|
107
|
-
caret: 0,
|
|
108
|
-
pasted: timePart
|
|
109
|
-
}).value;
|
|
110
|
-
const next = join(date, time);
|
|
111
|
-
return {
|
|
112
|
-
value: next,
|
|
113
|
-
caret: next.length
|
|
78
|
+
const text = readPasted(pasted);
|
|
79
|
+
if (text === void 0) return {
|
|
80
|
+
value,
|
|
81
|
+
caret
|
|
114
82
|
};
|
|
83
|
+
const [from, to] = pasteRange(value, text, caret, selectionEnd);
|
|
84
|
+
return dropEmptyTime(applyDateTimePaste$1({
|
|
85
|
+
value,
|
|
86
|
+
caret: from,
|
|
87
|
+
selectionEnd: to,
|
|
88
|
+
pasted: text,
|
|
89
|
+
separator,
|
|
90
|
+
joiner
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
function pasteRange(value, text, caret, selectionEnd) {
|
|
94
|
+
if (selectionEnd !== void 0 && selectionEnd !== caret) return [caret, selectionEnd];
|
|
95
|
+
const timeStart = timeStartOf(value);
|
|
96
|
+
const dateEnd = timeStart === -1 ? value.length : timeStart - 2;
|
|
97
|
+
if (DATE_AND_TIME.test(text)) return [0, value.length];
|
|
98
|
+
if (TIME_ONLY.test(text) && timeStart !== -1 && caret >= timeStart) return [timeStart, value.length];
|
|
99
|
+
if (FULL_DATE.test(text) && caret <= dateEnd) return [0, dateEnd];
|
|
100
|
+
return [caret, selectionEnd];
|
|
115
101
|
}
|
|
102
|
+
const skipsWallClock = (date, text) => {
|
|
103
|
+
const [hours, minutes] = (text.split(joiner)[1] ?? "").split(":").map(Number);
|
|
104
|
+
return date.getHours() !== hours || date.getMinutes() !== minutes;
|
|
105
|
+
};
|
|
116
106
|
/** `empty`, `incomplete`, `invalid` or `valid`, for the date and, with `withTime`, the time. */
|
|
117
107
|
function dateTimeStatus(text, withTime = false) {
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
const
|
|
123
|
-
return
|
|
108
|
+
const date = dateStatus(datePart(text));
|
|
109
|
+
if (!withTime || date === "empty" || date === "invalid") return date;
|
|
110
|
+
const status = dateTimeStatus$1(text, { joiner });
|
|
111
|
+
if (status !== "valid") return status;
|
|
112
|
+
const parsed = parseDateTime$1(text, { joiner });
|
|
113
|
+
return parsed && !skipsWallClock(parsed, text) ? "valid" : "invalid";
|
|
124
114
|
}
|
|
125
115
|
/** The date in the text, with its time when `withTime`; undefined until it is complete and real. */
|
|
126
116
|
function parseDateTime(text, withTime = false) {
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
117
|
+
if (!withTime) return dateStatus(text) === "valid" ? parseDate(text) : void 0;
|
|
118
|
+
const parsed = parseDateTime$1(text, { joiner });
|
|
119
|
+
return parsed && !skipsWallClock(parsed, text) ? parsed : void 0;
|
|
120
|
+
}
|
|
121
|
+
function withDay(text, day, { separator, time, withTime = false }) {
|
|
122
|
+
const date = formatDate(day, separator);
|
|
123
|
+
if (!withTime) return date;
|
|
124
|
+
const typed = text.split(joiner)[1];
|
|
125
|
+
const kept = typed && /\d/.test(typed) ? typed : time;
|
|
126
|
+
return kept ? `${date}${joiner}${kept}` : date;
|
|
127
|
+
}
|
|
128
|
+
function applyDateTimeInput({ caret, next, previous, separator, withTime = false }) {
|
|
129
|
+
let start = 0;
|
|
130
|
+
while (start < previous.length && start < next.length && previous[start] === next[start]) start++;
|
|
131
|
+
let end = 0;
|
|
132
|
+
while (end < previous.length - start && end < next.length - start && previous[previous.length - 1 - end] === next[next.length - 1 - end]) end++;
|
|
133
|
+
const removedEnd = previous.length - end;
|
|
134
|
+
const inserted = next.slice(start, next.length - end);
|
|
135
|
+
if (!inserted) {
|
|
136
|
+
if (removedEnd === start) return {
|
|
137
|
+
caret,
|
|
138
|
+
value: previous
|
|
139
|
+
};
|
|
140
|
+
return applyDateTimeMask({
|
|
141
|
+
caret: start,
|
|
142
|
+
key: "Backspace",
|
|
143
|
+
selectionEnd: removedEnd,
|
|
144
|
+
separator,
|
|
145
|
+
value: previous,
|
|
146
|
+
withTime
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (inserted.length === 1 && start === removedEnd) {
|
|
150
|
+
if (!isDateTimeMaskKey(inserted, withTime)) return {
|
|
151
|
+
caret: start,
|
|
152
|
+
value: previous
|
|
153
|
+
};
|
|
154
|
+
return applyDateTimeMask({
|
|
155
|
+
caret: start,
|
|
156
|
+
key: inserted,
|
|
157
|
+
separator,
|
|
158
|
+
value: previous,
|
|
159
|
+
withTime
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return applyDateTimePaste({
|
|
163
|
+
caret: start,
|
|
164
|
+
pasted: inserted,
|
|
165
|
+
selectionEnd: removedEnd,
|
|
166
|
+
separator,
|
|
167
|
+
value: previous,
|
|
168
|
+
withTime
|
|
169
|
+
});
|
|
135
170
|
}
|
|
136
171
|
/** The day in the text, even while its time is still being typed. */
|
|
137
172
|
function parseDatePart(text) {
|
|
138
|
-
return parseDate(
|
|
173
|
+
return parseDate(datePart(text));
|
|
139
174
|
}
|
|
140
175
|
/** The masked text for a date: `24.11.2026` or `24.11.2026, 14:30`. */
|
|
141
176
|
function formatDateTime(date, separator, withTime = false) {
|
|
142
|
-
return
|
|
177
|
+
if (!withTime) return formatDate(date, separator);
|
|
178
|
+
return formatDateTime$1(date, {
|
|
179
|
+
separator,
|
|
180
|
+
joiner
|
|
181
|
+
});
|
|
143
182
|
}
|
|
144
183
|
//#endregion
|
|
145
|
-
export { applyDateTimeMask, applyDateTimePaste, dateTimeStatus, formatDateTime, formatTime, isDateTimeMaskKey, parseDatePart, parseDateTime };
|
|
184
|
+
export { applyDateTimeInput, applyDateTimeMask, applyDateTimePaste, dateTimeStatus, formatDateTime, formatTime, isDateTimeMaskKey, parseDatePart, parseDateTime, withDay };
|
|
146
185
|
|
|
147
186
|
//# sourceMappingURL=date-time-mask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time-mask.js","names":[],"sources":["../../src/lib/date-time-mask.ts"],"sourcesContent":["import {\n apply,\n applyPaste,\n dateStatus,\n formatDate,\n isDateMaskKey,\n parseDate,\n} from 'ictus'\nimport {\n applyTime,\n applyTimePaste,\n formatTime,\n isTimeMaskKey,\n parseTime,\n timeStatus,\n} from 'ictus/time'\n\n// Fixed positions: `DD.MM.YYYY` then `, HH:MM`, i.e. day-month-year with a one-character\n// separator, the only layout Input Date Time types\nconst DATE_LENGTH = 10\nconst JOIN = ', '\nconst TIME_START = DATE_LENGTH + JOIN.length\n\ntype MaskOptions = { separator: string; withTime?: boolean }\n\nexport type DateTimeMaskInput = MaskOptions & {\n caret: number\n key: string\n selectionEnd?: number\n value: string\n}\n\nexport type DateTimeMaskResult = { caret: number; value: string }\n\nexport type DateTimeStatus = 'empty' | 'incomplete' | 'invalid' | 'valid'\n\nconst splitValue = (value: string) => ({\n date: value.slice(0, DATE_LENGTH),\n time: value.length > DATE_LENGTH ? value.slice(TIME_START) : '',\n})\n\nconst join = (date: string, time: string) =>\n time ? `${date}${JOIN}${time}` : date\n\n/** Keys the mask consumes; any other printable key is ignored. */\nexport function isDateTimeMaskKey(key: string, withTime = false) {\n return isDateMaskKey(key) || (withTime && isTimeMaskKey(key))\n}\n\n// Backspace right after a separator deletes the digit before it, Delete right before one the digit after\nfunction stepOverSeparators(value: string, caret: number, key: string) {\n const isSeparator = (char: string | undefined) =>\n char !== undefined && !/\\d/.test(char)\n let at = caret\n if (key === 'Backspace') while (at > 0 && isSeparator(value[at - 1])) at--\n if (key === 'Delete') while (at < value.length && isSeparator(value[at])) at++\n return at\n}\n\nfunction applyDate(\n value: string,\n caret: number,\n key: string,\n separator: string,\n selectionEnd?: number,\n): DateTimeMaskResult {\n if (selectionEnd !== undefined && selectionEnd !== caret)\n return apply({ value, caret, selectionEnd, key, separator })\n return apply({\n value,\n caret: stepOverSeparators(value, caret, key),\n key,\n separator,\n })\n}\n\n/** One keystroke through the date (and time) mask: the next value and caret. */\nexport function applyDateTimeMask({\n caret,\n key,\n selectionEnd,\n separator,\n value,\n withTime = false,\n}: DateTimeMaskInput): DateTimeMaskResult {\n if (!withTime) return applyDate(value, caret, key, separator, selectionEnd)\n\n const { date, time } = splitValue(value)\n const end = selectionEnd ?? caret\n const dateComplete = date.length === DATE_LENGTH\n\n // A selection reaching into the time drops the time; one inside it edits the time only\n if (end !== caret && caret < DATE_LENGTH && end > DATE_LENGTH)\n return applyDate(date, caret, key, separator, DATE_LENGTH)\n\n const inTime =\n caret > DATE_LENGTH ||\n (caret === DATE_LENGTH && dateComplete && key !== 'Backspace')\n if (!inTime) {\n const next = applyDate(\n date,\n caret,\n key,\n separator,\n end !== caret ? end : undefined,\n )\n return { value: join(next.value, time), caret: next.caret }\n }\n\n return applyTimePart({ caret, date, end, key, separator, time, value })\n}\n\nfunction applyTimePart({\n caret,\n date,\n end,\n key,\n separator,\n time,\n value,\n}: {\n caret: number\n date: string\n end: number\n key: string\n separator: string\n time: string\n value: string\n}): DateTimeMaskResult {\n if (!isTimeMaskKey(key)) return { value, caret }\n const timeCaret = Math.max(0, caret - TIME_START)\n const timeEnd = Math.max(0, end - TIME_START)\n const hasSelection = timeEnd !== timeCaret\n\n // Backspace at the start of the time steps back into the year\n if (key === 'Backspace' && !hasSelection && timeCaret === 0) {\n const next = applyDate(date, DATE_LENGTH, key, separator)\n return { value: join(next.value, time), caret: next.caret }\n }\n\n const next = applyTime({\n value: time,\n caret: hasSelection ? timeCaret : stepOverSeparators(time, timeCaret, key),\n selectionEnd: hasSelection ? timeEnd : undefined,\n key,\n })\n return { value: join(date, next.value), caret: TIME_START + next.caret }\n}\n\n/** Pasted text through the mask, e.g. `24.11.2026 14:30` or `24/11/2026`. */\nexport function applyDateTimePaste({\n caret,\n pasted,\n selectionEnd,\n separator,\n value,\n withTime = false,\n}: MaskOptions & {\n caret: number\n pasted: string\n selectionEnd?: number\n value: string\n}): DateTimeMaskResult {\n const [datePart = '', timePart = ''] = pasted.trim().split(/[,\\sT]+/)\n if (!withTime || !timePart)\n return applyPaste({\n value,\n caret,\n selectionEnd,\n pasted: datePart,\n separator,\n })\n\n const date = applyPaste({\n value: '',\n caret: 0,\n pasted: datePart,\n separator,\n }).value\n const time = applyTimePaste({ value: '', caret: 0, pasted: timePart }).value\n const next = join(date, time)\n return { value: next, caret: next.length }\n}\n\n/** `empty`, `incomplete`, `invalid` or `valid`, for the date and, with `withTime`, the time. */\nexport function dateTimeStatus(text: string, withTime = false): DateTimeStatus {\n const { date, time } = splitValue(text)\n const dateState = dateStatus(date)\n if (!withTime || dateState === 'empty' || dateState === 'invalid')\n return dateState\n if (dateState === 'incomplete') return 'incomplete'\n const timeState = time ? timeStatus(time) : 'incomplete'\n return timeState === 'empty' ? 'incomplete' : timeState\n}\n\n/** The date in the text, with its time when `withTime`; undefined until it is complete and real. */\nexport function parseDateTime(\n text: string,\n withTime = false,\n): Date | undefined {\n if (dateTimeStatus(text, withTime) !== 'valid') return undefined\n const { date, time } = splitValue(text)\n const day = parseDate(date)\n if (!day || !withTime) return day\n const clock = parseTime(time)\n if (!clock) return undefined\n day.setHours(clock.hours, clock.minutes, 0, 0)\n return day\n}\n\n/** The day in the text, even while its time is still being typed. */\nexport function parseDatePart(text: string) {\n return parseDate(splitValue(text).date)\n}\n\n/** The masked text for a date: `24.11.2026` or `24.11.2026, 14:30`. */\nexport function formatDateTime(\n date: Date,\n separator: string,\n withTime = false,\n) {\n return join(formatDate(date, separator), withTime ? formatTime(date) : '')\n}\n\nexport { formatTime }\n"],"mappings":";;;;AAmBA,MAAM,cAAc;AACpB,MAAM,OAAO;AACb,MAAM,aAAa;AAenB,MAAM,cAAc,WAAmB;CACrC,MAAM,MAAM,MAAM,GAAG,WAAW;CAChC,MAAM,MAAM,SAAS,cAAc,MAAM,MAAM,UAAU,IAAI;AAC/D;AAEA,MAAM,QAAQ,MAAc,SAC1B,OAAO,GAAG,OAAO,OAAO,SAAS;;AAGnC,SAAgB,kBAAkB,KAAa,WAAW,OAAO;CAC/D,OAAO,cAAc,GAAG,KAAM,YAA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c,cAAc,OAAO;CACvC,MAAM,YAAY,OAAO,WAAW,IAAI,IAAI;CAC5C,OAAO,cAAc,UAAU,eAAe;AAChD;;AAGA,SAAgB,cACd,MACA,WAAW,OACO;CAClB,IAAI,eAAe,MAAM,QAAQ,MAAM,SAAS,OAAO,KAAA;CACvD,MAAM,EAAE,MAAM,SAAS,WAAW,IAAI;CACtC,MAAM,MAAM,UAAU,IAAI;CAC1B,IAAI,CAAC,OAAO,CAAC,UAAU,OAAO;CAC9B,MAAM,QAAQ,UAAU,IAAI;CAC5B,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,IAAI,SAAS,MAAM,OAAO,MAAM,SAAS,GAAG,CAAC;CAC7C,OAAO;AACT;;AAGA,SAAgB,cAAc,MAAc;CAC1C,OAAO,UAAU,WAAW,IAAI,EAAE,IAAI;AACxC;;AAGA,SAAgB,eACd,MACA,WACA,WAAW,OACX;CACA,OAAO,KAAK,WAAW,MAAM,SAAS,GAAG,WAAW,WAAW,IAAI,IAAI,EAAE;AAC3E"}
|
|
1
|
+
{"version":3,"file":"date-time-mask.js","names":["isIctusDateTimeMaskKey","applyIctusDateTimePaste","ictusDateTimeStatus","ictusParseDateTime","ictusFormatDateTime"],"sources":["../../src/lib/date-time-mask.ts"],"sourcesContent":["import {\n apply,\n applyPaste,\n dateStatus,\n formatDate,\n isDateMaskKey,\n parseDate,\n} from 'ictus'\nimport {\n applyDateTime,\n applyDateTimePaste as applyIctusDateTimePaste,\n dateTimeStatus as ictusDateTimeStatus,\n formatDateTime as ictusFormatDateTime,\n isDateTimeMaskKey as isIctusDateTimeMaskKey,\n parseDateTime as ictusParseDateTime,\n type DateTimeStatus,\n} from 'ictus/datetime'\n\nconst joiner = ', '\n\ntype MaskOptions = { separator: string; withTime?: boolean }\n\nexport type DateTimeMaskInput = MaskOptions & {\n caret: number\n key: string\n selectionEnd?: number\n value: string\n}\n\nexport type DateTimeMaskResult = { caret: number; value: string }\n\nexport type { DateTimeStatus }\n\nconst datePart = (text: string) => text.split(joiner)[0] ?? ''\n\nconst timeStartOf = (value: string) => {\n const at = value.indexOf(joiner)\n return at === -1 ? -1 : at + joiner.length\n}\n\nfunction dropEmptyTime({ caret, value }: DateTimeMaskResult) {\n const at = value.indexOf(joiner)\n if (at === -1 || /\\d/.test(value.slice(at))) return { caret, value }\n return { caret: Math.min(caret, at), value: value.slice(0, at) }\n}\n\n/** Keys the mask consumes; any other printable key is ignored. */\nexport function isDateTimeMaskKey(key: string, withTime = false) {\n return withTime ? isIctusDateTimeMaskKey(key) : isDateMaskKey(key)\n}\n\nfunction stepOverSeparators(value: string, caret: number, key: string) {\n const isSeparator = (char: string | undefined) =>\n char !== undefined && !/\\d/.test(char)\n let at = caret\n if (key === 'Backspace') while (at > 0 && isSeparator(value[at - 1])) at--\n if (key === 'Delete') while (at < value.length && isSeparator(value[at])) at++\n return at\n}\n\n/** One keystroke through the date (and time) mask: the next value and caret. */\nexport function applyDateTimeMask({\n caret,\n key,\n selectionEnd,\n separator,\n value,\n withTime = false,\n}: DateTimeMaskInput): DateTimeMaskResult {\n const collapsed = selectionEnd === undefined || selectionEnd === caret\n const at = collapsed ? stepOverSeparators(value, caret, key) : caret\n const edit = { value, caret: at, selectionEnd: collapsed ? at : selectionEnd }\n if (!withTime) return apply({ ...edit, key, separator })\n return dropEmptyTime(applyDateTime({ ...edit, joiner, key, separator }))\n}\n\nconst TWELVE_HOUR = /(\\d{1,2}):(\\d{2})(?::\\d{2})?\\s*([ap])\\.?\\s*m\\.?(?![a-z])/i\nconst TIME_ONLY = /^\\d{1,2}:\\d{2}(?::\\d{2})?$/\nconst DATE_AND_TIME = /^\\S+[\\s,T]+\\d{1,2}:\\d{2}/\nconst FULL_DATE = /^[^:]*(?:\\d\\D*){8}$/\n\nfunction readPasted(pasted: string) {\n const text = pasted.trim()\n const match = TWELVE_HOUR.exec(text)\n if (!match) return text.replace(/\\s*\\p{L}+\\.?$/u, '')\n const [found, hours = '', minutes = '', meridiem = ''] = match\n const hour = Number(hours)\n if (hour < 1 || hour > 12) return undefined\n const dayHour = (hour % 12) + (meridiem.toLowerCase() === 'p' ? 12 : 0)\n return text.replace(found, `${dayHour}:${minutes}`)\n}\n\n/** Pasted text through the mask, e.g. `24.11.2026 14:30`, `2026-11-24T14:30`, `2:30 PM` or `24/11/2026`. */\nexport function applyDateTimePaste({\n caret,\n pasted,\n selectionEnd,\n separator,\n value,\n withTime = false,\n}: MaskOptions & {\n caret: number\n pasted: string\n selectionEnd?: number\n value: string\n}): DateTimeMaskResult {\n if (!withTime)\n return applyPaste({ value, caret, selectionEnd, pasted, separator })\n const text = readPasted(pasted)\n if (text === undefined) return { value, caret }\n const [from, to] = pasteRange(value, text, caret, selectionEnd)\n return dropEmptyTime(\n applyIctusDateTimePaste({\n value,\n caret: from,\n selectionEnd: to,\n pasted: text,\n separator,\n joiner,\n }),\n )\n}\n\nfunction pasteRange(\n value: string,\n text: string,\n caret: number,\n selectionEnd?: number,\n): [number, number | undefined] {\n if (selectionEnd !== undefined && selectionEnd !== caret)\n return [caret, selectionEnd]\n const timeStart = timeStartOf(value)\n const dateEnd = timeStart === -1 ? value.length : timeStart - joiner.length\n if (DATE_AND_TIME.test(text)) return [0, value.length]\n if (TIME_ONLY.test(text) && timeStart !== -1 && caret >= timeStart)\n return [timeStart, value.length]\n if (FULL_DATE.test(text) && caret <= dateEnd) return [0, dateEnd]\n return [caret, selectionEnd]\n}\n\nconst skipsWallClock = (date: Date, text: string) => {\n const [hours, minutes] = (text.split(joiner)[1] ?? '').split(':').map(Number)\n return date.getHours() !== hours || date.getMinutes() !== minutes\n}\n\n/** `empty`, `incomplete`, `invalid` or `valid`, for the date and, with `withTime`, the time. */\nexport function dateTimeStatus(text: string, withTime = false): DateTimeStatus {\n const date = dateStatus(datePart(text))\n if (!withTime || date === 'empty' || date === 'invalid') return date\n const status = ictusDateTimeStatus(text, { joiner })\n if (status !== 'valid') return status\n const parsed = ictusParseDateTime(text, { joiner })\n return parsed && !skipsWallClock(parsed, text) ? 'valid' : 'invalid'\n}\n\n/** The date in the text, with its time when `withTime`; undefined until it is complete and real. */\nexport function parseDateTime(\n text: string,\n withTime = false,\n): Date | undefined {\n if (!withTime)\n return dateStatus(text) === 'valid' ? parseDate(text) : undefined\n const parsed = ictusParseDateTime(text, { joiner })\n return parsed && !skipsWallClock(parsed, text) ? parsed : undefined\n}\n\nexport function withDay(\n text: string,\n day: Date,\n { separator, time, withTime = false }: MaskOptions & { time?: string },\n) {\n const date = formatDate(day, separator)\n if (!withTime) return date\n const typed = text.split(joiner)[1]\n const kept = typed && /\\d/.test(typed) ? typed : time\n return kept ? `${date}${joiner}${kept}` : date\n}\n\nexport function applyDateTimeInput({\n caret,\n next,\n previous,\n separator,\n withTime = false,\n}: MaskOptions & {\n caret: number\n next: string\n previous: string\n}): DateTimeMaskResult {\n let start = 0\n while (\n start < previous.length &&\n start < next.length &&\n previous[start] === next[start]\n )\n start++\n let end = 0\n while (\n end < previous.length - start &&\n end < next.length - start &&\n previous[previous.length - 1 - end] === next[next.length - 1 - end]\n )\n end++\n const removedEnd = previous.length - end\n const inserted = next.slice(start, next.length - end)\n if (!inserted) {\n if (removedEnd === start) return { caret, value: previous }\n return applyDateTimeMask({\n caret: start,\n key: 'Backspace',\n selectionEnd: removedEnd,\n separator,\n value: previous,\n withTime,\n })\n }\n if (inserted.length === 1 && start === removedEnd) {\n if (!isDateTimeMaskKey(inserted, withTime))\n return { caret: start, value: previous }\n return applyDateTimeMask({\n caret: start,\n key: inserted,\n separator,\n value: previous,\n withTime,\n })\n }\n return applyDateTimePaste({\n caret: start,\n pasted: inserted,\n selectionEnd: removedEnd,\n separator,\n value: previous,\n withTime,\n })\n}\n\n/** The day in the text, even while its time is still being typed. */\nexport function parseDatePart(text: string) {\n return parseDate(datePart(text))\n}\n\n/** The masked text for a date: `24.11.2026` or `24.11.2026, 14:30`. */\nexport function formatDateTime(\n date: Date,\n separator: string,\n withTime = false,\n) {\n if (!withTime) return formatDate(date, separator)\n return ictusForm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AW,SAKU;CACrB,IAAI,QAAQ;CACZ,OACE,QAAQ,SAAS,UACjB,QAAQ,KAAK,UACb,SAAS,WAAW,KAAK,QAEzB;CACF,IAAI,MAAM;CACV,OACE,MAAM,SAAS,SAAS,SACxB,MAAM,KAAK,SAAS,SACpB,SAAS,SAAS,SAAS,IAAI,SAAS,KAAK,KAAK,SAAS,IAAI,MAE/D;CACF,MAAM,aAAa,SAAS,SAAS;CACrC,MAAM,WAAW,KAAK,MAAM,OAAO,KAAK,SAAS,GAAG;CACpD,IAAI,CAAC,UAAU;EACb,IAAI,eAAe,OAAO,OAAO;GAAE;GAAO,OAAO;EAAS;EAC1D,OAAO,kBAAkB;GACvB,OAAO;GACP,KAAK;GACL,cAAc;GACd;GACA,OAAO;GACP;EACF,CAAC;CACH;CACA,IAAI,SAAS,WAAW,KAAK,UAAU,YAAY;EACjD,IAAI,CAAC,kBAAkB,UAAU,QAAQ,GACvC,OAAO;GAAE,OAAO;GAAO,OAAO;EAAS;EACzC,OAAO,kBAAkB;GACvB,OAAO;GACP,KAAK;GACL;GACA,OAAO;GACP;EACF,CAAC;CACH;CACA,OAAO,mBAAmB;EACxB,OAAO;EACP,QAAQ;EACR,cAAc;EACd;EACA,OAAO;EACP;CACF,CAAC;AACH;;AAGA,SAAgB,cAAc,MAAc;CAC1C,OAAO,UAAU,SAAS,IAAI,CAAC;AACjC;;AAGA,SAAgB,eACd,MACA,WACA,WAAW,OACX;CACA,IAAI,CAAC,UAAU,OAAO,WAAW,MAAM,SAAS;CAChD,OAAOC,iBAAoB,MAAM;EAAE;EAAW;CAAO,CAAC;AACxD"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let _radix_ui_colors = require("@radix-ui/colors");
|
|
5
|
-
_radix_ui_colors = require_chunk.__toESM(_radix_ui_colors);
|
|
6
5
|
let colorjs_io = require("colorjs.io");
|
|
7
6
|
colorjs_io = require_chunk.__toESM(colorjs_io);
|
|
8
7
|
let bezier_easing = require("bezier-easing");
|
|
@@ -36,6 +35,66 @@ bezier_easing = require_chunk.__toESM(bezier_easing);
|
|
|
36
35
|
* with Radix's own solver instead of duplicating its rounding-correction logic. Re-apply
|
|
37
36
|
* these two keywords after a re-sync.
|
|
38
37
|
*/
|
|
38
|
+
const RadixColors = {
|
|
39
|
+
grayP3: _radix_ui_colors.grayP3,
|
|
40
|
+
grayDarkP3: _radix_ui_colors.grayDarkP3,
|
|
41
|
+
mauveP3: _radix_ui_colors.mauveP3,
|
|
42
|
+
mauveDarkP3: _radix_ui_colors.mauveDarkP3,
|
|
43
|
+
slateP3: _radix_ui_colors.slateP3,
|
|
44
|
+
slateDarkP3: _radix_ui_colors.slateDarkP3,
|
|
45
|
+
sageP3: _radix_ui_colors.sageP3,
|
|
46
|
+
sageDarkP3: _radix_ui_colors.sageDarkP3,
|
|
47
|
+
oliveP3: _radix_ui_colors.oliveP3,
|
|
48
|
+
oliveDarkP3: _radix_ui_colors.oliveDarkP3,
|
|
49
|
+
sandP3: _radix_ui_colors.sandP3,
|
|
50
|
+
sandDarkP3: _radix_ui_colors.sandDarkP3,
|
|
51
|
+
tomatoP3: _radix_ui_colors.tomatoP3,
|
|
52
|
+
tomatoDarkP3: _radix_ui_colors.tomatoDarkP3,
|
|
53
|
+
redP3: _radix_ui_colors.redP3,
|
|
54
|
+
redDarkP3: _radix_ui_colors.redDarkP3,
|
|
55
|
+
rubyP3: _radix_ui_colors.rubyP3,
|
|
56
|
+
rubyDarkP3: _radix_ui_colors.rubyDarkP3,
|
|
57
|
+
crimsonP3: _radix_ui_colors.crimsonP3,
|
|
58
|
+
crimsonDarkP3: _radix_ui_colors.crimsonDarkP3,
|
|
59
|
+
pinkP3: _radix_ui_colors.pinkP3,
|
|
60
|
+
pinkDarkP3: _radix_ui_colors.pinkDarkP3,
|
|
61
|
+
plumP3: _radix_ui_colors.plumP3,
|
|
62
|
+
plumDarkP3: _radix_ui_colors.plumDarkP3,
|
|
63
|
+
purpleP3: _radix_ui_colors.purpleP3,
|
|
64
|
+
purpleDarkP3: _radix_ui_colors.purpleDarkP3,
|
|
65
|
+
violetP3: _radix_ui_colors.violetP3,
|
|
66
|
+
violetDarkP3: _radix_ui_colors.violetDarkP3,
|
|
67
|
+
irisP3: _radix_ui_colors.irisP3,
|
|
68
|
+
irisDarkP3: _radix_ui_colors.irisDarkP3,
|
|
69
|
+
indigoP3: _radix_ui_colors.indigoP3,
|
|
70
|
+
indigoDarkP3: _radix_ui_colors.indigoDarkP3,
|
|
71
|
+
blueP3: _radix_ui_colors.blueP3,
|
|
72
|
+
blueDarkP3: _radix_ui_colors.blueDarkP3,
|
|
73
|
+
cyanP3: _radix_ui_colors.cyanP3,
|
|
74
|
+
cyanDarkP3: _radix_ui_colors.cyanDarkP3,
|
|
75
|
+
tealP3: _radix_ui_colors.tealP3,
|
|
76
|
+
tealDarkP3: _radix_ui_colors.tealDarkP3,
|
|
77
|
+
jadeP3: _radix_ui_colors.jadeP3,
|
|
78
|
+
jadeDarkP3: _radix_ui_colors.jadeDarkP3,
|
|
79
|
+
greenP3: _radix_ui_colors.greenP3,
|
|
80
|
+
greenDarkP3: _radix_ui_colors.greenDarkP3,
|
|
81
|
+
grassP3: _radix_ui_colors.grassP3,
|
|
82
|
+
grassDarkP3: _radix_ui_colors.grassDarkP3,
|
|
83
|
+
brownP3: _radix_ui_colors.brownP3,
|
|
84
|
+
brownDarkP3: _radix_ui_colors.brownDarkP3,
|
|
85
|
+
orangeP3: _radix_ui_colors.orangeP3,
|
|
86
|
+
orangeDarkP3: _radix_ui_colors.orangeDarkP3,
|
|
87
|
+
skyP3: _radix_ui_colors.skyP3,
|
|
88
|
+
skyDarkP3: _radix_ui_colors.skyDarkP3,
|
|
89
|
+
mintP3: _radix_ui_colors.mintP3,
|
|
90
|
+
mintDarkP3: _radix_ui_colors.mintDarkP3,
|
|
91
|
+
limeP3: _radix_ui_colors.limeP3,
|
|
92
|
+
limeDarkP3: _radix_ui_colors.limeDarkP3,
|
|
93
|
+
yellowP3: _radix_ui_colors.yellowP3,
|
|
94
|
+
yellowDarkP3: _radix_ui_colors.yellowDarkP3,
|
|
95
|
+
amberP3: _radix_ui_colors.amberP3,
|
|
96
|
+
amberDarkP3: _radix_ui_colors.amberDarkP3
|
|
97
|
+
};
|
|
39
98
|
const arrayOf12 = [
|
|
40
99
|
0,
|
|
41
100
|
1,
|
|
@@ -84,10 +143,10 @@ const scaleNames = [
|
|
|
84
143
|
"yellow",
|
|
85
144
|
"amber"
|
|
86
145
|
];
|
|
87
|
-
const lightColors = Object.fromEntries(scaleNames.map((scaleName) => [scaleName, Object.values(
|
|
88
|
-
const darkColors = Object.fromEntries(scaleNames.map((scaleName) => [scaleName, Object.values(
|
|
89
|
-
const lightGrayColors = Object.fromEntries(grayScaleNames.map((scaleName) => [scaleName, Object.values(
|
|
90
|
-
const darkGrayColors = Object.fromEntries(grayScaleNames.map((scaleName) => [scaleName, Object.values(
|
|
146
|
+
const lightColors = Object.fromEntries(scaleNames.map((scaleName) => [scaleName, Object.values(RadixColors[`${scaleName}P3`]).map((str) => new colorjs_io.default(str).to("oklch"))]));
|
|
147
|
+
const darkColors = Object.fromEntries(scaleNames.map((scaleName) => [scaleName, Object.values(RadixColors[`${scaleName}DarkP3`]).map((str) => new colorjs_io.default(str).to("oklch"))]));
|
|
148
|
+
const lightGrayColors = Object.fromEntries(grayScaleNames.map((scaleName) => [scaleName, Object.values(RadixColors[`${scaleName}P3`]).map((str) => new colorjs_io.default(str).to("oklch"))]));
|
|
149
|
+
const darkGrayColors = Object.fromEntries(grayScaleNames.map((scaleName) => [scaleName, Object.values(RadixColors[`${scaleName}DarkP3`]).map((str) => new colorjs_io.default(str).to("oklch"))]));
|
|
91
150
|
const generateRadixColors = ({ appearance, ...args }) => {
|
|
92
151
|
const allScales = appearance === "light" ? lightColors : darkColors;
|
|
93
152
|
const grayScales = appearance === "light" ? lightGrayColors : darkGrayColors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-radix-colors.cjs","names":["RadixColors","Color"],"sources":["../../src/lib/generate-radix-colors.tsx"],"sourcesContent":["/**\n * Vendored from Radix UI's website — components/generate-radix-colors.tsx\n * https://github.com/radix-ui/website\n *\n * MIT License — Copyright (c) 2024 WorkOS\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND. (Full text:\n * https://github.com/radix-ui/website/blob/main/LICENSE)\n *\n * Kept VERBATIM so it can be re-synced upstream (this file is excluded from the\n * formatter in vite.config.ts). Strict type-checking is skipped (upstream targets\n * a looser tsconfig with unchecked array indexing over fixed 12-step scales).\n *\n * Only deviation from upstream: `getAlphaColorSrgb`/`getAlphaColorP3` are `export`ed (no\n * algorithm change) so `accent-theme.ts` can re-solve alpha for its canvas-tinted steps\n * with Radix's own solver instead of duplicating its rounding-correction logic. Re-apply\n * these two keywords after a re-sync.\n */\n// @ts-nocheck\nimport * as RadixColors from \"@radix-ui/colors\";\nimport Color from \"colorjs.io\";\nimport BezierEasing from \"bezier-easing\";\n\ntype ArrayOf12<T> = [T, T, T, T, T, T, T, T, T, T, T, T];\nconst arrayOf12 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] as const;\n\n// prettier-ignore\nconst grayScaleNames = ['gray', 'mauve', 'slate', 'sage', 'olive', 'sand'] as const;\n\n// prettier-ignore\nconst scaleNames = [...grayScaleNames, 'tomato', 'red', 'ruby', 'crimson', 'pink',\n'plum', 'purple', 'violet', 'iris', 'indigo', 'blue', 'cyan', 'teal', 'jade', 'green',\n'grass', 'brown', 'orange', 'sky', 'mint', 'lime', 'yellow', 'amber'] as const;\n\nconst lightColors = Object.fromEntries(\n\tscaleNames.map((scaleName) => [\n\t\tscaleName,\n\t\tObject.values(RadixColors[`${scaleName}P3`]).map((str) => new Color(str).to(\"oklch\")),\n\t]),\n) as Record<(typeof scaleNames)[number], ArrayOf12<Color>>;\n\nconst darkColors = Object.fromEntries(\n\tscaleNames.map((scaleName) => [\n\t\tscaleName,\n\t\tObject.values(RadixColors[`${scaleName}DarkP3`]).map((str) => new Color(str).to(\"oklch\")),\n\t]),\n) as Record<(typeof scaleNames)[number], ArrayOf12<Color>>;\n\nconst lightGrayColors = Object.fromEntries(\n\tgrayScaleNames.map((scaleName) => [\n\t\tscaleName,\n\t\tObject.values(RadixColors[`${scaleName}P3`]).map((str) => new Color(str).to(\"oklch\")),\n\t]),\n) as Record<(typeof grayScaleNames)[number], ArrayOf12<Color>>;\n\nconst darkGrayColors = Object.fromEntries(\n\tgrayScaleNames.map((scaleName) => [\n\t\tscaleName,\n\t\tObject.values(RadixColors[`${scaleName}DarkP3`]).map((str) => new Color(str).to(\"oklch\")),\n\t]),\n) as Record<(typeof grayScaleNames)[number], ArrayOf12<Color>>;\n\nexport const generateRadixColors = ({\n\tappearance,\n\t...args\n}: {\n\tappearance: \"light\" | \"dark\";\n\taccent: string;\n\tgray: string;\n\tbackground: string;\n}) => {\n\tconst allScales = appearance === \"light\" ? lightColors : darkColors;\n\tconst grayScales = appearance === \"light\" ? lightGrayColors : darkGrayColors;\n\tconst backgroundColor = new Color(args.background).to(\"oklch\");\n\n\tconst grayBaseColor = new Color(args.gray).to(\"oklch\");\n\tconst grayScaleColors = getScaleFromColor(grayBaseColor, grayScales, backgroundColor);\n\n\tconst accentBaseColor = new Color(args.accent).to(\"oklch\");\n\n\tlet accentScaleColors = getScaleFromColor(accentBaseColor, allScales, backgroundColor);\n\n\t// Enforce srgb for the background color\n\tconst backgroundHex = backgroundColor.to(\"srgb\").toString({ format: \"hex\" });\n\n\t// Make sure we use the tint from the gray scale for when base is pure white or black\n\tconst accentBaseHex = accentBaseColor.to(\"srgb\").toString({ format: \"hex\" });\n\tif (accentBaseHex === \"#000\" || accentBaseHex === \"#fff\") {\n\t\taccentScaleColors = grayScaleColors.map((color) => color.clone()) as ArrayOf12<Color>;\n\t}\n\n\tconst [accent9Color, accentContrastColor] = getStep9Colors(accentScaleColors, accentBaseColor);\n\n\taccentScaleColors[8] = accent9Color;\n\taccentScaleColors[9] = getButtonHoverColor(accent9Color, [accentScaleColors]);\n\n\t// Limit saturation of the text colors\n\taccentScaleColors[10].coords[1] = Math.min(\n\t\tMath.max(accentScaleColors[8].coords[1], accentScaleColors[7].coords[1]),\n\t\taccentScaleColors[10].coords[1],\n\t);\n\taccentScaleColors[11].coords[1] = Math.min(\n\t\tMath.max(accentScaleColors[8].coords[1], accentScaleColors[7].coords[1]),\n\t\taccentScaleColors[11].coords[1],\n\t);\n\n\tconst accentScaleHex = accentScaleColors.map((color) =>\n\t\tcolor.to(\"srgb\").toString({ format: \"hex\" }),\n\t) as ArrayOf12<string>;\n\n\tconst accentScaleWideGamut = accentScaleColors.map(toOklchString) as ArrayOf12<string>;\n\n\tconst accentScaleAlphaHex = accentScaleHex.map((color) =>\n\t\tgetAlphaColorSrgb(color, backgroundHex),\n\t) as ArrayOf12<string>;\n\n\tconst accentScaleAlphaWideGamutString = accentScaleHex.map((color) =>\n\t\tgetAlphaColorP3(color, backgroundHex),\n\t) as ArrayOf12<string>;\n\n\tconst accentContrastColorHex = accentContrastColor.to(\"srgb\").toString({ format: \"hex\" });\n\n\tconst grayScaleHex = grayScaleColors.map((color) =>\n\t\tcolor.to(\"srgb\").toString({ format: \"hex\" }),\n\t) as ArrayOf12<string>;\n\n\tconst grayScaleWideGamut = grayScaleColors.map(toOklchString) as ArrayOf12<string>;\n\n\tconst grayScaleAlphaHex = grayScaleHex.map((color) =>\n\t\tgetAlphaColorSrgb(color, backgroundHex),\n\t) as ArrayOf12<string>;\n\n\tconst grayScaleAlphaWideGamutString = grayScaleHex.map((color) =>\n\t\tgetAlphaColorP3(color, backgroundHex),\n\t) as ArrayOf12<string>;\n\n\tconst accentSurfaceHex =\n\t\tappearance === \"light\"\n\t\t\t? getAlphaColorSrgb(accentScaleHex[1], backgroundHex, 0.8)\n\t\t\t: getAlphaColorSrgb(accentScaleHex[1], backgroundHex, 0.5);\n\n\tconst accentSurfaceWideGamutString =\n\t\tappearance === \"light\"\n\t\t\t? getAlphaColorP3(accentScaleWideGamut[1], backgroundHex, 0.8)\n\t\t\t: getAlphaColorP3(accentScaleWideGamut[1], backgroundHex, 0.5);\n\n\treturn {\n\t\taccentScale: accentScaleHex,\n\t\taccentScaleAlpha: accentScaleAlphaHex,\n\t\taccentScaleWideGamut: accentScaleWideGamut,\n\t\taccentScaleAlphaWideGamut: accentScaleAlphaWideGamutString,\n\t\taccentContrast: accentContrastColorHex,\n\n\t\tgrayScale: grayScaleHex,\n\t\tgrayScaleAlpha: grayScaleAlphaHex,\n\t\tgrayScaleWideGamut: grayScaleWideGamut,\n\t\tgrayScaleAlphaWideGamut: grayScaleAlphaWideGamutString,\n\n\t\tgraySurface: appearance === \"light\" ? \"#ffffffcc\" : \"rgba(0, 0, 0, 0.05)\",\n\t\tgraySurfaceWideGamut:\n\t\t\tappearance === \"light\" ? \"color(display-p3 1 1 1 / 80%)\" : \"color(display-p3 0 0 0 / 5%)\",\n\n\t\taccentSurface: accentSurfaceHex,\n\t\taccentSurfaceWideGamut: accentSurfaceWideGamutString,\n\n\t\tbackground: backgroundHex,\n\t};\n};\n\nfunction getStep9Colors(scale: ArrayOf12<Color>, accentBaseColor: Color): [Color, Color] {\n\tconst referenceBackgroundColor = scale[0];\n\tconst distance = accentBaseColor.deltaEOK(referenceBackgroundColor) * 100;\n\n\t// If the accent base color is close to the page background color, it's likely\n\t// white on white or black on black, so we want to return something that makes sense instead\n\tif (distance < 25) {\n\t\treturn [scale[8], getTextColor(scale[8])];\n\t}\n\n\treturn [accentBaseColor, getTextColor(accentBaseColor)];\n}\n\nfunction getButtonHoverColor(source: Color, scales: ArrayOf12<Color>[]) {\n\tconst [L, C, H] = source.coords;\n\tconst newL = L > 0.4 ? L - 0.03 / (L + 0.1) : L + 0.03 / (L + 0.1);\n\tconst newC = L > 0.4 && !isNaN(H) ? C * 0.93 + 0 : C;\n\tconst buttonHoverColor = new Color(\"oklch\", [newL, newC, H]);\n\n\t// Find closest in-scale color to donate the chroma and hue.\n\t// Especially useful when the source color is pure white or black,\n\t// but the gray scale is tinted.\n\tlet closestColor = buttonHoverColor;\n\tlet minDistance = Infinity;\n\n\tscales.forEach((scale) => {\n\t\tfor (const color of scale) {\n\t\t\tconst distance = buttonHoverColor.deltaEOK(color);\n\t\t\tif (distance < minDistance) {\n\t\t\t\tminDistance = distance;\n\t\t\t\tclosestColor = color;\n\t\t\t}\n\t\t}\n\t});\n\n\tbuttonHoverColor.coords[1] = closestColor.coords[1];\n\tbuttonHoverColor.coords[2] = closestColor.coords[2];\n\treturn buttonHoverColor;\n}\n\nfunction getScaleFromColor(\n\tsource: Color,\n\tscales: Record<string, ArrayOf12<Color>>,\n\tbackgroundColor: Color,\n) {\n\tlet allColors: { scale: string; color: Color; distance: number }[] = [];\n\n\tObject.entries(scales).forEach(([name, scale]) => {\n\t\tfor (const color of scale) {\n\t\t\tconst distance = source.deltaEOK(color);\n\t\t\tallColors.push({ scale: name, distance, color });\n\t\t}\n\t});\n\n\tallColors.sort((a, b) => a.distance - b.distance);\n\n\t// Remove non-unique scales\n\tlet closestColors = allColors.filter(\n\t\t(color, i, arr) => i === arr.findIndex((value) => value.scale === color.scale),\n\t);\n\n\t// If the next two closest colors are both grays, remove the second one until it’s not a gray anymore.\n\t// This is because up next we will be comparing how close the two closest colors are to the source color,\n\t// and since the grays are all extremely close to each other, we won’t get any useful data from the second\n\t// closest color if it’s also a gray.\n\tconst grayScaleNamesStr = grayScaleNames as readonly string[];\n\tconst allAreGrays = closestColors.every((color) => grayScaleNamesStr.includes(color.scale));\n\tif (!allAreGrays && grayScaleNamesStr.includes(closestColors[0].scale)) {\n\t\twhile (grayScaleNamesStr.includes(closestColors[1].scale)) {\n\t\t\tclosestColors.splice(1, 1);\n\t\t}\n\t}\n\n\tlet colorA = closestColors[0];\n\tlet colorB = closestColors[1];\n\n\t// Light trigonometry ahead.\n\t//\n\t// We want to determine the color that is the closest to the source color. Sometimes it makes sense\n\t// to proportionally mix the two closest colors together, but sometimes it is not useful at all.\n\t// Color coords are spatial in 3D, however we can treat the data we have as a 2D projection that is good enough.\n\t//\n\t// Case 1:\n\t// If the distances between the source color, the 1st closest color (A) and the 2nd closest color (B) form\n\t// a triangle where NEITHER angle A nor B are larger than 90 degrees, then we want to mix the 1st and the 2nd\n\t// closest colors in the same proportion as distances AD and BD are to each other. Mixing the two would result\n\t// in a color that would be closer to the source color than either of the two original closest colors.\n\t// Example: source color is a desaturated blue, which is between \"indigo\" and \"slate\" scales.\n\t//\n\t// C ← Source color\n\t// /|⟍\n\t// / | ⟍\n\t// b / | ⟍ a\n\t// / | ⟍\n\t// / | ⟍\n\t// A --- D -------- B\n\t// ↑\n\t// The color we want to use as the base, which is a mix of A and B.\n\t//\n\t// Case 2:\n\t// If the distances between the source color, the 1st closest color (A) and the 2nd closest color (B) form\n\t// a triangle where EITHER angle A or B are larger than 90 degrees, then we don’t care about point B because it’s\n\t// directionally the same as A, as mixing A and B can’t provide us with a color that is any closer to the source.\n\t// Example: source color is a saturated blue, with \"blue\" being the closest scale, and \"indigo\" just being further.\n\t//\n\t// C ← Source color\n\t// \\⟍\n\t// \\ ⟍\n\t// \\ ⟍ a\n\t// b \\ ⟍\n\t// \\ ⟍\n\t// A ------- B\n\t// ↑\n\t// The color we want to use as the base, which is not influenced by B.\n\n\t// We’ll need all the lengths of the triangle sides, named after the angles they look at:\n\tconst a = colorB.distance;\n\tconst b = colorA.distance;\n\tconst c = colorA.color.deltaEOK(colorB.color);\n\n\t// We can get the ratios of AD to BD lengths with trigonometry using tangents,\n\t// as the ratio of the tangents of the opposite angles will match.\n\tconst cosA = (b ** 2 + c ** 2 - a ** 2) / (2 * b * c);\n\tconst radA = Math.acos(cosA);\n\tconst sinA = Math.sin(radA);\n\n\tconst cosB = (a ** 2 + c ** 2 - b ** 2) / (2 * a * c);\n\tconst radB = Math.acos(cosB);\n\tconst sinB = Math.sin(radB);\n\n\t// Tangent of angle C in the ACD triangle\n\tconst tanC1 = cosA / sinA;\n\n\t// Tangent of angle C in the BCD triangle\n\tconst tanC2 = cosB / sinB;\n\n\t// The ratio of the tangents corresponds to the ratio of the distances AD to BD\n\t// In the end, it means how much of scale B we want to mix into scale A.\n\t// If it’s \"0\" or less, this is an obtuse triangle from case 2, and we use just scale A.\n\tconst ratio = Math.max(0, tanC1 / tanC2) * 0.5;\n\n\t// The base scale is going to be a mix of the two closest scales, with the mix ratio we determined before\n\tconst scaleA = scales[colorA.scale];\n\tconst scaleB = scales[colorB.scale];\n\tconst scale = arrayOf12.map((i) =>\n\t\tnew Color(Color.mix(scaleA[i], scaleB[i], ratio)).to(\"oklch\"),\n\t) as ArrayOf12<Color>;\n\n\t// Get the closest color from the pre-mixed scale we created\n\tconst baseColor = scale.toSorted((a, b) => source.deltaEOK(a) - source.deltaEOK(b))[0];\n\n\t// Note the chroma difference between the source color and the base color\n\tconst ratioC = source.coords[1] / baseColor.coords[1];\n\n\t// Modify hue and chroma of the scale to match the source color\n\tscale.forEach((color) => {\n\t\tcolor.coords[1] = Math.min(source.coords[1] * 1.5, color.coords[1] * ratioC);\n\t\tcolor.coords[2] = source.coords[2];\n\t});\n\n\t// Light mode\n\tif (scale[0].coords[0] > 0.5) {\n\t\tconst lightnessScale = scale.map(({ coords }) => coords[0]);\n\t\tconst backgroundL = Math.max(0, Math.min(1, backgroundColor.coords[0]));\n\t\tconst newLightnessScale = transposeProgressionStart(\n\t\t\tbackgroundL,\n\t\t\t// Add white as the first \"step\" of the light scale\n\t\t\t[1, ...lightnessScale],\n\t\t\tlightModeEasing,\n\t\t);\n\n\t\t// Remove the step we added\n\t\tnewLightnessScale.shift();\n\n\t\tnewLightnessScale.forEach((lightness, i) => {\n\t\t\tscale[i].coords[0] = lightness;\n\t\t});\n\n\t\treturn scale;\n\t}\n\n\t// Dark mode\n\tlet ease: typeof darkModeEasing = [...darkModeEasing];\n\tconst referenceBackgroundColorL = scale[0].coords[0];\n\tconst backgroundColorL = Math.max(0, Math.min(1, backgroundColor.coords[0]));\n\n\t// If background is lighter than step 0, we want to gradually change the easing to linear\n\tconst ratioL = backgroundColorL / referenceBackgroundColorL;\n\n\tif (ratioL > 1) {\n\t\tconst maxRatio = 1.5;\n\n\t\tfor (let i = 0; i < ease.length; i++) {\n\t\t\tconst metaRatio = (ratioL - 1) * (maxRatio / (maxRatio - 1));\n\t\t\tease[i] = ratioL > maxRatio ? 0 : Math.max(0, ease[i] * (1 - metaRatio));\n\t\t}\n\t}\n\n\tconst lightnessScale = scale.map(({ coords }) => coords[0]);\n\tconst backgroundL = backgroundColor.coords[0];\n\tconst newLightnessScale = transposeProgressionStart(backgroundL, lightnessScale, ease);\n\n\tnewLightnessScale.forEach((lightness, i) => {\n\t\tscale[i].coords[0] = lightness;\n\t});\n\n\treturn scale;\n}\n\nfunction getTextColor(background: Color) {\n\tconst white = new Color(\"oklch\", [1, 0, 0]);\n\n\tif (Math.abs(white.contrastAPCA(background)) < 40) {\n\t\tconst [, C, H] = background.coords;\n\t\treturn new Color(\"oklch\", [0.25, Math.max(0.08 * C, 0.04), H]);\n\t}\n\n\treturn white;\n}\n\n// target = background * (1 - alpha) + foreground * alpha\n// alpha = (target - background) / (foreground - background)\n// Expects 0-1 numbers for the RGB channels\n// oxlint-disable-next-line eslint/complexity -- pre-existing; split it before adding branches\nfunction getAlphaColor(\n\ttargetRgb: number[],\n\tbackgroundRgb: number[],\n\trgbPrecision: number,\n\talphaPrecision: number,\n\ttargetAlpha?: number,\n) {\n\tconst [tr, tg, tb] = targetRgb.map((c) => Math.round(c * rgbPrecision));\n\tconst [br, bg, bb] = backgroundRgb.map((c) => Math.round(c * rgbPrecision));\n\n\tif (\n\t\ttr === undefined ||\n\t\ttg === undefined ||\n\t\ttb === undefined ||\n\t\tbr === undefined ||\n\t\tbg === undefined ||\n\t\tbb === undefined\n\t) {\n\t\tthrow Error(\"Color is undefined\");\n\t}\n\n\t// Is the background color lighter, RGB-wise, than target color?\n\t// Decide whether we want to add as little color or as much color as possible,\n\t// darkening or lightening the background respectively.\n\t// If at least one of the bits of the target RGB value\n\t// is lighter than the background, we want to lighten it.\n\tlet desiredRgb = 0;\n\tif (tr > br) {\n\t\tdesiredRgb = rgbPrecision;\n\t} else if (tg > bg) {\n\t\tdesiredRgb = rgbPrecision;\n\t} else if (tb > bb) {\n\t\tdesiredRgb = rgbPrecision;\n\t}\n\n\tconst alphaR = (tr - br) / (desiredRgb - br);\n\tconst alphaG = (tg - bg) / (desiredRgb - bg);\n\tconst alphaB = (tb - bb) / (desiredRgb - bb);\n\n\tconst isPureGray = [alphaR, alphaG, alphaB].every((alpha) => alpha === alphaR);\n\n\t// No need for precision gymnastics with pure grays, and we can get cleaner output\n\tif (!targetAlpha && isPureGray) {\n\t\t// Convert back to 0-1 values\n\t\tconst V = desiredRgb / rgbPrecision;\n\t\treturn [V, V, V, alphaR] as const;\n\t}\n\n\tconst clampRgb = (n: number) => (isNaN(n) ? 0 : Math.min(rgbPrecision, Math.max(0, n)));\n\tconst clampA = (n: number) => (isNaN(n) ? 0 : Math.min(alphaPrecision, Math.max(0, n)));\n\tconst maxAlpha = targetAlpha ?? Math.max(alphaR, alphaG, alphaB);\n\n\tconst A = clampA(Math.ceil(maxAlpha * alphaPrecision)) / alphaPrecision;\n\tlet R = clampRgb(((br * (1 - A) - tr) / A) * -1);\n\tlet G = clampRgb(((bg * (1 - A) - tg) / A) * -1);\n\tlet B = clampRgb(((bb * (1 - A) - tb) / A) * -1);\n\n\tR = Math.ceil(R);\n\tG = Math.ceil(G);\n\tB = Math.ceil(B);\n\n\tconst blendedR = blendAlpha(R, A, br);\n\tconst blendedG = blendAlpha(G, A, bg);\n\tconst blendedB = blendAlpha(B, A, bb);\n\n\t// Correct for rounding errors in light mode\n\tif (desiredRgb === 0) {\n\t\tif (tr <= br && tr !== blendedR) {\n\t\t\tR = tr > blendedR ? R + 1 : R - 1;\n\t\t}\n\n\t\tif (tg <= bg && tg !== blendedG) {\n\t\t\tG = tg > blendedG ? G + 1 : G - 1;\n\t\t}\n\n\t\tif (tb <= bb && tb !== blendedB) {\n\t\t\tB = tb > blendedB ? B + 1 : B - 1;\n\t\t}\n\t}\n\n\t// Correct for rounding errors in dark mode\n\tif (desiredRgb === rgbPrecision) {\n\t\tif (tr >= br && tr !== blendedR) {\n\t\t\tR = tr > blendedR ? R + 1 : R - 1;\n\t\t}\n\n\t\tif (tg >= bg && tg !== blendedG) {\n\t\t\tG = tg > blendedG ? G + 1 : G - 1;\n\t\t}\n\n\t\tif (tb >= bb && tb !== blendedB) {\n\t\t\tB = tb > blendedB ? B + 1 : B - 1;\n\t\t}\n\t}\n\n\t// Convert back to 0-1 values\n\tR = R / rgbPrecision;\n\tG = G / rgbPrecision;\n\tB = B / rgbPrecision;\n\n\treturn [R, G, B, A] as const;\n}\n\n// Important – I empirically discovered that this rounding is how the browser actually overlays\n// transparent RGB bits over each other. It does NOT round the whole result altogether.\nfunction blendAlpha(foreground: number, alpha: number, background: number, round = true) {\n\tif (round) {\n\t\treturn Math.round(background * (1 - alpha)) + Math.round(foreground * alpha);\n\t}\n\n\treturn background * (1 - alpha) + foreground * alpha;\n}\n\nexport function getAlphaColorSrgb(targetColor: string, backgroundColor: string, targetAlpha?: number) {\n\tconst [r, g, b, a] = getAlphaColor(\n\t\tnew Color(targetColor).to(\"srgb\").coords,\n\t\tnew Color(backgroundColor).to(\"srgb\").coords,\n\t\t255,\n\t\t255,\n\t\ttargetAlpha,\n\t);\n\n\treturn formatHex(new Color(\"srgb\", [r, g, b], a).toString({ format: \"hex\" }));\n}\n\nexport function getAlphaColorP3(targetColor: string, backgroundColor: string, targetAlpha?: number) {\n\tconst [r, g, b, a] = getAlphaColor(\n\t\tnew Color(targetColor).to(\"p3\").coords,\n\t\tnew Color(backgroundColor).to(\"p3\").coords,\n\t\t// Not sure why, but the resulting P3 alpha colors are blended in the browser most precisely when\n\t\t// rounded to 255 integers too. Is the browser using 0-255 rather than 0-1 under the hood for P3 too?\n\t\t255,\n\t\t1000,\n\t\ttargetAlpha,\n\t);\n\n\treturn (\n\t\tnew Color(\"p3\", [r, g, b], a)\n\t\t\t.toString({ precision: 4 })\n\t\t\t// Important: in non-browser environments colorjs.io outputs a different format for some reason\n\t\t\t.replace(\"color(p3 \", \"color(display-p3 \")\n\t);\n}\n\n// Format shortform hex to longform\nfunction formatHex(str: string) {\n\tif (!str.startsWith(\"#\")) {\n\t\treturn str;\n\t}\n\n\tif (str.length === 4) {\n\t\tconst hash = str.charAt(0);\n\t\tconst r = str.charAt(1);\n\t\tconst g = str.charAt(2);\n\t\tconst b = str.charAt(3);\n\t\treturn hash + r + r + g + g + b + b;\n\t}\n\n\tif (str.length === 5) {\n\t\tconst hash = str.charAt(0);\n\t\tconst r = str.charAt(1);\n\t\tconst g = str.charAt(2);\n\t\tconst b = str.charAt(3);\n\t\tconst a = str.charAt(4);\n\t\treturn hash + r + r + g + g + b + b + a + a;\n\t}\n\n\treturn str;\n}\n\nconst darkModeEasing = [1, 0, 1, 0] as [number, number, number, number];\nconst lightModeEasing = [0, 2, 0, 2] as [number, number, number, number];\n\nexport function transposeProgressionStart(\n\tto: number,\n\tarr: number[],\n\tcurve: [number, number, number, number],\n) {\n\treturn arr.map((n, i, arr) => {\n\t\tconst lastIndex = arr.length - 1;\n\t\tconst diff = arr[0] - to;\n\t\tconst fn = BezierEasing(...curve);\n\t\treturn n - diff * fn(1 - i / lastIndex);\n\t});\n}\n\nexport function transposeProgressionEnd(\n\tto: number,\n\tarr: number[],\n\tcurve: [number, number, number, number],\n) {\n\treturn arr.map((n, i, arr) => {\n\t\tconst lastIndex = arr.length - 1;\n\t\tconst diff = arr[lastIndex] - to;\n\t\tconst fn = BezierEasing(...curve);\n\t\treturn n - diff * fn(i / lastIndex);\n\t});\n}\n\n// Convert to OKLCH string with percentage for the lightness channel\n// https://github.com/radix-ui/themes/issues/420\nfunction toOklchString(color: Color) {\n\tconst L = +(color.coords[0] * 100).toFixed(1);\n\treturn color\n\t\t.to(\"oklch\")\n\t\t.toString({ precision: 4 })\n\t\t.replace(/(\\S+)(.+)/, `oklch(${L}%$2`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,YAAY;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAI;AAAE;AAGvD,MAAM,iBAAiB;CAAC;CAAQ;CAAS;CAAS;CAAQ;CAAS;AAAM;AAGzE,MAAM,aAAa;CAAC,GAAG;CAAgB;CAAU;CAAO;CAAQ;CAAW;CAC3E;CAAQ;CAAU;CAAU;CAAQ;CAAU;CAAQ;CAAQ;CAAQ;CAAQ;CAC9E;CAAS;CAAS;CAAU;CAAO;CAAQ;CAAQ;CAAU;AAAO;AAEpE,MAAM,cAAc,OAAO,YAC1B,WAAW,KAAK,cAAc,CAC7B,WACA,OAAO,OAAOA,iBAAY,GAAG,UAAU,IAAI,EAAE,KAAK,QAAQ,IAAIC,WAAAA,QAAM,GAAG,EAAE,GAAG,OAAO,CAAC,CACrF,CAAC,CACF;AAEA,MAAM,aAAa,OAAO,YACzB,WAAW,KAAK,cAAc,CAC7B,WACA,OAAO,OAAOD,iBAAY,GAAG,UAAU,QAAQ,EAAE,KAAK,QAAQ,IAAIC,WAAAA,QAAM,GAAG,EAAE,GAAG,OAAO,CAAC,CACzF,CAAC,CACF;AAEA,MAAM,kBAAkB,OAAO,YAC9B,eAAe,KAAK,cAAc,CACjC,WACA,OAAO,OAAOD,iBAAY,GAAG,UAAU,IAA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,KAAK,OAAA,GAAA,cAAA,SACE,GAAG,KACR,EAAE,IAAI,IAAI,SAAS;CACvC,CAAC;AACF;AAEA,SAAgB,wBACf,IACA,KACA,OACC;CACD,OAAO,IAAI,KAAK,GAAG,GAAG,QAAQ;EAC7B,MAAM,YAAY,IAAI,SAAS;EAG/B,OAAO,KAFM,IAAI,aAAa,OAAA,GAAA,cAAA,SACN,GAAG,KACR,EAAE,IAAI,SAAS;CACnC,CAAC;AACF;AAIA,SAAS,cAAc,OAAc;CACpC,MAAM,IAAI,EAAE,MAAM,OAAO,KAAK,KAAK,QAAQ,CAAC;CAC5C,OAAO,MACL,GAAG,OAAO,EACV,SAAS,EAAE,WAAW,EAAE,CAAC,EACzB,QAAQ,aAAa,SAAS,EAAE,IAAI;AACvC"}
|
|
1
|
+
{"version":3,"file":"generate-radix-colors.cjs","names":["Color"],"sources":["../../src/lib/generate-radix-colors.tsx"],"sourcesContent":["/**\n * Vendored from Radix UI's website — components/generate-radix-colors.tsx\n * https://github.com/radix-ui/website\n *\n * MIT License — Copyright (c) 2024 WorkOS\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND. (Full text:\n * https://github.com/radix-ui/website/blob/main/LICENSE)\n *\n * Kept VERBATIM so it can be re-synced upstream (this file is excluded from the\n * formatter in vite.config.ts). Strict type-checking is skipped (upstream targets\n * a looser tsconfig with unchecked array indexing over fixed 12-step scales).\n *\n * Only deviation from upstream: `getAlphaColorSrgb`/`getAlphaColorP3` are `export`ed (no\n * algorithm change) so `accent-theme.ts` can re-solve alpha for its canvas-tinted steps\n * with Radix's own solver instead of duplicating its rounding-correction logic. Re-apply\n * these two keywords after a re-sync.\n */\n// @ts-nocheck\nimport {\n\tgrayP3,\n\tgrayDarkP3,\n\tmauveP3,\n\tmauveDarkP3,\n\tslateP3,\n\tslateDarkP3,\n\tsageP3,\n\tsageDarkP3,\n\toliveP3,\n\toliveDarkP3,\n\tsandP3,\n\tsandDarkP3,\n\ttomatoP3,\n\ttomatoDarkP3,\n\tredP3,\n\tredDarkP3,\n\trubyP3,\n\trubyDarkP3,\n\tcrimsonP3,\n\tcrimsonDarkP3,\n\tpinkP3,\n\tpinkDarkP3,\n\tplumP3,\n\tplumDarkP3,\n\tpurpleP3,\n\tpurpleDarkP3,\n\tvioletP3,\n\tvioletDarkP3,\n\tirisP3,\n\tirisDarkP3,\n\tindigoP3,\n\tindigoDarkP3,\n\tblueP3,\n\tblueDarkP3,\n\tcyanP3,\n\tcyanDarkP3,\n\ttealP3,\n\ttealDarkP3,\n\tjadeP3,\n\tjadeDarkP3,\n\tgreenP3,\n\tgreenDarkP3,\n\tgrassP3,\n\tgrassDarkP3,\n\tbrownP3,\n\tbrownDarkP3,\n\torangeP3,\n\torangeDarkP3,\n\tskyP3,\n\tskyDarkP3,\n\tmintP3,\n\tmintDarkP3,\n\tlimeP3,\n\tlimeDarkP3,\n\tyellowP3,\n\tyellowDarkP3,\n\tamberP3,\n\tamberDarkP3,\n} from \"@radix-ui/colors\";\nimport Color from \"colorjs.io\";\nimport BezierEasing from \"bezier-easing\";\n\nconst RadixColors = {\n\tgrayP3,\n\tgrayDarkP3,\n\tmauveP3,\n\tmauveDarkP3,\n\tslateP3,\n\tslateDarkP3,\n\tsageP3,\n\tsageDarkP3,\n\toliveP3,\n\toliveDarkP3,\n\tsandP3,\n\tsandDarkP3,\n\ttomatoP3,\n\ttomatoDarkP3,\n\tredP3,\n\tredDarkP3,\n\trubyP3,\n\trubyDarkP3,\n\tcrimsonP3,\n\tcrimsonDarkP3,\n\tpinkP3,\n\tpinkDarkP3,\n\tplumP3,\n\tplumDarkP3,\n\tpurpleP3,\n\tpurpleDarkP3,\n\tvioletP3,\n\tvioletDarkP3,\n\tirisP3,\n\tirisDarkP3,\n\tindigoP3,\n\tindigoDarkP3,\n\tblueP3,\n\tblueDarkP3,\n\tcyanP3,\n\tcyanDarkP3,\n\ttealP3,\n\ttealDarkP3,\n\tjadeP3,\n\tjadeDarkP3,\n\tgreenP3,\n\tgreenDarkP3,\n\tgrassP3,\n\tgrassDarkP3,\n\tbrownP3,\n\tbrownDarkP3,\n\torangeP3,\n\torangeDarkP3,\n\tskyP3,\n\tskyDarkP3,\n\tmintP3,\n\tmintDarkP3,\n\tlimeP3,\n\tlimeDarkP3,\n\tyellowP3,\n\tyellowDarkP3,\n\tamberP3,\n\tamberDarkP3,\n};\n\ntype ArrayOf12<T> = [T, T, T, T, T, T, T, T, T, T, T, T];\nconst arrayOf12 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] as const;\n\n// prettier-ignore\nconst grayScaleNames = ['gray', 'mauve', 'slate', 'sage', 'olive', 'sand'] as const;\n\n// prettier-ignore\nconst scaleNames = [...grayScaleNames, 'tomato', 'red', 'ruby', 'crimson', 'pink',\n'plum', 'purple', 'violet', 'iris', 'indigo', 'blue', 'cyan', 'teal', 'jade', 'green',\n'grass', 'brown', 'orange', 'sky', 'mint', 'lime', 'yellow', 'amber'] as const;\n\nconst lightColors = Object.fromEntries(\n\tscaleNames.map((scaleName) => [\n\t\tscaleName,\n\t\tObject.values(RadixColors[`${scaleName}P3`]).map((str) => new Color(str).to(\"oklch\")),\n\t]),\n) as Record<(typeof scaleNames)[number], ArrayOf12<Color>>;\n\nconst darkColors = Object.fromEntries(\n\tscaleNames.map((scaleName) => [\n\t\tscaleName,\n\t\tObject.values(RadixColors[`${scaleName}DarkP3`]).map((str) => new Color(str).to(\"oklch\")),\n\t]),\n) as Record<(typeof scaleNames)[number], ArrayOf12<Color>>;\n\nconst lightGrayColors = Object.fromEntries(\n\tgrayScaleNames.map((scaleName) => [\n\t\tscaleName,\n\t\tObject.values(RadixColors[`${scaleName}P3`]).map((str) => new Color(str).to(\"oklch\")),\n\t]),\n) as Record<(typeof grayScaleNames)[number], ArrayOf12<Color>>;\n\nconst darkGrayColors = Object.fromEntries(\n\tgrayScaleNames.map((scaleName) => [\n\t\tscaleName,\n\t\tObject.values(RadixColors[`${scaleName}DarkP3`]).map((str) => new Color(str).to(\"oklch\")),\n\t]),\n) as Record<(typeof grayScaleNames)[number], ArrayOf12<Color>>;\n\nexport const generateRadixColors = ({\n\tappearance,\n\t...args\n}: {\n\tappearance: \"light\" | \"dark\";\n\taccent: string;\n\tgray: string;\n\tbackground: string;\n}) => {\n\tconst allScales = appearance === \"light\" ? lightColors : darkColors;\n\tconst grayScales = appearance === \"light\" ? lightGrayColors : darkGrayColors;\n\tconst backgroundColor = new Color(args.background).to(\"oklch\");\n\n\tconst grayBaseColor = new Color(args.gray).to(\"oklch\");\n\tconst grayScaleColors = getScaleFromColor(grayBaseColor, grayScales, backgroundColor);\n\n\tconst accentBaseColor = new Color(args.accent).to(\"oklch\");\n\n\tlet accentScaleColors = getScaleFromColor(accentBaseColor, allScales, backgroundColor);\n\n\t// Enforce srgb for the background color\n\tconst backgroundHex = backgroundColor.to(\"srgb\").toString({ format: \"hex\" });\n\n\t// Make sure we use the tint from the gray scale for when base is pure white or black\n\tconst accentBaseHex = accentBaseColor.to(\"srgb\").toString({ format: \"hex\" });\n\tif (accentBaseHex === \"#000\" || accentBaseHex === \"#fff\") {\n\t\taccentScaleColors = grayScaleColors.map((color) => color.clone()) as ArrayOf12<Color>;\n\t}\n\n\tconst [accent9Color, accentContrastColor] = getStep9Colors(accentScaleColors, accentBaseColor);\n\n\taccentScaleColors[8] = accent9Color;\n\taccentScaleColors[9] = getButtonHoverColor(accent9Color, [accentScaleColors]);\n\n\t// Limit saturation of the text colors\n\taccentScaleColors[10].coords[1] = Math.min(\n\t\tMath.max(accentScaleColors[8].coords[1], accentScaleColors[7].coords[1]),\n\t\taccentScaleColors[10].coords[1],\n\t);\n\taccentScaleColors[11].coords[1] = Math.min(\n\t\tMath.max(accentScaleColors[8].coords[1], accentScaleColors[7].coords[1]),\n\t\taccentScaleColors[11].coords[1],\n\t);\n\n\tconst accentScaleHex = accentScaleColors.map((color) =>\n\t\tcolor.to(\"srgb\").toString({ format: \"hex\" }),\n\t) as ArrayOf12<string>;\n\n\tconst accentScaleWideGamut = accentScaleColors.map(toOklchString) as ArrayOf12<string>;\n\n\tconst accentScaleAlphaHex = accentScaleHex.map((color) =>\n\t\tgetAlphaColorSrgb(color, backgroundHex),\n\t) as ArrayOf12<string>;\n\n\tconst accentScaleAlphaWideGamutString = accentScaleHex.map((color) =>\n\t\tgetAlphaColorP3(color, backgroundHex),\n\t) as ArrayOf12<string>;\n\n\tconst accentContrastColorHex = accentContrastColor.to(\"srgb\").toString({ format: \"hex\" });\n\n\tconst grayScaleHex = grayScaleColors.map((color) =>\n\t\tcolor.to(\"srgb\").toString({ format: \"hex\" }),\n\t) as ArrayOf12<string>;\n\n\tconst grayScaleWideGamut = grayScaleColors.map(toOklchString) as ArrayOf12<string>;\n\n\tconst grayScaleAlphaHex = grayScaleHex.map((color) =>\n\t\tgetAlphaColorSrgb(color, backgroundHex),\n\t) as ArrayOf12<string>;\n\n\tconst grayScaleAlphaWideGamutString = grayScaleHex.map((color) =>\n\t\tgetAlphaColorP3(color, backgroundHex),\n\t) as ArrayOf12<string>;\n\n\tconst accentSurfaceHex =\n\t\tappearance === \"light\"\n\t\t\t? getAlphaColorSrgb(accentScaleHex[1], backgroundHex, 0.8)\n\t\t\t: getAlphaColorSrgb(accentScaleHex[1], backgroundHex, 0.5);\n\n\tconst accentSurfaceWideGamutString =\n\t\tappearance === \"light\"\n\t\t\t? getAlphaColorP3(accentScaleWideGamut[1], backgroundHex, 0.8)\n\t\t\t: getAlphaColorP3(accentScaleWideGamut[1], backgroundHex, 0.5);\n\n\treturn {\n\t\taccentScale: accentScaleHex,\n\t\taccentScaleAlpha: accentScaleAlphaHex,\n\t\taccentScaleWideGamut: accentScaleWideGamut,\n\t\taccentScaleAlphaWideGamut: accentScaleAlphaWideGamutString,\n\t\taccentContrast: accentContrastColorHex,\n\n\t\tgrayScale: grayScaleHex,\n\t\tgrayScaleAlpha: grayScaleAlphaHex,\n\t\tgrayScaleWideGamut: grayScaleWideGamut,\n\t\tgrayScaleAlphaWideGamut: grayScaleAlphaWideGamutString,\n\n\t\tgraySurface: appearance === \"light\" ? \"#ffffffcc\" : \"rgba(0, 0, 0, 0.05)\",\n\t\tgraySurfaceWideGamut:\n\t\t\tappearance === \"light\" ? \"color(display-p3 1 1 1 / 80%)\" : \"color(display-p3 0 0 0 / 5%)\",\n\n\t\taccentSurface: accentSurfaceHex,\n\t\taccentSurfaceWideGamut: accentSurfaceWideGamutString,\n\n\t\tbackground: backgroundHex,\n\t};\n};\n\nfunction getStep9Colors(scale: ArrayOf12<Color>, accentBaseColor: Color): [Color, Color] {\n\tconst referenceBackgroundColor = scale[0];\n\tconst distance = accentBaseColor.deltaEOK(referenceBackgroundColor) * 100;\n\n\t// If the accent base color is close to the page background color, it's likely\n\t// white on white or black on black, so we want to return something that makes sense instead\n\tif (distance < 25) {\n\t\treturn [scale[8], getTextColor(scale[8])];\n\t}\n\n\treturn [accentBaseColor, getTextColor(accentBaseColor)];\n}\n\nfunction getButtonHoverColor(source: Color, scales: ArrayOf12<Color>[]) {\n\tconst [L, C, H] = source.coords;\n\tconst newL = L > 0.4 ? L - 0.03 / (L + 0.1) : L + 0.03 / (L + 0.1);\n\tconst newC = L > 0.4 && !isNaN(H) ? C * 0.93 + 0 : C;\n\tconst buttonHoverColor = new Color(\"oklch\", [newL, newC, H]);\n\n\t// Find closest in-scale color to donate the chroma and hue.\n\t// Especially useful when the source color is pure white or black,\n\t// but the gray scale is tinted.\n\tlet closestColor = buttonHoverColor;\n\tlet minDistance = Infinity;\n\n\tscales.forEach((scale) => {\n\t\tfor (const color of scale) {\n\t\t\tconst distance = buttonHoverColor.deltaEOK(color);\n\t\t\tif (distance < minDistance) {\n\t\t\t\tminDistance = distance;\n\t\t\t\tclosestColor = color;\n\t\t\t}\n\t\t}\n\t});\n\n\tbuttonHoverColor.coords[1] = closestColor.coords[1];\n\tbuttonHoverColor.coords[2] = closestColor.coords[2];\n\treturn buttonHoverColor;\n}\n\nfunction getScaleFromColor(\n\tsource: Color,\n\tscales: Record<string, ArrayOf12<Color>>,\n\tbackgroundColor: Color,\n) {\n\tlet allColors: { scale: string; color: Color; distance: number }[] = [];\n\n\tObject.entries(scales).forEach(([name, scale]) => {\n\t\tfor (const color of scale) {\n\t\t\tconst distance = source.deltaEOK(color);\n\t\t\tallColors.push({ scale: name, distance, color });\n\t\t}\n\t});\n\n\tallColors.sort((a, b) => a.distance - b.distance);\n\n\t// Remove non-unique scales\n\tlet closestColors = allColors.filter(\n\t\t(color, i, arr) => i === arr.findIndex((value) => value.scale === color.scale),\n\t);\n\n\t// If the next two closest colors are both grays, remove the second one until it’s not a gray anymore.\n\t// This is because up next we will be comparing how close the two closest colors are to the source color,\n\t// and since the grays are all extremely close to each other, we won’t get any useful data from the second\n\t// closest color if it’s also a gray.\n\tconst grayScaleNamesStr = grayScaleNames as readonly string[];\n\tconst allAreGrays = closestColors.every((color) => grayScaleNamesStr.includes(color.scale));\n\tif (!allAreGrays && grayScaleNamesStr.includes(closestColors[0].scale)) {\n\t\twhile (grayScaleNamesStr.includes(closestColors[1].scale)) {\n\t\t\tclosestColors.splice(1, 1);\n\t\t}\n\t}\n\n\tlet colorA = closestColors[0];\n\tlet colorB = closestColors[1];\n\n\t// Light trigonometry ahead.\n\t//\n\t// We want to determine the color that is the closest to the source color. Sometimes it makes sense\n\t// to proportionally mix the two closest colors together, but sometimes it is not useful at all.\n\t// Color coords are spatial in 3D, however we can treat the data we have as a 2D projection that is good enough.\n\t//\n\t// Case 1:\n\t// If the distances between the source color, the 1st closest color (A) and the 2nd closest color (B) form\n\t// a triangle where NEITHER angle A nor B are larger than 90 degrees, then we want to mix the 1st and the 2nd\n\t// closest colors in the same proportion as distances AD and BD are to each other. Mixing the two would result\n\t// in a color that would be closer to the source color than either of the two original closest colors.\n\t// Example: source color is a desaturated blue, which is between \"indigo\" and \"slate\" scales.\n\t//\n\t// C ← Source color\n\t// /|⟍\n\t// / | ⟍\n\t// b / | ⟍ a\n\t// / | ⟍\n\t// / | ⟍\n\t// A --- D -------- B\n\t// ↑\n\t// The color we want to use as the base, which is a mix of A and B.\n\t//\n\t// Case 2:\n\t// If the distances between the source color, the 1st closest color (A) and the 2nd closest color (B) form\n\t// a triangle where EITHER angle A or B are larger than 90 degrees, then we don’t care about point B because it’s\n\t// directionally the same as A, as mixing A and B can’t provide us with a color that is any closer to the source.\n\t// Example: source color is a saturated blue, with \"blue\" being the closest scale, and \"indigo\" just being further.\n\t//\n\t// C ← Source color\n\t// \\⟍\n\t// \\ ⟍\n\t// \\ ⟍ a\n\t// b \\ ⟍\n\t// \\ ⟍\n\t// A ------- B\n\t// ↑\n\t// The color we want to use as the base, which is not influenced by B.\n\n\t// We’ll need all the lengths of the triangle sides, named after the angles they look at:\n\tconst a = colorB.distance;\n\tconst b = colorA.distance;\n\tconst c = colorA.color.deltaEOK(colorB.color);\n\n\t// We can get the ratios of AD to BD lengths with trigonometry using tangents,\n\t// as the ratio of the tangents of the opposite angles will match.\n\tconst cosA = (b ** 2 + c ** 2 - a ** 2) / (2 * b * c);\n\tconst radA = Math.acos(cosA);\n\tconst sinA = Math.sin(radA);\n\n\tconst cosB = (a ** 2 + c ** 2 - b ** 2) / (2 * a * c);\n\tconst radB = Math.acos(cosB);\n\tconst sinB = Math.sin(radB);\n\n\t// Tangent of angle C in the ACD triangle\n\tconst tanC1 = cosA / sinA;\n\n\t// Tangent of angle C in the BCD triangle\n\tconst tanC2 = cosB / sinB;\n\n\t// The ratio of the tangents corresponds to the ratio of the distances AD to BD\n\t// In the end, it means how much of scale B we want to mix into scale A.\n\t// If it’s \"0\" or less, this is an obtuse triangle from case 2, and we use just scale A.\n\tconst ratio = Math.max(0, tanC1 / tanC2) * 0.5;\n\n\t// The base scale is going to be a mix of the two closest scales, with the mix ratio we determined before\n\tconst scaleA = scales[colorA.scale];\n\tconst scaleB = scales[colorB.scale];\n\tconst scale = arrayOf12.map((i) =>\n\t\tnew Color(Color.mix(scaleA[i], scaleB[i], ratio)).to(\"oklch\"),\n\t) as ArrayOf12<Color>;\n\n\t// Get the closest color from the pre-mixed scale we created\n\tconst baseColor = scale.toSorted((a, b) => source.deltaEOK(a) - source.deltaEOK(b))[0];\n\n\t// Note the chroma difference between the source color and the base color\n\tconst ratioC = source.coords[1] / baseColor.coords[1];\n\n\t// Modify hue and chroma of the scale to match the source color\n\tscale.forEach((color) => {\n\t\tcolor.coords[1] = Math.min(source.coords[1] * 1.5, color.coords[1] * ratioC);\n\t\tcolor.coords[2] = source.coords[2];\n\t});\n\n\t// Light mode\n\tif (scale[0].coords[0] > 0.5) {\n\t\tconst lightnessScale = scale.map(({ coords }) => coords[0]);\n\t\tconst backgroundL = Math.max(0, Math.min(1, backgroundColor.coords[0]));\n\t\tconst newLightnessScale = transposeProgressionStart(\n\t\t\tbackgroundL,\n\t\t\t// Add white as the first \"step\" of the light scale\n\t\t\t[1, ...lightnessScale],\n\t\t\tlightModeEasing,\n\t\t);\n\n\t\t// Remove the step we added\n\t\tnewLightnessScale.shift();\n\n\t\tnewLightnessScale.forEach((lightness, i) => {\n\t\t\tscale[i].coords[0] = lightness;\n\t\t});\n\n\t\treturn scale;\n\t}\n\n\t// Dark mode\n\tlet ease: typeof darkModeEasing = [...darkModeEasing];\n\tconst referenceBackgroundColorL = scale[0].coords[0];\n\tconst backgroundColorL = Math.max(0, Math.min(1, backgroundColor.coords[0]));\n\n\t// If background is lighter than step 0, we want to gradually change the easing to linear\n\tconst ratioL = backgroundColorL / referenceBackgroundColorL;\n\n\tif (ratioL > 1) {\n\t\tconst maxRatio = 1.5;\n\n\t\tfor (let i = 0; i < ease.length; i++) {\n\t\t\tconst metaRatio = (ratioL - 1) * (maxRatio / (maxRatio - 1));\n\t\t\tease[i] = ratioL > maxRatio ? 0 : Math.max(0, ease[i] * (1 - metaRatio));\n\t\t}\n\t}\n\n\tconst lightnessScale = scale.map(({ coords }) => coords[0]);\n\tconst backgroundL = backgroundColor.coords[0];\n\tconst newLightnessScale = transposeProgressionStart(backgroundL, lightnessScale, ease);\n\n\tnewLightnessScale.forEach((lightness, i) => {\n\t\tscale[i].coords[0] = lightness;\n\t});\n\n\treturn scale;\n}\n\nfunction getTextColor(background: Color) {\n\tconst white = new Color(\"oklch\", [1, 0, 0]);\n\n\tif (Math.abs(white.contrastAPCA(background)) < 40) {\n\t\tconst [, C, H] = background.coords;\n\t\treturn new Color(\"oklch\", [0.25, Math.max(0.08 * C, 0.04), H]);\n\t}\n\n\treturn white;\n}\n\n// target = background * (1 - alpha) + foreground * alpha\n// alpha = (target - background) / (foreground - background)\n// Expects 0-1 numbers for the RGB channels\n// oxlint-disable-next-line eslint/complexity -- pre-existing; split it before adding branches\nfunction getAlphaColor(\n\ttargetRgb: number[],\n\tbackgroundRgb: number[],\n\trgbPrecision: number,\n\talphaPrecision: number,\n\ttargetAlpha?: number,\n) {\n\tconst [tr, tg, tb] = targetRgb.map((c) => Math.round(c * rgbPrecision));\n\tconst [br, bg, bb] = backgroundRgb.map((c) => Math.round(c * rgbPrecision));\n\n\tif (\n\t\ttr === undefined ||\n\t\ttg === undefined ||\n\t\ttb === undefined ||\n\t\tbr === undefined ||\n\t\tbg === undefined ||\n\t\tbb === undefined\n\t) {\n\t\tthrow Error(\"Color is undefined\");\n\t}\n\n\t// Is the background color lighter, RGB-wise, than target color?\n\t// Decide whether we want to add as little color or as much color as possible,\n\t// darkening or lightening the background respectively.\n\t// If at least one of the bits of the target RGB value\n\t// is lighter than the background, we want to lighten it.\n\tlet desiredRgb = 0;\n\tif (tr > br) {\n\t\tdesiredRgb = rgbPrecision;\n\t} else if (tg > bg) {\n\t\tdesiredRgb = rgbPrecision;\n\t} else if (tb > bb) {\n\t\tdesiredRgb = rgbPrecision;\n\t}\n\n\tconst alphaR = (tr - br) / (desiredRgb - br);\n\tconst alphaG = (tg - bg) / (desiredRgb - bg);\n\tconst alphaB = (tb - bb) / (desiredRgb - bb);\n\n\tconst isPureGray = [alphaR, alphaG, alphaB].every((alpha) => alpha === alphaR);\n\n\t// No need for precision gymnastics with pure grays, and we can get cleaner output\n\tif (!targetAlpha && isPureGray) {\n\t\t// Convert back to 0-1 values\n\t\tconst V = desiredRgb / rgbPrecision;\n\t\treturn [V, V, V, alphaR] as const;\n\t}\n\n\tconst clampRgb = (n: number) => (isNaN(n) ? 0 : Math.min(rgbPrecision, Math.max(0, n)));\n\tconst clampA = (n: number) => (isNaN(n) ? 0 : Math.min(alphaPrecision, Math.max(0, n)));\n\tconst maxAlpha = targetAlpha ?? Math.max(alphaR, alphaG, alphaB);\n\n\tconst A = clampA(Math.ceil(maxAlpha * alphaPrecision)) / alphaPrecision;\n\tlet R = clampRgb(((br * (1 - A) - tr) / A) * -1);\n\tlet G = clampRgb(((bg * (1 - A) - tg) / A) * -1);\n\tlet B = clampRgb(((bb * (1 - A) - tb) / A) * -1);\n\n\tR = Math.ceil(R);\n\tG = Math.ceil(G);\n\tB = Math.ceil(B);\n\n\tconst blendedR = blendAlpha(R, A, br);\n\tconst blendedG = blendAlpha(G, A, bg);\n\tconst blendedB = blendAlpha(B, A, bb);\n\n\t// Correct for rounding errors in light mode\n\tif (desiredRgb === 0) {\n\t\tif (tr <= br && tr !== blendedR) {\n\t\t\tR = tr > blendedR ? R + 1 : R - 1;\n\t\t}\n\n\t\tif (tg <= bg && tg !== blendedG) {\n\t\t\tG = tg > blendedG ? G + 1 : G - 1;\n\t\t}\n\n\t\tif (tb <= bb && tb !== blendedB) {\n\t\t\tB = tb > blendedB ? B + 1 : B - 1;\n\t\t}\n\t}\n\n\t// Correct for rounding errors in dark mode\n\tif (desiredRgb === rgbPrecision) {\n\t\tif (tr >= br && tr !== blendedR) {\n\t\t\tR = tr > blendedR ? R + 1 : R - 1;\n\t\t}\n\n\t\tif (tg >= bg && tg !== blendedG) {\n\t\t\tG = tg > blendedG ? G + 1 : G - 1;\n\t\t}\n\n\t\tif (tb >= bb && tb !== blendedB) {\n\t\t\tB = tb > blendedB ? B + 1 : B - 1;\n\t\t}\n\t}\n\n\t// Convert back to 0-1 values\n\tR = R / rgbPrecision;\n\tG = G / rgbPrecision;\n\tB = B / rgbPrecision;\n\n\treturn [R, G, B, A] as const;\n}\n\n// Important – I empirically discovered that this rounding is how the browser actually overlays\n// transparent RGB bits over each other. It does NOT round the whole result altogether.\nfunction blendAlpha(foreground: number, alpha: number, background: number, round = true) {\n\tif (round) {\n\t\treturn Math.round(background * (1 - alpha)) + Math.round(foreground * alpha);\n\t}\n\n\treturn background * (1 - alpha) + foreground * alpha;\n}\n\nexport function getAlphaColorSrgb(targetColor: string, backgroundColor: string, targetAlpha?: number) {\n\tconst [r, g, b, a] = getAlphaColor(\n\t\tnew Color(targetColor).to(\"srgb\").coords,\n\t\tnew Color(backgroundColor).to(\"srgb\").coords,\n\t\t255,\n\t\t255,\n\t\ttargetAlpha,\n\t);\n\n\treturn formatHex(new Color(\"srgb\", [r, g, b], a).toString({ format: \"hex\" }));\n}\n\nexport function getAlphaColorP3(targetColor: string, backgroundColor: string, targetAlpha?: number) {\n\tconst [r, g, b, a] = getAlphaColor(\n\t\tnew Color(targetColor).to(\"p3\").coords,\n\t\tnew Color(backgroundColor).to(\"p3\").coords,\n\t\t// Not sure why, but the resulting P3 alpha colors are blended in the browser most precisely when\n\t\t// rounded to 255 integers too. Is the browser using 0-255 rather than 0-1 under the hood for P3 too?\n\t\t255,\n\t\t1000,\n\t\ttargetAlpha,\n\t);\n\n\treturn (\n\t\tnew Color(\"p3\", [r, g, b], a)\n\t\t\t.toString({ precision: 4 })\n\t\t\t// Important: in non-browser environments colorjs.io outputs a different format for some reason\n\t\t\t.replace(\"color(p3 \", \"color(display-p3 \")\n\t);\n}\n\n// Format shortform hex to longform\nfunction formatHex(str: string) {\n\tif (!str.startsWith(\"#\")) {\n\t\treturn str;\n\t}\n\n\tif (str.length === 4) {\n\t\tconst hash = str.charAt(0);\n\t\tconst r = str.charAt(1);\n\t\tconst g = str.charAt(2);\n\t\tconst b = str.charAt(3);\n\t\treturn hash + r + r + g + g + b + b;\n\t}\n\n\tif (str.length === 5) {\n\t\tconst hash = str.charAt(0);\n\t\tconst r = str.charAt(1);\n\t\tconst g = str.charAt(2);\n\t\tconst b = str.charAt(3);\n\t\tconst a = str.charAt(4);\n\t\treturn hash + r + r + g + g + b + b + a + a;\n\t}\n\n\treturn str;\n}\n\nconst darkModeEasing = [1, 0, 1, 0] as [number, number, number, number];\nconst lightModeEasing = [0, 2, 0, 2] as [number, number, number, number];\n\nexport function transposeProgressionStart(\n\tto: number,\n\tarr: number[],\n\tcurve: [number, number, number, number],\n) {\n\treturn arr.map((n, i, arr) => {\n\t\tconst lastIndex = arr.length - 1;\n\t\tconst diff = arr[0] - to;\n\t\tconst fn = BezierEasing(...curve);\n\t\treturn n - diff * fn(1 - i / lastIndex);\n\t});\n}\n\nexport function transposeProgressionEnd(\n\tto: number,\n\tarr: number[],\n\tcurve: [number, number, number, number],\n) {\n\treturn arr.map((n, i, arr) => {\n\t\tconst lastIndex = arr.length - 1;\n\t\tconst diff = arr[lastIndex] - to;\n\t\tconst fn = BezierEasing(...curve);\n\t\treturn n - diff * fn(i / lastIndex);\n\t});\n}\n\n// Convert to OKLCH string with percentage for the lightness channel\n// https://github.com/radix-ui/themes/issues/420\nfunction toOklchString(color: Color) {\n\tconst L = +(color.coords[0] * 100).toFixed(1);\n\treturn color\n\t\t.to(\"oklch\")\n\t\t.toString({ precision: 4 })\n\t\t.replace(/(\\S+)(.+)/, `oklch(${L}%$2`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAM,cAAc;CACnB,QAAA,iBAAA;CACA,YAAA,iBAAA;CACA,SAAA,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