@multiplatform.one/components 10.1.1 → 10.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/MiddleEllipsisText/index.native.cjs +5 -1
- package/dist/cjs/MiddleEllipsisText/index.native.js +5 -1
- package/dist/cjs/MiddleEllipsisText/index.native.js.map +1 -1
- package/dist/cjs/Tabs/index.cjs +3 -2
- package/dist/cjs/Tabs/index.native.cjs +3 -2
- package/dist/cjs/Tabs/index.native.js +3 -2
- package/dist/cjs/Tabs/index.native.js.map +1 -1
- package/dist/cjs/layouts/timeline.cjs +0 -1
- package/dist/cjs/layouts/timeline.native.cjs +0 -1
- package/dist/cjs/layouts/timeline.native.js +0 -1
- package/dist/cjs/layouts/timeline.native.js.map +1 -1
- package/dist/cjs/views/Calendar.cjs +54 -76
- package/dist/cjs/views/Calendar.native.cjs +54 -76
- package/dist/cjs/views/Calendar.native.js +54 -76
- package/dist/cjs/views/Calendar.native.js.map +1 -1
- package/dist/cjs/views/Gantt.cjs +185 -69
- package/dist/cjs/views/Gantt.native.cjs +190 -72
- package/dist/cjs/views/Gantt.native.js +190 -72
- package/dist/cjs/views/Gantt.native.js.map +1 -1
- package/dist/cjs/views/GanttDateGrip.cjs +20 -14
- package/dist/cjs/views/GanttDateGrip.native.cjs +24 -14
- package/dist/cjs/views/GanttDateGrip.native.js +24 -14
- package/dist/cjs/views/GanttDateGrip.native.js.map +1 -1
- package/dist/cjs/views/GanttGripDot.cjs +43 -0
- package/dist/cjs/views/GanttGripDot.native.cjs +46 -0
- package/dist/cjs/views/GanttGripDot.native.js +48 -0
- package/dist/cjs/views/GanttGripDot.native.js.map +1 -0
- package/dist/cjs/views/eventTint.cjs +242 -0
- package/dist/cjs/views/eventTint.native.cjs +346 -0
- package/dist/cjs/views/eventTint.native.js +348 -0
- package/dist/cjs/views/eventTint.native.js.map +1 -0
- package/dist/esm/MiddleEllipsisText/index.native.js +2 -1
- package/dist/esm/MiddleEllipsisText/index.native.js.map +1 -1
- package/dist/esm/Tabs/index.mjs +3 -2
- package/dist/esm/Tabs/index.mjs.map +1 -1
- package/dist/esm/Tabs/index.native.js +3 -2
- package/dist/esm/Tabs/index.native.js.map +1 -1
- package/dist/esm/layouts/timeline.mjs +0 -1
- package/dist/esm/layouts/timeline.mjs.map +1 -1
- package/dist/esm/layouts/timeline.native.js +0 -1
- package/dist/esm/layouts/timeline.native.js.map +1 -1
- package/dist/esm/views/Calendar.mjs +53 -75
- package/dist/esm/views/Calendar.mjs.map +1 -1
- package/dist/esm/views/Calendar.native.js +53 -75
- package/dist/esm/views/Calendar.native.js.map +1 -1
- package/dist/esm/views/Gantt.mjs +186 -70
- package/dist/esm/views/Gantt.mjs.map +1 -1
- package/dist/esm/views/Gantt.native.js +191 -73
- package/dist/esm/views/Gantt.native.js.map +1 -1
- package/dist/esm/views/GanttDateGrip.mjs +21 -15
- package/dist/esm/views/GanttDateGrip.mjs.map +1 -1
- package/dist/esm/views/GanttDateGrip.native.js +25 -15
- package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
- package/dist/esm/views/GanttGripDot.mjs +24 -0
- package/dist/esm/views/GanttGripDot.mjs.map +1 -0
- package/dist/esm/views/GanttGripDot.native.js +25 -0
- package/dist/esm/views/GanttGripDot.native.js.map +1 -0
- package/dist/esm/views/eventTint.mjs +196 -0
- package/dist/esm/views/eventTint.mjs.map +1 -0
- package/dist/esm/views/eventTint.native.js +298 -0
- package/dist/esm/views/eventTint.native.js.map +1 -0
- package/dist/jsx/MiddleEllipsisText/index.native.cjs +5 -1
- package/dist/jsx/MiddleEllipsisText/index.native.js +5 -1
- package/dist/jsx/MiddleEllipsisText/index.native.js.map +1 -1
- package/dist/jsx/Tabs/index.mjs +3 -2
- package/dist/jsx/Tabs/index.mjs.map +1 -1
- package/dist/jsx/Tabs/index.native.cjs +3 -2
- package/dist/jsx/Tabs/index.native.js +3 -2
- package/dist/jsx/Tabs/index.native.js.map +1 -1
- package/dist/jsx/layouts/timeline.mjs +0 -1
- package/dist/jsx/layouts/timeline.mjs.map +1 -1
- package/dist/jsx/layouts/timeline.native.cjs +0 -1
- package/dist/jsx/layouts/timeline.native.js +0 -1
- package/dist/jsx/layouts/timeline.native.js.map +1 -1
- package/dist/jsx/views/Calendar.mjs +53 -75
- package/dist/jsx/views/Calendar.mjs.map +1 -1
- package/dist/jsx/views/Calendar.native.cjs +54 -76
- package/dist/jsx/views/Calendar.native.js +54 -76
- package/dist/jsx/views/Calendar.native.js.map +1 -1
- package/dist/jsx/views/Gantt.mjs +186 -70
- package/dist/jsx/views/Gantt.mjs.map +1 -1
- package/dist/jsx/views/Gantt.native.cjs +190 -72
- package/dist/jsx/views/Gantt.native.js +190 -72
- package/dist/jsx/views/Gantt.native.js.map +1 -1
- package/dist/jsx/views/GanttDateGrip.mjs +21 -15
- package/dist/jsx/views/GanttDateGrip.mjs.map +1 -1
- package/dist/jsx/views/GanttDateGrip.native.cjs +24 -14
- package/dist/jsx/views/GanttDateGrip.native.js +24 -14
- package/dist/jsx/views/GanttDateGrip.native.js.map +1 -1
- package/dist/jsx/views/GanttGripDot.mjs +24 -0
- package/dist/jsx/views/GanttGripDot.mjs.map +1 -0
- package/dist/jsx/views/GanttGripDot.native.cjs +46 -0
- package/dist/jsx/views/GanttGripDot.native.js +48 -0
- package/dist/jsx/views/GanttGripDot.native.js.map +1 -0
- package/dist/jsx/views/eventTint.mjs +196 -0
- package/dist/jsx/views/eventTint.mjs.map +1 -0
- package/dist/jsx/views/eventTint.native.cjs +346 -0
- package/dist/jsx/views/eventTint.native.js +348 -0
- package/dist/jsx/views/eventTint.native.js.map +1 -0
- package/package.json +7 -7
- package/src/MiddleEllipsisText/MiddleEllipsisText.native.spec.tsx +9 -0
- package/src/MiddleEllipsisText/index.native.tsx +1 -0
- package/src/Tabs/Tabs.measurement.spec.tsx +40 -1
- package/src/Tabs/index.tsx +3 -2
- package/src/hoverTouchPath.coarse.spec.tsx +28 -4
- package/src/layouts/timeline.replyInset.spec.tsx +72 -22
- package/src/layouts/timeline.tsx +0 -1
- package/src/views/Calendar.eventFill.spec.tsx +44 -9
- package/src/views/Calendar.tsx +23 -31
- package/src/views/Gantt.barInk.spec.tsx +257 -0
- package/src/views/Gantt.grips.spec.tsx +226 -0
- package/src/views/Gantt.tint.palette.spec.ts +288 -0
- package/src/views/Gantt.tsx +224 -65
- package/src/views/GanttDateGrip.native.spec.tsx +8 -0
- package/src/views/GanttDateGrip.tsx +28 -17
- package/src/views/GanttGripDot.tsx +36 -0
- package/src/views/dataIdentity.spec.tsx +29 -13
- package/src/views/eventTint.ts +305 -0
- package/types/MiddleEllipsisText/index.native.d.ts +1 -0
- package/types/MiddleEllipsisText/index.native.d.ts.map +1 -1
- package/types/Tabs/index.d.ts.map +1 -1
- package/types/layouts/timeline.d.ts.map +1 -1
- package/types/views/Calendar.d.ts.map +1 -1
- package/types/views/Gantt.d.ts.map +1 -1
- package/types/views/GanttDateGrip.d.ts +7 -0
- package/types/views/GanttDateGrip.d.ts.map +1 -1
- package/types/views/GanttGripDot.d.ts +9 -0
- package/types/views/GanttGripDot.d.ts.map +1 -0
- package/types/views/eventTint.d.ts +72 -0
- package/types/views/eventTint.d.ts.map +1 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import * as Colors from "@tamagui/colors";
|
|
2
|
+
import { aaTextContrastRatio, apcaContrast, contrastRatio, fillLabelLc, holdInkFloor, isDarkThemeName, normalizeToHex, relativeLuminance, resolveLegibleInkOn } from "@multiplatform.one/theme";
|
|
3
|
+
import { useThemeName } from "tamagui";
|
|
4
|
+
|
|
5
|
+
const EVENT_BAR_PX = 3;
|
|
6
|
+
const EVENT_GRIP_DOT_PX = 10;
|
|
7
|
+
const eventTints = {
|
|
8
|
+
light: {
|
|
9
|
+
rest: .22,
|
|
10
|
+
selected: .38,
|
|
11
|
+
ghost: .13
|
|
12
|
+
},
|
|
13
|
+
dark: {
|
|
14
|
+
rest: .4,
|
|
15
|
+
selected: .5,
|
|
16
|
+
ghost: .24
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const eventRampSteps = {
|
|
20
|
+
rest: 6,
|
|
21
|
+
selected: 7
|
|
22
|
+
};
|
|
23
|
+
const EVENT_GHOST_DARK = .6;
|
|
24
|
+
const EVENT_STRIP_STEP = 11;
|
|
25
|
+
const EVENT_STRIP_FLOOR = 3;
|
|
26
|
+
const contrast = (a, b) => contrastRatio(relativeLuminance(a), relativeLuminance(b));
|
|
27
|
+
function eventTintFor(themeName) {
|
|
28
|
+
return eventTints[isDarkThemeName(themeName) ? "dark" : "light"];
|
|
29
|
+
}
|
|
30
|
+
function useEventTint() {
|
|
31
|
+
return eventTintFor(useThemeName());
|
|
32
|
+
}
|
|
33
|
+
function useEventDark() {
|
|
34
|
+
return isDarkThemeName(useThemeName());
|
|
35
|
+
}
|
|
36
|
+
function themeValue(theme, color) {
|
|
37
|
+
const token = color.startsWith("$");
|
|
38
|
+
const val = theme[token ? color.slice(1) : color]?.val;
|
|
39
|
+
if (typeof val === "string") return val;
|
|
40
|
+
return token ? void 0 : color;
|
|
41
|
+
}
|
|
42
|
+
function blendOver(fill, surface, alpha) {
|
|
43
|
+
const top = normalizeToHex(fill);
|
|
44
|
+
const bottom = normalizeToHex(surface);
|
|
45
|
+
if (!top || !bottom) return null;
|
|
46
|
+
return `#${[
|
|
47
|
+
1,
|
|
48
|
+
3,
|
|
49
|
+
5
|
|
50
|
+
].map((offset) => {
|
|
51
|
+
const a = Number.parseInt(top.slice(offset, offset + 2), 16);
|
|
52
|
+
const b = Number.parseInt(bottom.slice(offset, offset + 2), 16);
|
|
53
|
+
return Math.round(b + (a - b) * alpha).toString(16).padStart(2, "0");
|
|
54
|
+
}).join("")}`;
|
|
55
|
+
}
|
|
56
|
+
const rampFamilies = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const [name, scale] of Object.entries(Colors)) {
|
|
58
|
+
if (/A$|P3/.test(name)) continue;
|
|
59
|
+
const family = name.replace(/Dark$/, "");
|
|
60
|
+
for (const value of Object.values(scale)) {
|
|
61
|
+
const hex = normalizeToHex(String(value));
|
|
62
|
+
if (hex && !rampFamilies.has(hex)) rampFamilies.set(hex, family);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function eventRamp(theme, fill, dark) {
|
|
66
|
+
if (/^\$?color-\d+$/.test(fill)) return (step) => themeValue(theme, `color-${step}`);
|
|
67
|
+
const value = themeValue(theme, fill);
|
|
68
|
+
const hex = value ? normalizeToHex(value) : null;
|
|
69
|
+
const family = hex ? rampFamilies.get(hex) : void 0;
|
|
70
|
+
const scale = family ? Colors[dark ? `${family}Dark` : family] : void 0;
|
|
71
|
+
return scale ? (step) => scale[`${family}${step}`] : null;
|
|
72
|
+
}
|
|
73
|
+
function eventPaint(theme, fill, state, { dark, surface = "background" }) {
|
|
74
|
+
const ground = themeValue(theme, surface);
|
|
75
|
+
if (dark) {
|
|
76
|
+
const step = eventRamp(theme, fill, true)?.(eventRampSteps[state === "ghost" ? "rest" : state]);
|
|
77
|
+
const hex = step ? normalizeToHex(step) : null;
|
|
78
|
+
if (hex && state !== "ghost") return hex;
|
|
79
|
+
const ghost = hex && ground ? blendOver(hex, ground, EVENT_GHOST_DARK) : null;
|
|
80
|
+
if (ghost) return ghost;
|
|
81
|
+
}
|
|
82
|
+
const value = themeValue(theme, fill);
|
|
83
|
+
if (!value || !ground) return null;
|
|
84
|
+
if (dark || state === "ghost") return blendOver(value, ground, eventTints[dark ? "dark" : "light"][state]);
|
|
85
|
+
const strip = eventRamp(theme, fill, false)?.(11);
|
|
86
|
+
const stripHex = strip ? normalizeToHex(strip) : null;
|
|
87
|
+
const clears = (paint) => paint !== null && (!stripHex || contrast(stripHex, paint) >= 3);
|
|
88
|
+
const { rest, selected } = eventTints.light;
|
|
89
|
+
const restPaint = blendOver(value, ground, rest);
|
|
90
|
+
if (clears(restPaint)) {
|
|
91
|
+
if (state === "rest") return restPaint;
|
|
92
|
+
for (let percent = Math.round(selected * 100); percent > Math.round(rest * 100); percent--) {
|
|
93
|
+
const paint = blendOver(value, ground, percent / 100);
|
|
94
|
+
if (clears(paint)) return paint;
|
|
95
|
+
}
|
|
96
|
+
return restPaint;
|
|
97
|
+
}
|
|
98
|
+
const lightened = lightenedRest(value, ground, clears);
|
|
99
|
+
return lightened ? lightened[state] : restPaint;
|
|
100
|
+
}
|
|
101
|
+
const EVENT_REST_STANDOFF = 1.2;
|
|
102
|
+
function lightenedRest(value, ground, clears) {
|
|
103
|
+
const canvas = normalizeToHex(ground);
|
|
104
|
+
if (!canvas) return null;
|
|
105
|
+
for (let percent = Math.round(eventTints.light.rest * 100) - 1; percent > 1; percent--) {
|
|
106
|
+
const selected = blendOver(value, ground, percent / 100);
|
|
107
|
+
if (!clears(selected)) continue;
|
|
108
|
+
const rest = blendOver(value, ground, (percent - 1) / 100);
|
|
109
|
+
if (!rest || contrast(rest, canvas) < 1.2) return null;
|
|
110
|
+
return {
|
|
111
|
+
rest,
|
|
112
|
+
selected
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const labelHolds = (label, fill) => contrast(label, fill) >= aaTextContrastRatio && Math.abs(apcaContrast(label, fill)) >= fillLabelLc;
|
|
118
|
+
const EVENT_SOLID_SELECTED = .1;
|
|
119
|
+
function eventSolid(theme, fill, state) {
|
|
120
|
+
const [paper, anchor] = ["color-1", "color-12"].map((token) => {
|
|
121
|
+
const value2 = themeValue(theme, token);
|
|
122
|
+
return value2 ? normalizeToHex(value2) : null;
|
|
123
|
+
});
|
|
124
|
+
const value = themeValue(theme, fill);
|
|
125
|
+
const solid = value ? normalizeToHex(value) : null;
|
|
126
|
+
if (!paper || !anchor || !solid) return null;
|
|
127
|
+
const hueInk = eventRamp(theme, fill, false)?.(12);
|
|
128
|
+
const dark = hueInk && normalizeToHex(hueInk) || anchor;
|
|
129
|
+
const ink = Math.abs(apcaContrast(paper, solid)) >= Math.abs(apcaContrast(dark, solid)) ? paper : dark;
|
|
130
|
+
const far = ink === paper ? anchor : paper;
|
|
131
|
+
const rest = Array.from({ length: 13 }, (_, step) => blendOver(far, solid, step / 20)).find((paint) => paint !== null && labelHolds(ink, paint));
|
|
132
|
+
if (!rest) return {
|
|
133
|
+
paint: solid,
|
|
134
|
+
ink: normalizeToHex(holdInkFloor(solid, ink)) ?? ink
|
|
135
|
+
};
|
|
136
|
+
if (state === "rest") return {
|
|
137
|
+
paint: rest,
|
|
138
|
+
ink
|
|
139
|
+
};
|
|
140
|
+
const selected = [anchor, paper].map((toward) => blendOver(toward, rest, EVENT_SOLID_SELECTED)).find((paint) => paint !== null && labelHolds(ink, paint));
|
|
141
|
+
return {
|
|
142
|
+
paint: selected ?? rest,
|
|
143
|
+
ink
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function eventStripPaint(theme, fill, { dark, surface }) {
|
|
147
|
+
const step = eventRamp(theme, fill, dark)?.(11);
|
|
148
|
+
const hex = step ? normalizeToHex(step) : null;
|
|
149
|
+
if (hex) return hex;
|
|
150
|
+
const value = themeValue(theme, fill);
|
|
151
|
+
const solid = value ? normalizeToHex(value) : null;
|
|
152
|
+
if (!solid) return null;
|
|
153
|
+
const ink = themeValue(theme, "color-12");
|
|
154
|
+
const paints = ["rest", "selected"].map((state) => eventPaint(theme, fill, state, {
|
|
155
|
+
dark,
|
|
156
|
+
surface
|
|
157
|
+
})).filter((paint) => paint !== null);
|
|
158
|
+
const candidates = [solid, ...ink ? [.35, .6].map((mix) => blendOver(solid, ink, mix)) : []].filter((candidate) => candidate !== null);
|
|
159
|
+
return candidates.find((candidate) => paints.every((paint) => contrast(candidate, paint) >= 3)) ?? candidates.at(-1) ?? null;
|
|
160
|
+
}
|
|
161
|
+
function eventInk(theme, grounds, preferred = "color-12") {
|
|
162
|
+
const preferredValue = themeValue(theme, preferred);
|
|
163
|
+
if (!preferredValue) return preferred;
|
|
164
|
+
const paper = themeValue(theme, "color-1");
|
|
165
|
+
const ink = themeValue(theme, "color-12");
|
|
166
|
+
let replacement;
|
|
167
|
+
for (const ground of grounds) {
|
|
168
|
+
if (!ground) continue;
|
|
169
|
+
const resolved = resolveLegibleInkOn({
|
|
170
|
+
fill: ground,
|
|
171
|
+
preferred: preferredValue,
|
|
172
|
+
paper,
|
|
173
|
+
ink
|
|
174
|
+
});
|
|
175
|
+
if (resolved && resolved !== preferredValue) replacement = resolved;
|
|
176
|
+
}
|
|
177
|
+
return replacement ?? preferred;
|
|
178
|
+
}
|
|
179
|
+
function eventLabelInk(theme, fill, grounds, dark, tone = "primary") {
|
|
180
|
+
const ramp = eventRamp(theme, fill, dark);
|
|
181
|
+
const [dim, full] = [11, 12].map((step) => {
|
|
182
|
+
const value = ramp?.(step);
|
|
183
|
+
return value ? normalizeToHex(value) : null;
|
|
184
|
+
});
|
|
185
|
+
const grounded = grounds.map((ground) => ground ? normalizeToHex(ground) : null).filter((hex) => hex !== null);
|
|
186
|
+
const reads = (ink) => grounded.every((ground) => contrast(ink, ground) >= aaTextContrastRatio);
|
|
187
|
+
if (full && tone === "secondary" && dim) for (let percent = 0; percent < 100; percent++) {
|
|
188
|
+
const ink = blendOver(full, dim, percent / 100);
|
|
189
|
+
if (ink && reads(ink)) return ink;
|
|
190
|
+
}
|
|
191
|
+
if (full && reads(full)) return full;
|
|
192
|
+
return eventInk(theme, grounds, full ?? (tone === "secondary" ? "color-11" : "color-12"));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export { EVENT_BAR_PX, EVENT_GHOST_DARK, EVENT_GRIP_DOT_PX, EVENT_REST_STANDOFF, EVENT_SOLID_SELECTED, EVENT_STRIP_FLOOR, EVENT_STRIP_STEP, blendOver, eventInk, eventLabelInk, eventPaint, eventRamp, eventRampSteps, eventSolid, eventStripPaint, eventTintFor, eventTints, themeValue, useEventDark, useEventTint };
|
|
196
|
+
//# sourceMappingURL=eventTint.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventTint.js","names":[],"sources":["jsx/views/eventTint.js"],"sourcesContent":["import * as Colors from \"@tamagui/colors\";\nimport {\n aaTextContrastRatio,\n apcaContrast,\n contrastRatio,\n fillLabelLc,\n holdInkFloor,\n isDarkThemeName,\n normalizeToHex,\n relativeLuminance,\n resolveLegibleInkOn\n} from \"@multiplatform.one/theme\";\nimport { useThemeName } from \"tamagui\";\nconst EVENT_BAR_PX = 3;\nconst EVENT_GRIP_DOT_PX = 10;\nconst eventTints = {\n light: { rest: 0.22, selected: 0.38, ghost: 0.13 },\n dark: { rest: 0.4, selected: 0.5, ghost: 0.24 }\n};\nconst eventRampSteps = {\n rest: 6,\n selected: 7\n};\nconst EVENT_GHOST_DARK = 0.6;\nconst EVENT_STRIP_STEP = 11;\nconst EVENT_STRIP_FLOOR = 3;\nconst contrast = (a, b) => contrastRatio(relativeLuminance(a), relativeLuminance(b));\nfunction eventTintFor(themeName) {\n return eventTints[isDarkThemeName(themeName) ? \"dark\" : \"light\"];\n}\nfunction useEventTint() {\n return eventTintFor(useThemeName());\n}\nfunction useEventDark() {\n return isDarkThemeName(useThemeName());\n}\nfunction themeValue(theme, color) {\n const token = color.startsWith(\"$\");\n const val = theme[token ? color.slice(1) : color]?.val;\n if (typeof val === \"string\") return val;\n return token ? void 0 : color;\n}\nfunction blendOver(fill, surface, alpha) {\n const top = normalizeToHex(fill);\n const bottom = normalizeToHex(surface);\n if (!top || !bottom) return null;\n return `#${[1, 3, 5].map((offset) => {\n const a = Number.parseInt(top.slice(offset, offset + 2), 16);\n const b = Number.parseInt(bottom.slice(offset, offset + 2), 16);\n return Math.round(b + (a - b) * alpha).toString(16).padStart(2, \"0\");\n }).join(\"\")}`;\n}\nconst rampFamilies = /* @__PURE__ */ new Map();\nfor (const [name, scale] of Object.entries(Colors)) {\n if (/A$|P3/.test(name)) continue;\n const family = name.replace(/Dark$/, \"\");\n for (const value of Object.values(scale)) {\n const hex = normalizeToHex(String(value));\n if (hex && !rampFamilies.has(hex)) rampFamilies.set(hex, family);\n }\n}\nfunction eventRamp(theme, fill, dark) {\n if (/^\\$?color-\\d+$/.test(fill)) return (step) => themeValue(theme, `color-${step}`);\n const value = themeValue(theme, fill);\n const hex = value ? normalizeToHex(value) : null;\n const family = hex ? rampFamilies.get(hex) : void 0;\n const scale = family ? Colors[dark ? `${family}Dark` : family] : void 0;\n return scale ? (step) => scale[`${family}${step}`] : null;\n}\nfunction eventPaint(theme, fill, state, { dark, surface = \"background\" }) {\n const ground = themeValue(theme, surface);\n if (dark) {\n const step = eventRamp(theme, fill, true)?.(eventRampSteps[state === \"ghost\" ? \"rest\" : state]);\n const hex = step ? normalizeToHex(step) : null;\n if (hex && state !== \"ghost\") return hex;\n const ghost = hex && ground ? blendOver(hex, ground, EVENT_GHOST_DARK) : null;\n if (ghost) return ghost;\n }\n const value = themeValue(theme, fill);\n if (!value || !ground) return null;\n if (dark || state === \"ghost\")\n return blendOver(value, ground, eventTints[dark ? \"dark\" : \"light\"][state]);\n const strip = eventRamp(theme, fill, false)?.(EVENT_STRIP_STEP);\n const stripHex = strip ? normalizeToHex(strip) : null;\n const clears = (paint) => paint !== null && (!stripHex || contrast(stripHex, paint) >= EVENT_STRIP_FLOOR);\n const { rest, selected } = eventTints.light;\n const restPaint = blendOver(value, ground, rest);\n if (clears(restPaint)) {\n if (state === \"rest\") return restPaint;\n for (let percent = Math.round(selected * 100); percent > Math.round(rest * 100); percent--) {\n const paint = blendOver(value, ground, percent / 100);\n if (clears(paint)) return paint;\n }\n return restPaint;\n }\n const lightened = lightenedRest(value, ground, clears);\n return lightened ? lightened[state] : restPaint;\n}\nconst EVENT_REST_STANDOFF = 1.2;\nfunction lightenedRest(value, ground, clears) {\n const canvas = normalizeToHex(ground);\n if (!canvas) return null;\n for (let percent = Math.round(eventTints.light.rest * 100) - 1; percent > 1; percent--) {\n const selected = blendOver(value, ground, percent / 100);\n if (!clears(selected)) continue;\n const rest = blendOver(value, ground, (percent - 1) / 100);\n if (!rest || contrast(rest, canvas) < EVENT_REST_STANDOFF) return null;\n return { rest, selected };\n }\n return null;\n}\nconst labelHolds = (label, fill) => contrast(label, fill) >= aaTextContrastRatio && Math.abs(apcaContrast(label, fill)) >= fillLabelLc;\nconst EVENT_SOLID_SELECTED = 0.1;\nfunction eventSolid(theme, fill, state) {\n const [paper, anchor] = [\"color-1\", \"color-12\"].map((token) => {\n const value2 = themeValue(theme, token);\n return value2 ? normalizeToHex(value2) : null;\n });\n const value = themeValue(theme, fill);\n const solid = value ? normalizeToHex(value) : null;\n if (!paper || !anchor || !solid) return null;\n const hueInk = eventRamp(theme, fill, false)?.(12);\n const dark = hueInk && normalizeToHex(hueInk) || anchor;\n const ink = Math.abs(apcaContrast(paper, solid)) >= Math.abs(apcaContrast(dark, solid)) ? paper : dark;\n const far = ink === paper ? anchor : paper;\n const rest = Array.from({ length: 13 }, (_, step) => blendOver(far, solid, step / 20)).find(\n (paint) => paint !== null && labelHolds(ink, paint)\n );\n if (!rest) return { paint: solid, ink: normalizeToHex(holdInkFloor(solid, ink)) ?? ink };\n if (state === \"rest\") return { paint: rest, ink };\n const selected = [anchor, paper].map((toward) => blendOver(toward, rest, EVENT_SOLID_SELECTED)).find((paint) => paint !== null && labelHolds(ink, paint));\n return { paint: selected ?? rest, ink };\n}\nfunction eventStripPaint(theme, fill, { dark, surface }) {\n const step = eventRamp(theme, fill, dark)?.(EVENT_STRIP_STEP);\n const hex = step ? normalizeToHex(step) : null;\n if (hex) return hex;\n const value = themeValue(theme, fill);\n const solid = value ? normalizeToHex(value) : null;\n if (!solid) return null;\n const ink = themeValue(theme, \"color-12\");\n const paints = [\"rest\", \"selected\"].map((state) => eventPaint(theme, fill, state, { dark, surface })).filter((paint) => paint !== null);\n const candidates = [\n solid,\n ...ink ? [0.35, 0.6].map((mix) => blendOver(solid, ink, mix)) : []\n ].filter((candidate) => candidate !== null);\n return candidates.find(\n (candidate) => paints.every((paint) => contrast(candidate, paint) >= EVENT_STRIP_FLOOR)\n ) ?? candidates.at(-1) ?? null;\n}\nfunction eventInk(theme, grounds, preferred = \"color-12\") {\n const preferredValue = themeValue(theme, preferred);\n if (!preferredValue) return preferred;\n const paper = themeValue(theme, \"color-1\");\n const ink = themeValue(theme, \"color-12\");\n let replacement;\n for (const ground of grounds) {\n if (!ground) continue;\n const resolved = resolveLegibleInkOn({ fill: ground, preferred: preferredValue, paper, ink });\n if (resolved && resolved !== preferredValue) replacement = resolved;\n }\n return replacement ?? preferred;\n}\nfunction eventLabelInk(theme, fill, grounds, dark, tone = \"primary\") {\n const ramp = eventRamp(theme, fill, dark);\n const [dim, full] = [11, 12].map((step) => {\n const value = ramp?.(step);\n return value ? normalizeToHex(value) : null;\n });\n const grounded = grounds.map((ground) => ground ? normalizeToHex(ground) : null).filter((hex) => hex !== null);\n const reads = (ink) => grounded.every((ground) => contrast(ink, ground) >= aaTextContrastRatio);\n if (full && tone === \"secondary\" && dim)\n for (let percent = 0; percent < 100; percent++) {\n const ink = blendOver(full, dim, percent / 100);\n if (ink && reads(ink)) return ink;\n }\n if (full && reads(full)) return full;\n return eventInk(theme, grounds, full ?? (tone === \"secondary\" ? \"color-11\" : \"color-12\"));\n}\nexport {\n EVENT_BAR_PX,\n EVENT_GHOST_DARK,\n EVENT_GRIP_DOT_PX,\n EVENT_REST_STANDOFF,\n EVENT_SOLID_SELECTED,\n EVENT_STRIP_FLOOR,\n EVENT_STRIP_STEP,\n blendOver,\n eventInk,\n eventLabelInk,\n eventPaint,\n eventRamp,\n eventRampSteps,\n eventSolid,\n eventStripPaint,\n eventTintFor,\n eventTints,\n themeValue,\n useEventDark,\n useEventTint\n};\n//# sourceMappingURL=eventTint.js.map\n"],"mappings":";;;;;AAaA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,aAAa;CACjB,OAAO;EAAE,MAAM;EAAM,UAAU;EAAM,OAAO;CAAK;CACjD,MAAM;EAAE,MAAM;EAAK,UAAU;EAAK,OAAO;CAAK;AAChD;AACA,MAAM,iBAAiB;CACrB,MAAM;CACN,UA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AAW,SAAS,KAAK,MAAM,KAAK,mBAAmB;CAC9F,IAAI,QAAQ,SAAS,eAAe,KAClC,KAAK,IAAI,UAAU,GAAG,UAAU,KAAK,WAAW;EAC9C,MAAM,MAAM,UAAU,MAAM,KAAK,UAAU,GAAG;EAC9C,IAAI,OAAO,MAAM,GAAG,GAAG,OAAO;CAChC;CACF,IAAI,QAAQ,MAAM,IAAI,GAAG,OAAO;CAChC,OAAO,SAAS,OAAO,SAAS,SAAS,SAAS,cAAc,aAAa,WAAW;AAC1F"}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name2 in all) __defProp(target, name2, {
|
|
11
|
+
get: all[name2],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var eventTint_exports = {};
|
|
30
|
+
__export(eventTint_exports, {
|
|
31
|
+
EVENT_BAR_PX: () => EVENT_BAR_PX,
|
|
32
|
+
EVENT_GHOST_DARK: () => EVENT_GHOST_DARK,
|
|
33
|
+
EVENT_GRIP_DOT_PX: () => EVENT_GRIP_DOT_PX,
|
|
34
|
+
EVENT_REST_STANDOFF: () => EVENT_REST_STANDOFF,
|
|
35
|
+
EVENT_SOLID_SELECTED: () => EVENT_SOLID_SELECTED,
|
|
36
|
+
EVENT_STRIP_FLOOR: () => EVENT_STRIP_FLOOR,
|
|
37
|
+
EVENT_STRIP_STEP: () => EVENT_STRIP_STEP,
|
|
38
|
+
blendOver: () => blendOver,
|
|
39
|
+
eventInk: () => eventInk,
|
|
40
|
+
eventLabelInk: () => eventLabelInk,
|
|
41
|
+
eventPaint: () => eventPaint,
|
|
42
|
+
eventRamp: () => eventRamp,
|
|
43
|
+
eventRampSteps: () => eventRampSteps,
|
|
44
|
+
eventSolid: () => eventSolid,
|
|
45
|
+
eventStripPaint: () => eventStripPaint,
|
|
46
|
+
eventTintFor: () => eventTintFor,
|
|
47
|
+
eventTints: () => eventTints,
|
|
48
|
+
themeValue: () => themeValue,
|
|
49
|
+
useEventDark: () => useEventDark,
|
|
50
|
+
useEventTint: () => useEventTint
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(eventTint_exports);
|
|
53
|
+
var Colors = __toESM(require("@tamagui/colors"));
|
|
54
|
+
var import_theme = require("@multiplatform.one/theme");
|
|
55
|
+
var import_tamagui = require("tamagui");
|
|
56
|
+
var EVENT_BAR_PX = 3;
|
|
57
|
+
var EVENT_GRIP_DOT_PX = 10;
|
|
58
|
+
var eventTints = {
|
|
59
|
+
light: {
|
|
60
|
+
rest: .22,
|
|
61
|
+
selected: .38,
|
|
62
|
+
ghost: .13
|
|
63
|
+
},
|
|
64
|
+
dark: {
|
|
65
|
+
rest: .4,
|
|
66
|
+
selected: .5,
|
|
67
|
+
ghost: .24
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var eventRampSteps = {
|
|
71
|
+
rest: 6,
|
|
72
|
+
selected: 7
|
|
73
|
+
};
|
|
74
|
+
var EVENT_GHOST_DARK = .6;
|
|
75
|
+
var EVENT_STRIP_STEP = 11;
|
|
76
|
+
var EVENT_STRIP_FLOOR = 3;
|
|
77
|
+
var contrast = function contrast2(a, b) {
|
|
78
|
+
return (0, import_theme.contrastRatio)((0, import_theme.relativeLuminance)(a), (0, import_theme.relativeLuminance)(b));
|
|
79
|
+
};
|
|
80
|
+
function eventTintFor(themeName) {
|
|
81
|
+
return eventTints[(0, import_theme.isDarkThemeName)(themeName) ? "dark" : "light"];
|
|
82
|
+
}
|
|
83
|
+
function useEventTint() {
|
|
84
|
+
return eventTintFor((0, import_tamagui.useThemeName)());
|
|
85
|
+
}
|
|
86
|
+
function useEventDark() {
|
|
87
|
+
return (0, import_theme.isDarkThemeName)((0, import_tamagui.useThemeName)());
|
|
88
|
+
}
|
|
89
|
+
function themeValue(theme, color) {
|
|
90
|
+
var _theme_;
|
|
91
|
+
var token = color.startsWith("$");
|
|
92
|
+
var val = (_theme_ = theme[token ? color.slice(1) : color]) === null || _theme_ === void 0 ? void 0 : _theme_.val;
|
|
93
|
+
if (typeof val === "string") return val;
|
|
94
|
+
return token ? void 0 : color;
|
|
95
|
+
}
|
|
96
|
+
function blendOver(fill, surface, alpha) {
|
|
97
|
+
var top = (0, import_theme.normalizeToHex)(fill);
|
|
98
|
+
var bottom = (0, import_theme.normalizeToHex)(surface);
|
|
99
|
+
if (!top || !bottom) return null;
|
|
100
|
+
return `#${[
|
|
101
|
+
1,
|
|
102
|
+
3,
|
|
103
|
+
5
|
|
104
|
+
].map(function(offset) {
|
|
105
|
+
var a = Number.parseInt(top.slice(offset, offset + 2), 16);
|
|
106
|
+
var b = Number.parseInt(bottom.slice(offset, offset + 2), 16);
|
|
107
|
+
return Math.round(b + (a - b) * alpha).toString(16).padStart(2, "0");
|
|
108
|
+
}).join("")}`;
|
|
109
|
+
}
|
|
110
|
+
var rampFamilies = /* @__PURE__ */ new Map();
|
|
111
|
+
var _iteratorNormalCompletion = true;
|
|
112
|
+
var _didIteratorError = false;
|
|
113
|
+
var _iteratorError = void 0;
|
|
114
|
+
try {
|
|
115
|
+
for (var _iterator = Object.entries(Colors)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
116
|
+
var [name, scale] = _step.value;
|
|
117
|
+
if (/A$|P3/.test(name)) continue;
|
|
118
|
+
var family = name.replace(/Dark$/, "");
|
|
119
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
120
|
+
try {
|
|
121
|
+
for (var _iterator1 = Object.values(scale)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
122
|
+
var value = _step1.value;
|
|
123
|
+
var hex = (0, import_theme.normalizeToHex)(String(value));
|
|
124
|
+
if (hex && !rampFamilies.has(hex)) rampFamilies.set(hex, family);
|
|
125
|
+
}
|
|
126
|
+
} catch (err) {
|
|
127
|
+
_didIteratorError1 = true;
|
|
128
|
+
_iteratorError1 = err;
|
|
129
|
+
} finally {
|
|
130
|
+
try {
|
|
131
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
132
|
+
_iterator1.return();
|
|
133
|
+
}
|
|
134
|
+
} finally {
|
|
135
|
+
if (_didIteratorError1) {
|
|
136
|
+
throw _iteratorError1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
_didIteratorError = true;
|
|
143
|
+
_iteratorError = err;
|
|
144
|
+
} finally {
|
|
145
|
+
try {
|
|
146
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
147
|
+
_iterator.return();
|
|
148
|
+
}
|
|
149
|
+
} finally {
|
|
150
|
+
if (_didIteratorError) {
|
|
151
|
+
throw _iteratorError;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function eventRamp(theme, fill, dark) {
|
|
156
|
+
if (/^\$?color-\d+$/.test(fill)) return function(step) {
|
|
157
|
+
return themeValue(theme, `color-${step}`);
|
|
158
|
+
};
|
|
159
|
+
var value2 = themeValue(theme, fill);
|
|
160
|
+
var hex2 = value2 ? (0, import_theme.normalizeToHex)(value2) : null;
|
|
161
|
+
var family2 = hex2 ? rampFamilies.get(hex2) : void 0;
|
|
162
|
+
var scale2 = family2 ? Colors[dark ? `${family2}Dark` : family2] : void 0;
|
|
163
|
+
return scale2 ? function(step) {
|
|
164
|
+
return scale2[`${family2}${step}`];
|
|
165
|
+
} : null;
|
|
166
|
+
}
|
|
167
|
+
function eventPaint(theme, fill, state, param) {
|
|
168
|
+
var { dark, surface = "background" } = param;
|
|
169
|
+
var _eventRamp;
|
|
170
|
+
var ground = themeValue(theme, surface);
|
|
171
|
+
if (dark) {
|
|
172
|
+
var _eventRamp1;
|
|
173
|
+
var step = (_eventRamp1 = eventRamp(theme, fill, true)) === null || _eventRamp1 === void 0 ? void 0 : _eventRamp1(eventRampSteps[state === "ghost" ? "rest" : state]);
|
|
174
|
+
var hex2 = step ? (0, import_theme.normalizeToHex)(step) : null;
|
|
175
|
+
if (hex2 && state !== "ghost") return hex2;
|
|
176
|
+
var ghost = hex2 && ground ? blendOver(hex2, ground, EVENT_GHOST_DARK) : null;
|
|
177
|
+
if (ghost) return ghost;
|
|
178
|
+
}
|
|
179
|
+
var value2 = themeValue(theme, fill);
|
|
180
|
+
if (!value2 || !ground) return null;
|
|
181
|
+
if (dark || state === "ghost") return blendOver(value2, ground, eventTints[dark ? "dark" : "light"][state]);
|
|
182
|
+
var strip = (_eventRamp = eventRamp(theme, fill, false)) === null || _eventRamp === void 0 ? void 0 : _eventRamp(EVENT_STRIP_STEP);
|
|
183
|
+
var stripHex = strip ? (0, import_theme.normalizeToHex)(strip) : null;
|
|
184
|
+
var clears = function clears2(paint2) {
|
|
185
|
+
return paint2 !== null && (!stripHex || contrast(stripHex, paint2) >= EVENT_STRIP_FLOOR);
|
|
186
|
+
};
|
|
187
|
+
var { rest, selected } = eventTints.light;
|
|
188
|
+
var restPaint = blendOver(value2, ground, rest);
|
|
189
|
+
if (clears(restPaint)) {
|
|
190
|
+
if (state === "rest") return restPaint;
|
|
191
|
+
for (var percent = Math.round(selected * 100); percent > Math.round(rest * 100); percent--) {
|
|
192
|
+
var paint = blendOver(value2, ground, percent / 100);
|
|
193
|
+
if (clears(paint)) return paint;
|
|
194
|
+
}
|
|
195
|
+
return restPaint;
|
|
196
|
+
}
|
|
197
|
+
var lightened = lightenedRest(value2, ground, clears);
|
|
198
|
+
return lightened ? lightened[state] : restPaint;
|
|
199
|
+
}
|
|
200
|
+
var EVENT_REST_STANDOFF = 1.2;
|
|
201
|
+
function lightenedRest(value2, ground, clears) {
|
|
202
|
+
var canvas = (0, import_theme.normalizeToHex)(ground);
|
|
203
|
+
if (!canvas) return null;
|
|
204
|
+
for (var percent = Math.round(eventTints.light.rest * 100) - 1; percent > 1; percent--) {
|
|
205
|
+
var selected = blendOver(value2, ground, percent / 100);
|
|
206
|
+
if (!clears(selected)) continue;
|
|
207
|
+
var rest = blendOver(value2, ground, (percent - 1) / 100);
|
|
208
|
+
if (!rest || contrast(rest, canvas) < EVENT_REST_STANDOFF) return null;
|
|
209
|
+
return {
|
|
210
|
+
rest,
|
|
211
|
+
selected
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
var labelHolds = function labelHolds2(label, fill) {
|
|
217
|
+
return contrast(label, fill) >= import_theme.aaTextContrastRatio && Math.abs((0, import_theme.apcaContrast)(label, fill)) >= import_theme.fillLabelLc;
|
|
218
|
+
};
|
|
219
|
+
var EVENT_SOLID_SELECTED = .1;
|
|
220
|
+
function eventSolid(theme, fill, state) {
|
|
221
|
+
var _normalizeToHex;
|
|
222
|
+
var _eventRamp;
|
|
223
|
+
var [paper, anchor] = ["color-1", "color-12"].map(function(token) {
|
|
224
|
+
var value3 = themeValue(theme, token);
|
|
225
|
+
return value3 ? (0, import_theme.normalizeToHex)(value3) : null;
|
|
226
|
+
});
|
|
227
|
+
var value2 = themeValue(theme, fill);
|
|
228
|
+
var solid = value2 ? (0, import_theme.normalizeToHex)(value2) : null;
|
|
229
|
+
if (!paper || !anchor || !solid) return null;
|
|
230
|
+
var hueInk = (_eventRamp = eventRamp(theme, fill, false)) === null || _eventRamp === void 0 ? void 0 : _eventRamp(12);
|
|
231
|
+
var dark = hueInk && (0, import_theme.normalizeToHex)(hueInk) || anchor;
|
|
232
|
+
var ink = Math.abs((0, import_theme.apcaContrast)(paper, solid)) >= Math.abs((0, import_theme.apcaContrast)(dark, solid)) ? paper : dark;
|
|
233
|
+
var far = ink === paper ? anchor : paper;
|
|
234
|
+
var rest = Array.from({ length: 13 }, function(_, step) {
|
|
235
|
+
return blendOver(far, solid, step / 20);
|
|
236
|
+
}).find(function(paint) {
|
|
237
|
+
return paint !== null && labelHolds(ink, paint);
|
|
238
|
+
});
|
|
239
|
+
if (!rest) return {
|
|
240
|
+
paint: solid,
|
|
241
|
+
ink: (_normalizeToHex = (0, import_theme.normalizeToHex)((0, import_theme.holdInkFloor)(solid, ink))) !== null && _normalizeToHex !== void 0 ? _normalizeToHex : ink
|
|
242
|
+
};
|
|
243
|
+
if (state === "rest") return {
|
|
244
|
+
paint: rest,
|
|
245
|
+
ink
|
|
246
|
+
};
|
|
247
|
+
var selected = [anchor, paper].map(function(toward) {
|
|
248
|
+
return blendOver(toward, rest, EVENT_SOLID_SELECTED);
|
|
249
|
+
}).find(function(paint) {
|
|
250
|
+
return paint !== null && labelHolds(ink, paint);
|
|
251
|
+
});
|
|
252
|
+
return {
|
|
253
|
+
paint: selected !== null && selected !== void 0 ? selected : rest,
|
|
254
|
+
ink
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function eventStripPaint(theme, fill, param) {
|
|
258
|
+
var { dark, surface } = param;
|
|
259
|
+
var _ref, _candidates_find;
|
|
260
|
+
var _eventRamp;
|
|
261
|
+
var step = (_eventRamp = eventRamp(theme, fill, dark)) === null || _eventRamp === void 0 ? void 0 : _eventRamp(EVENT_STRIP_STEP);
|
|
262
|
+
var hex2 = step ? (0, import_theme.normalizeToHex)(step) : null;
|
|
263
|
+
if (hex2) return hex2;
|
|
264
|
+
var value2 = themeValue(theme, fill);
|
|
265
|
+
var solid = value2 ? (0, import_theme.normalizeToHex)(value2) : null;
|
|
266
|
+
if (!solid) return null;
|
|
267
|
+
var ink = themeValue(theme, "color-12");
|
|
268
|
+
var paints = ["rest", "selected"].map(function(state) {
|
|
269
|
+
return eventPaint(theme, fill, state, {
|
|
270
|
+
dark,
|
|
271
|
+
surface
|
|
272
|
+
});
|
|
273
|
+
}).filter(function(paint) {
|
|
274
|
+
return paint !== null;
|
|
275
|
+
});
|
|
276
|
+
var candidates = [solid, ...ink ? [.35, .6].map(function(mix) {
|
|
277
|
+
return blendOver(solid, ink, mix);
|
|
278
|
+
}) : []].filter(function(candidate) {
|
|
279
|
+
return candidate !== null;
|
|
280
|
+
});
|
|
281
|
+
return (_ref = (_candidates_find = candidates.find(function(candidate) {
|
|
282
|
+
return paints.every(function(paint) {
|
|
283
|
+
return contrast(candidate, paint) >= EVENT_STRIP_FLOOR;
|
|
284
|
+
});
|
|
285
|
+
})) !== null && _candidates_find !== void 0 ? _candidates_find : candidates.at(-1)) !== null && _ref !== void 0 ? _ref : null;
|
|
286
|
+
}
|
|
287
|
+
function eventInk(theme, grounds) {
|
|
288
|
+
var preferred = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "color-12";
|
|
289
|
+
var preferredValue = themeValue(theme, preferred);
|
|
290
|
+
if (!preferredValue) return preferred;
|
|
291
|
+
var paper = themeValue(theme, "color-1");
|
|
292
|
+
var ink = themeValue(theme, "color-12");
|
|
293
|
+
var replacement;
|
|
294
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
295
|
+
try {
|
|
296
|
+
for (var _iterator2 = grounds[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
297
|
+
var ground = _step2.value;
|
|
298
|
+
if (!ground) continue;
|
|
299
|
+
var resolved = (0, import_theme.resolveLegibleInkOn)({
|
|
300
|
+
fill: ground,
|
|
301
|
+
preferred: preferredValue,
|
|
302
|
+
paper,
|
|
303
|
+
ink
|
|
304
|
+
});
|
|
305
|
+
if (resolved && resolved !== preferredValue) replacement = resolved;
|
|
306
|
+
}
|
|
307
|
+
} catch (err) {
|
|
308
|
+
_didIteratorError2 = true;
|
|
309
|
+
_iteratorError2 = err;
|
|
310
|
+
} finally {
|
|
311
|
+
try {
|
|
312
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
313
|
+
_iterator2.return();
|
|
314
|
+
}
|
|
315
|
+
} finally {
|
|
316
|
+
if (_didIteratorError2) {
|
|
317
|
+
throw _iteratorError2;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return replacement !== null && replacement !== void 0 ? replacement : preferred;
|
|
322
|
+
}
|
|
323
|
+
function eventLabelInk(theme, fill, grounds, dark) {
|
|
324
|
+
var tone = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : "primary";
|
|
325
|
+
var ramp = eventRamp(theme, fill, dark);
|
|
326
|
+
var [dim, full] = [11, 12].map(function(step) {
|
|
327
|
+
var value2 = ramp === null || ramp === void 0 ? void 0 : ramp(step);
|
|
328
|
+
return value2 ? (0, import_theme.normalizeToHex)(value2) : null;
|
|
329
|
+
});
|
|
330
|
+
var grounded = grounds.map(function(ground) {
|
|
331
|
+
return ground ? (0, import_theme.normalizeToHex)(ground) : null;
|
|
332
|
+
}).filter(function(hex2) {
|
|
333
|
+
return hex2 !== null;
|
|
334
|
+
});
|
|
335
|
+
var reads = function reads2(ink2) {
|
|
336
|
+
return grounded.every(function(ground) {
|
|
337
|
+
return contrast(ink2, ground) >= import_theme.aaTextContrastRatio;
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
if (full && tone === "secondary" && dim) for (var percent = 0; percent < 100; percent++) {
|
|
341
|
+
var ink = blendOver(full, dim, percent / 100);
|
|
342
|
+
if (ink && reads(ink)) return ink;
|
|
343
|
+
}
|
|
344
|
+
if (full && reads(full)) return full;
|
|
345
|
+
return eventInk(theme, grounds, full !== null && full !== void 0 ? full : tone === "secondary" ? "color-11" : "color-12");
|
|
346
|
+
}
|