@charcoal-ui/utils 5.0.0-beta.2 → 5.0.0-beta.4
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/index.cjs +230 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +128 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +118 -60
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +191 -0
- package/dist/index.js.map +1 -0
- package/package.json +15 -19
- package/src/index.ts +17 -17
- package/dist/index.cjs.js +0 -217
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -167
- package/dist/index.esm.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let polished = require("polished");
|
|
25
|
+
polished = __toESM(polished);
|
|
26
|
+
|
|
27
|
+
//#region src/index.ts
|
|
28
|
+
const GRADIENT_DIRECTIONS = [
|
|
29
|
+
"to top",
|
|
30
|
+
"to bottom",
|
|
31
|
+
"to left",
|
|
32
|
+
"to right"
|
|
33
|
+
];
|
|
34
|
+
function transparentGradient(color, defaultDirection = "to bottom") {
|
|
35
|
+
return function transparentGradient$1(direction = defaultDirection) {
|
|
36
|
+
const transparent = (0, polished.rgba)(color, 0);
|
|
37
|
+
return (0, polished.linearGradient)({
|
|
38
|
+
colorStops: [color, transparent],
|
|
39
|
+
fallback: transparent,
|
|
40
|
+
toDirection: typeof direction === "object" ? defaultDirection : direction
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function gradient(toDirection = "to bottom") {
|
|
45
|
+
return function toLinearGradient(value) {
|
|
46
|
+
return (0, polished.linearGradient)({
|
|
47
|
+
colorStops: value.map(({ color, ratio }) => `${color} ${ratio}%`),
|
|
48
|
+
fallback: value[0]?.color,
|
|
49
|
+
toDirection
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function applyEffectToGradient(effect) {
|
|
54
|
+
return function toGradient(value) {
|
|
55
|
+
return value.map(({ color, ratio }) => ({
|
|
56
|
+
color: applyEffect(color, effect),
|
|
57
|
+
ratio
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function applyEffect(baseColor, effects) {
|
|
62
|
+
const color = baseColor ?? "#00000000";
|
|
63
|
+
if (Array.isArray(effects)) return effects.reduce(applySingleEffect, color);
|
|
64
|
+
return applySingleEffect(color, effects);
|
|
65
|
+
}
|
|
66
|
+
function applySingleEffect(baseColor, effect) {
|
|
67
|
+
switch (effect.type) {
|
|
68
|
+
case "alpha": return applyAlpha(baseColor, effect);
|
|
69
|
+
case "opacity": return applyOpacity(baseColor, effect);
|
|
70
|
+
case "replace": return applyReplace(baseColor, effect);
|
|
71
|
+
default: throw new RangeError(`Unknown effect type ${effect.type}, upgrade @charcoal-ui/utils`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function applyAlpha(baseColor, { color, opacity }) {
|
|
75
|
+
const base = (0, polished.parseToRgb)(baseColor);
|
|
76
|
+
const effect = (0, polished.parseToRgb)(color);
|
|
77
|
+
return (0, polished.rgba)(...alphaBlend([
|
|
78
|
+
base.red,
|
|
79
|
+
base.green,
|
|
80
|
+
base.blue,
|
|
81
|
+
base.alpha ?? 1
|
|
82
|
+
], [
|
|
83
|
+
effect.red,
|
|
84
|
+
effect.green,
|
|
85
|
+
effect.blue,
|
|
86
|
+
clamp(0, 1, (effect.alpha ?? 1) * (opacity ?? 1))
|
|
87
|
+
]));
|
|
88
|
+
}
|
|
89
|
+
function applyOpacity(baseColor, { opacity }) {
|
|
90
|
+
const parsed = (0, polished.parseToRgb)(baseColor);
|
|
91
|
+
parsed.alpha = clamp(0, 1, (parsed.alpha ?? 1) * opacity);
|
|
92
|
+
return (0, polished.rgbToColorString)(parsed);
|
|
93
|
+
}
|
|
94
|
+
function applyReplace(baseColor, { color = baseColor, opacity }) {
|
|
95
|
+
if (opacity === void 0) return color;
|
|
96
|
+
const parsed = (0, polished.parseToRgb)(color);
|
|
97
|
+
parsed.alpha = opacity;
|
|
98
|
+
return (0, polished.rgbToColorString)(parsed);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* NOTE: alpha component must be in range from 0.0 to 1.0. (0.0 represents a fully transparent)
|
|
102
|
+
*
|
|
103
|
+
* @param src `[r, g, b, alpha]` Background
|
|
104
|
+
* @param dst `[r, g, b, alpha]` Foreground
|
|
105
|
+
*/
|
|
106
|
+
function alphaBlend(src, dst) {
|
|
107
|
+
const srcA = src[3];
|
|
108
|
+
const dstA = dst[3];
|
|
109
|
+
const outA = srcA + dstA * (1 - srcA);
|
|
110
|
+
if (outA < EPS) return [
|
|
111
|
+
0,
|
|
112
|
+
0,
|
|
113
|
+
0,
|
|
114
|
+
0
|
|
115
|
+
];
|
|
116
|
+
return [
|
|
117
|
+
Math.round((src[0] * srcA * (1 - dstA) + dst[0] * dstA) / outA),
|
|
118
|
+
Math.round((src[1] * srcA * (1 - dstA) + dst[1] * dstA) / outA),
|
|
119
|
+
Math.round((src[2] * srcA * (1 - dstA) + dst[2] * dstA) / outA),
|
|
120
|
+
outA
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
const EPS = 1e-6;
|
|
124
|
+
function clamp(min, max, value) {
|
|
125
|
+
return Math.min(Math.max(value, min), max);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* affix `px` unit
|
|
129
|
+
*
|
|
130
|
+
* @param value pixel
|
|
131
|
+
*/
|
|
132
|
+
function px(value) {
|
|
133
|
+
return `${value}px`;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* affix `s` unit
|
|
137
|
+
*
|
|
138
|
+
* @param value second
|
|
139
|
+
*/
|
|
140
|
+
function dur(value) {
|
|
141
|
+
return `${value}s`;
|
|
142
|
+
}
|
|
143
|
+
const notDisabledSelector = `&:not(:disabled):not([aria-disabled]), &[aria-disabled=false]`;
|
|
144
|
+
const disabledSelector = `&:disabled, &[aria-disabled]:not([aria-disabled=false])`;
|
|
145
|
+
/**
|
|
146
|
+
* Construct media query from breakpoint
|
|
147
|
+
*/
|
|
148
|
+
function maxWidth(breakpoint) {
|
|
149
|
+
return `(max-width: ${breakpoint - 1}px)`;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Derive half-leading from typography size
|
|
153
|
+
*/
|
|
154
|
+
const halfLeading = ({ fontSize, lineHeight }) => (lineHeight - fontSize) / 2;
|
|
155
|
+
/**
|
|
156
|
+
* Namespaced custom property
|
|
157
|
+
*/
|
|
158
|
+
const customPropertyToken = (id, modifiers = []) => `--charcoal-${id}${modifiers.length === 0 ? "" : ["", modifiers].join("-")}`;
|
|
159
|
+
/**
|
|
160
|
+
* @example
|
|
161
|
+
* ```js
|
|
162
|
+
* mapKeys({ a: 'aa', b: 'bb' }, (key) => key.toUpperCase()) // => { A: "aa", B: "bb" }
|
|
163
|
+
* ````
|
|
164
|
+
*/
|
|
165
|
+
function mapKeys(object, callback) {
|
|
166
|
+
return Object.fromEntries(Object.entries(object).map(([key, value]) => [callback(key), value]));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @example
|
|
170
|
+
* ```js
|
|
171
|
+
* mapObject({ a: 'aa', b: 'bb', c: 'cc' }, (key, value) =>
|
|
172
|
+
* key === 'b' ? undefined : [key + '1', value.toUpperCase()]
|
|
173
|
+
* ) // => { a1: "AA", c1: "CC" }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
function mapObject(source, callback) {
|
|
177
|
+
return Object.fromEntries(Object.entries(source).flatMap(([key, value]) => {
|
|
178
|
+
const entry = callback(key, value);
|
|
179
|
+
if (entry) return [entry];
|
|
180
|
+
else return [];
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @example
|
|
185
|
+
* ```js
|
|
186
|
+
* flatMapObject({ a: 'aa', b: 'bb' }, (key, value) => [
|
|
187
|
+
* [key + '1', value + '1'],
|
|
188
|
+
* [key + '2', value + '2'],
|
|
189
|
+
* ]) // => { a1: "aa1", a2: "aa2", b1: "bb1", b2: "bb2" }
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
function flatMapObject(source, callback) {
|
|
193
|
+
return Object.fromEntries(Object.entries(source).flatMap(([key, value]) => {
|
|
194
|
+
return callback(key, value);
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* filterObject(
|
|
201
|
+
* { a: 'aa', b: 'bb', c: 'cc' },
|
|
202
|
+
* (value): value is string => value !== 'bb'
|
|
203
|
+
* ) // => { a: "aa", c: "cc" }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
function filterObject(source, fn) {
|
|
207
|
+
return mapObject(source, (key, value) => {
|
|
208
|
+
if (fn(value) === true) return [key, value];
|
|
209
|
+
else return null;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
exports.GRADIENT_DIRECTIONS = GRADIENT_DIRECTIONS;
|
|
215
|
+
exports.applyEffect = applyEffect;
|
|
216
|
+
exports.applyEffectToGradient = applyEffectToGradient;
|
|
217
|
+
exports.customPropertyToken = customPropertyToken;
|
|
218
|
+
exports.disabledSelector = disabledSelector;
|
|
219
|
+
exports.dur = dur;
|
|
220
|
+
exports.filterObject = filterObject;
|
|
221
|
+
exports.flatMapObject = flatMapObject;
|
|
222
|
+
exports.gradient = gradient;
|
|
223
|
+
exports.halfLeading = halfLeading;
|
|
224
|
+
exports.mapKeys = mapKeys;
|
|
225
|
+
exports.mapObject = mapObject;
|
|
226
|
+
exports.maxWidth = maxWidth;
|
|
227
|
+
exports.notDisabledSelector = notDisabledSelector;
|
|
228
|
+
exports.px = px;
|
|
229
|
+
exports.transparentGradient = transparentGradient;
|
|
230
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["transparentGradient","base: RgbaColor","effect: RgbaColor","parsed: RgbaColor"],"sources":["../src/index.ts"],"sourcesContent":["import { rgba, rgbToColorString, parseToRgb, linearGradient } from 'polished'\nimport type { RgbColor } from 'polished/lib/types/color'\n\nimport type {\n AlphaEffect,\n Effect,\n Effects,\n GradientMaterial,\n OpacityEffect,\n ReplaceEffect,\n TypographyDescriptor,\n} from '@charcoal-ui/foundation'\nimport type { Styles } from 'polished/lib/types/style'\n\nexport const GRADIENT_DIRECTIONS = [\n 'to top',\n 'to bottom',\n 'to left',\n 'to right',\n] as const\n\nexport type GradientDirection = (typeof GRADIENT_DIRECTIONS)[number]\n\nexport function transparentGradient(\n color: string,\n defaultDirection: GradientDirection = 'to bottom'\n) {\n return function transparentGradient(\n direction: GradientDirection | object = defaultDirection\n ): Styles {\n const transparent = rgba(color, 0)\n return linearGradient({\n colorStops: [color, transparent],\n fallback: transparent,\n toDirection: typeof direction === 'object' ? defaultDirection : direction,\n })\n }\n}\n\nexport function gradient(toDirection: GradientDirection = 'to bottom') {\n return function toLinearGradient(value: GradientMaterial): Styles {\n return linearGradient({\n colorStops: value.map(({ color, ratio }) => `${color} ${ratio}%`),\n fallback: value[0]?.color,\n toDirection,\n })\n }\n}\n\nexport function applyEffectToGradient(effect: Effects) {\n return function toGradient(value: GradientMaterial): GradientMaterial {\n return value.map(({ color, ratio }) => ({\n color: applyEffect(color, effect),\n ratio,\n }))\n }\n}\n\ninterface RgbaColor extends RgbColor {\n alpha?: number\n}\n\ninterface ReadonlyArrayConstructor {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isArray(value: any): value is readonly any[]\n}\n\nexport function applyEffect(\n baseColor: string | null,\n effects: Effects\n): string {\n const color = baseColor ?? '#00000000'\n if ((Array as ReadonlyArrayConstructor).isArray(effects)) {\n return effects.reduce(applySingleEffect, color)\n }\n return applySingleEffect(color, effects)\n}\n\nfunction applySingleEffect(baseColor: string, effect: Effect): string {\n switch (effect.type) {\n case 'alpha':\n return applyAlpha(baseColor, effect)\n case 'opacity':\n return applyOpacity(baseColor, effect)\n case 'replace':\n return applyReplace(baseColor, effect)\n default:\n throw new RangeError(\n `Unknown effect type ${\n (effect as Effect).type\n }, upgrade @charcoal-ui/utils`\n )\n }\n}\n\nfunction applyAlpha(baseColor: string, { color, opacity }: AlphaEffect) {\n const base: RgbaColor = parseToRgb(baseColor)\n const effect: RgbaColor = parseToRgb(color)\n const src = [base.red, base.green, base.blue, base.alpha ?? 1.0] as const\n const dst = [\n effect.red,\n effect.green,\n effect.blue,\n clamp(0, 1, (effect.alpha ?? 1.0) * (opacity ?? 1.0)),\n ] as const\n return rgba(...alphaBlend(src, dst))\n}\n\nfunction applyOpacity(baseColor: string, { opacity }: OpacityEffect) {\n const parsed: RgbaColor = parseToRgb(baseColor)\n parsed.alpha = clamp(0, 1, (parsed.alpha ?? 1.0) * opacity)\n return rgbToColorString(parsed)\n}\n\nfunction applyReplace(\n baseColor: string,\n { color = baseColor, opacity }: ReplaceEffect\n) {\n if (opacity === undefined) {\n return color\n }\n const parsed: RgbaColor = parseToRgb(color)\n // NOTE: intentionally ignores any alpha value in the baseColor\n parsed.alpha = opacity\n return rgbToColorString(parsed)\n}\n\ntype Color4 = readonly [number, number, number, number]\n\n/**\n * NOTE: alpha component must be in range from 0.0 to 1.0. (0.0 represents a fully transparent)\n *\n * @param src `[r, g, b, alpha]` Background\n * @param dst `[r, g, b, alpha]` Foreground\n */\nfunction alphaBlend(src: Color4, dst: Color4): Color4 {\n const srcA = src[3]\n const dstA = dst[3]\n const outA = srcA + dstA * (1 - srcA)\n if (outA < EPS) {\n // blending 0% alpha with 0% alpha\n return [0, 0, 0, 0]\n }\n return [\n Math.round((src[0] * srcA * (1 - dstA) + dst[0] * dstA) / outA),\n Math.round((src[1] * srcA * (1 - dstA) + dst[1] * dstA) / outA),\n Math.round((src[2] * srcA * (1 - dstA) + dst[2] * dstA) / outA),\n outA,\n ]\n}\nconst EPS = 1e-6\n\nfunction clamp(min: number, max: number, value: number) {\n return Math.min(Math.max(value, min), max)\n}\n\n/**\n * affix `px` unit\n *\n * @param value pixel\n */\nexport function px(value: number) {\n return `${value}px`\n}\n\n/**\n * affix `s` unit\n *\n * @param value second\n */\nexport function dur(value: number) {\n return `${value}s`\n}\n\nexport const notDisabledSelector = `&:not(:disabled):not([aria-disabled]), &[aria-disabled=false]`\n\nexport const disabledSelector = `&:disabled, &[aria-disabled]:not([aria-disabled=false])`\n\n/**\n * Construct media query from breakpoint\n */\nexport function maxWidth(breakpoint: number) {\n return `(max-width: ${breakpoint - 1}px)`\n}\n\n/**\n * Derive half-leading from typography size\n */\nexport const halfLeading = ({\n fontSize,\n lineHeight,\n}: TypographyDescriptor): number => (lineHeight - fontSize) / 2\n\n/**\n * Namespaced custom property\n */\nexport const customPropertyToken = (\n id: string,\n modifiers: readonly string[] = []\n): `--charcoal-${string}` =>\n `--charcoal-${id}${modifiers.length === 0 ? '' : ['', modifiers].join('-')}`\n\n/**\n * @example\n * ```js\n * mapKeys({ a: 'aa', b: 'bb' }, (key) => key.toUpperCase()) // => { A: \"aa\", B: \"bb\" }\n * ````\n */\nexport function mapKeys<V, K extends string>(\n object: Record<string, V>,\n callback: (key: string) => K\n) {\n return Object.fromEntries(\n Object.entries(object).map(([key, value]) => [callback(key), value])\n ) as Record<K, V>\n}\n\n/**\n * @example\n * ```js\n * mapObject({ a: 'aa', b: 'bb', c: 'cc' }, (key, value) =>\n * key === 'b' ? undefined : [key + '1', value.toUpperCase()]\n * ) // => { a1: \"AA\", c1: \"CC\" }\n * ```\n */\nexport function mapObject<\n SourceKey extends string,\n SourceValue,\n DestKey extends string,\n DestValue\n>(\n source: Record<SourceKey, SourceValue>,\n callback: (\n key: SourceKey,\n value: SourceValue\n ) => [DestKey, DestValue] | null | undefined\n) {\n return Object.fromEntries(\n Object.entries(source).flatMap(([key, value]) => {\n const entry = callback(key as SourceKey, value as SourceValue)\n if (entry) {\n return [entry]\n } else {\n return []\n }\n })\n ) as Record<DestKey, DestValue>\n}\n\n/**\n * @example\n * ```js\n * flatMapObject({ a: 'aa', b: 'bb' }, (key, value) => [\n * [key + '1', value + '1'],\n * [key + '2', value + '2'],\n * ]) // => { a1: \"aa1\", a2: \"aa2\", b1: \"bb1\", b2: \"bb2\" }\n * ```\n */\nexport function flatMapObject<\n SourceKey extends string,\n SourceValue,\n DestKey extends string,\n DestValue\n>(\n source: Record<SourceKey, SourceValue>,\n callback: (key: SourceKey, value: SourceValue) => [DestKey, DestValue][]\n) {\n return Object.fromEntries(\n Object.entries(source).flatMap(([key, value]) => {\n return callback(key as SourceKey, value as SourceValue)\n })\n ) as Record<DestKey, DestValue>\n}\n\n/**\n * @example\n * ```ts\n * filterObject(\n * { a: 'aa', b: 'bb', c: 'cc' },\n * (value): value is string => value !== 'bb'\n * ) // => { a: \"aa\", c: \"cc\" }\n * ```\n */\nexport function filterObject<Source, Dest extends Source>(\n source: Record<string, Source>,\n fn: (value: Source) => value is Dest\n) {\n return mapObject(source, (key, value) => {\n if (fn(value) === true) {\n return [key, value]\n } else {\n return null\n }\n }) as Record<string, Dest>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACD;AAID,SAAgB,oBACd,OACA,mBAAsC,aACtC;AACA,QAAO,SAASA,sBACd,YAAwC,kBAChC;EACR,MAAM,iCAAmB,OAAO,EAAE;AAClC,sCAAsB;GACpB,YAAY,CAAC,OAAO,YAAY;GAChC,UAAU;GACV,aAAa,OAAO,cAAc,WAAW,mBAAmB;GACjE,CAAC;;;AAIN,SAAgB,SAAS,cAAiC,aAAa;AACrE,QAAO,SAAS,iBAAiB,OAAiC;AAChE,sCAAsB;GACpB,YAAY,MAAM,KAAK,EAAE,OAAO,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG;GACjE,UAAU,MAAM,IAAI;GACpB;GACD,CAAC;;;AAIN,SAAgB,sBAAsB,QAAiB;AACrD,QAAO,SAAS,WAAW,OAA2C;AACpE,SAAO,MAAM,KAAK,EAAE,OAAO,aAAa;GACtC,OAAO,YAAY,OAAO,OAAO;GACjC;GACD,EAAE;;;AAaP,SAAgB,YACd,WACA,SACQ;CACR,MAAM,QAAQ,aAAa;AAC3B,KAAK,MAAmC,QAAQ,QAAQ,CACtD,QAAO,QAAQ,OAAO,mBAAmB,MAAM;AAEjD,QAAO,kBAAkB,OAAO,QAAQ;;AAG1C,SAAS,kBAAkB,WAAmB,QAAwB;AACpE,SAAQ,OAAO,MAAf;EACE,KAAK,QACH,QAAO,WAAW,WAAW,OAAO;EACtC,KAAK,UACH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region ../foundation/src/typography.d.ts
|
|
4
|
+
interface TypographyDescriptor {
|
|
5
|
+
readonly lineHeight: number;
|
|
6
|
+
readonly fontSize: number;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region ../foundation/src/color.d.ts
|
|
10
|
+
type Material = string;
|
|
11
|
+
type GradientMaterial = readonly {
|
|
12
|
+
readonly color: Material;
|
|
13
|
+
readonly ratio: number;
|
|
14
|
+
}[];
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../foundation/src/effect.d.ts
|
|
17
|
+
type Effects = Readonly<Effect> | readonly Readonly<Effect>[];
|
|
18
|
+
type Effect = AlphaEffect | OpacityEffect | ReplaceEffect;
|
|
19
|
+
interface BaseEffect {}
|
|
20
|
+
interface AlphaEffect extends BaseEffect {
|
|
21
|
+
readonly type: "alpha";
|
|
22
|
+
/**
|
|
23
|
+
* Color to blend with the base color using alpha blending.
|
|
24
|
+
*/
|
|
25
|
+
readonly color: string;
|
|
26
|
+
/**
|
|
27
|
+
* Multiplied with the alpha value of the effect's `color` before blending.
|
|
28
|
+
*
|
|
29
|
+
* `1` by default.
|
|
30
|
+
*/
|
|
31
|
+
readonly opacity?: number;
|
|
32
|
+
}
|
|
33
|
+
interface OpacityEffect extends BaseEffect {
|
|
34
|
+
readonly type: "opacity";
|
|
35
|
+
/**
|
|
36
|
+
* Value to multiply with the current color's alpha value.
|
|
37
|
+
*/
|
|
38
|
+
readonly opacity: number;
|
|
39
|
+
}
|
|
40
|
+
interface ReplaceEffect extends BaseEffect {
|
|
41
|
+
readonly type: "replace";
|
|
42
|
+
/**
|
|
43
|
+
* Replaces any given color with this color
|
|
44
|
+
*/
|
|
45
|
+
readonly color?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Replaces the alpha value with this opacity.
|
|
48
|
+
*
|
|
49
|
+
* Overrides the `color`'s opacity as well.
|
|
50
|
+
*/
|
|
51
|
+
readonly opacity?: number;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/index.d.ts
|
|
55
|
+
declare const GRADIENT_DIRECTIONS: readonly ["to top", "to bottom", "to left", "to right"];
|
|
56
|
+
type GradientDirection = (typeof GRADIENT_DIRECTIONS)[number];
|
|
57
|
+
declare function transparentGradient(color: string, defaultDirection?: GradientDirection): (direction?: GradientDirection | object) => Styles;
|
|
58
|
+
declare function gradient(toDirection?: GradientDirection): (value: GradientMaterial) => Styles;
|
|
59
|
+
declare function applyEffectToGradient(effect: Effects): (value: GradientMaterial) => GradientMaterial;
|
|
60
|
+
declare function applyEffect(baseColor: string | null, effects: Effects): string;
|
|
61
|
+
/**
|
|
62
|
+
* affix `px` unit
|
|
63
|
+
*
|
|
64
|
+
* @param value pixel
|
|
65
|
+
*/
|
|
66
|
+
declare function px(value: number): string;
|
|
67
|
+
/**
|
|
68
|
+
* affix `s` unit
|
|
69
|
+
*
|
|
70
|
+
* @param value second
|
|
71
|
+
*/
|
|
72
|
+
declare function dur(value: number): string;
|
|
73
|
+
declare const notDisabledSelector = "&:not(:disabled):not([aria-disabled]), &[aria-disabled=false]";
|
|
74
|
+
declare const disabledSelector = "&:disabled, &[aria-disabled]:not([aria-disabled=false])";
|
|
75
|
+
/**
|
|
76
|
+
* Construct media query from breakpoint
|
|
77
|
+
*/
|
|
78
|
+
declare function maxWidth(breakpoint: number): string;
|
|
79
|
+
/**
|
|
80
|
+
* Derive half-leading from typography size
|
|
81
|
+
*/
|
|
82
|
+
declare const halfLeading: ({
|
|
83
|
+
fontSize,
|
|
84
|
+
lineHeight
|
|
85
|
+
}: TypographyDescriptor) => number;
|
|
86
|
+
/**
|
|
87
|
+
* Namespaced custom property
|
|
88
|
+
*/
|
|
89
|
+
declare const customPropertyToken: (id: string, modifiers?: readonly string[]) => `--charcoal-${string}`;
|
|
90
|
+
/**
|
|
91
|
+
* @example
|
|
92
|
+
* ```js
|
|
93
|
+
* mapKeys({ a: 'aa', b: 'bb' }, (key) => key.toUpperCase()) // => { A: "aa", B: "bb" }
|
|
94
|
+
* ````
|
|
95
|
+
*/
|
|
96
|
+
declare function mapKeys<V, K extends string>(object: Record<string, V>, callback: (key: string) => K): Record<K, V>;
|
|
97
|
+
/**
|
|
98
|
+
* @example
|
|
99
|
+
* ```js
|
|
100
|
+
* mapObject({ a: 'aa', b: 'bb', c: 'cc' }, (key, value) =>
|
|
101
|
+
* key === 'b' ? undefined : [key + '1', value.toUpperCase()]
|
|
102
|
+
* ) // => { a1: "AA", c1: "CC" }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function mapObject<SourceKey extends string, SourceValue, DestKey extends string, DestValue>(source: Record<SourceKey, SourceValue>, callback: (key: SourceKey, value: SourceValue) => [DestKey, DestValue] | null | undefined): Record<DestKey, DestValue>;
|
|
106
|
+
/**
|
|
107
|
+
* @example
|
|
108
|
+
* ```js
|
|
109
|
+
* flatMapObject({ a: 'aa', b: 'bb' }, (key, value) => [
|
|
110
|
+
* [key + '1', value + '1'],
|
|
111
|
+
* [key + '2', value + '2'],
|
|
112
|
+
* ]) // => { a1: "aa1", a2: "aa2", b1: "bb1", b2: "bb2" }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function flatMapObject<SourceKey extends string, SourceValue, DestKey extends string, DestValue>(source: Record<SourceKey, SourceValue>, callback: (key: SourceKey, value: SourceValue) => [DestKey, DestValue][]): Record<DestKey, DestValue>;
|
|
116
|
+
/**
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* filterObject(
|
|
120
|
+
* { a: 'aa', b: 'bb', c: 'cc' },
|
|
121
|
+
* (value): value is string => value !== 'bb'
|
|
122
|
+
* ) // => { a: "aa", c: "cc" }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare function filterObject<Source, Dest extends Source>(source: Record<string, Source>, fn: (value: Source) => value is Dest): Record<string, Dest>;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { GRADIENT_DIRECTIONS, GradientDirection, applyEffect, applyEffectToGradient, customPropertyToken, disabledSelector, dur, filterObject, flatMapObject, gradient, halfLeading, mapKeys, mapObject, maxWidth, notDisabledSelector, px, transparentGradient };
|
|
128
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../foundation/src/typography.ts","../../foundation/src/color.ts","../../foundation/src/effect.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;UAAiB,oBAAA;;;AAAjB;;;KCAY,QAAA;KAEA,gBAAA;kBACM;EDHlB,SAAiB,KAAA,EAAA,MAAA;;;;KEAL,OAAA,GAAU,SAAS,mBAAmB,SAAS;KAE/C,MAAA,GAAS,cAAc,gBAAgB;UAEzC,UAAA;AFJO,UEMA,WAAA,SAAoB,UFNpB,CAAA;;;;ACAjB;EAEA,SAAY,KAAA,EAAA,MAAA;;;;ACFZ;;WAA+B,OAAA,CAAA,EAAA,MAAA;;AAA4B,UAoB1C,aAAA,SAAsB,UApBoB,CAAA;WAAT,IAAA,EAAA,SAAA;EAAA;AAElD;;WAAqB,OAAA,EAAA,MAAA;;AAA8B,UA0BlC,aAAA,SAAsB,UA1BY,CAAA;EAAA,SAAA,IAAA,EAAA,SAAA;EAAA;AAInD;AAcA;EAQA,SAAiB,KAAA,CAAA,EAAA,MAAA;;;;ACdjB;AAOA;EAEA,SAAgB,OAAA,CAAA,EAAA,MAAA;;;;cATH;AHdI,KGqBL,iBAAA,GHrBK,CAAA,OGqBuB,mBHrBvB,CAAA,CAAA,MAAA,CAAA;iBGuBD,mBAAA,mCAEI,iCAGL,+BACV;iBAUW,QAAA,eAAsB,4BACI,qBAAmB;iBAS7C,qBAAA,SAA8B,kBACV,qBAAmB;AFlD3C,iBEmEI,WAAA,CFnEJ,SAAA,EAAA,MAAA,GAAA,IAAA,EAAA,OAAA,EEqED,OFrEC,CAAA,EAAA,MAAA;AAEZ;;;;ACFA;AAAY,iBCiKI,EAAA,CDjKJ,KAAA,EAAA,MA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,EAAA,GAAA,CAmD8C,OAnD9C,EAmDuD,SAnDvD,CAAA,EAAA,CAAA,EAyDA,MAzDA,CAyDO,OAzDP,EAyDgB,SAzDhB,CAAA;;AAWP;;;;;;;;AAUiB,iBAgDD,YAhDC,OAWH,eAqCoC,MArC3B,QAAhB,EAsCG,MAtCH,CAAA,MAAA,EAsCkB,MAtClB,CAAA,EAAA,EAAA,EAAA,CAAA,KAAA,EAuCO,MAvCP,EAAA,GAAA,KAAA,IAuC2B,IAvC3B,CAAA,EA+CC,MA/CD,CAAA,MAAA,EA+CgB,IA/ChB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,70 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Styles } from "polished/lib/types/style";
|
|
2
|
+
|
|
3
|
+
//#region ../foundation/src/typography.d.ts
|
|
4
|
+
interface TypographyDescriptor {
|
|
5
|
+
readonly lineHeight: number;
|
|
6
|
+
readonly fontSize: number;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region ../foundation/src/color.d.ts
|
|
10
|
+
type Material = string;
|
|
11
|
+
type GradientMaterial = readonly {
|
|
12
|
+
readonly color: Material;
|
|
13
|
+
readonly ratio: number;
|
|
14
|
+
}[];
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../foundation/src/effect.d.ts
|
|
17
|
+
type Effects = Readonly<Effect> | readonly Readonly<Effect>[];
|
|
18
|
+
type Effect = AlphaEffect | OpacityEffect | ReplaceEffect;
|
|
19
|
+
interface BaseEffect {}
|
|
20
|
+
interface AlphaEffect extends BaseEffect {
|
|
21
|
+
readonly type: "alpha";
|
|
22
|
+
/**
|
|
23
|
+
* Color to blend with the base color using alpha blending.
|
|
24
|
+
*/
|
|
25
|
+
readonly color: string;
|
|
26
|
+
/**
|
|
27
|
+
* Multiplied with the alpha value of the effect's `color` before blending.
|
|
28
|
+
*
|
|
29
|
+
* `1` by default.
|
|
30
|
+
*/
|
|
31
|
+
readonly opacity?: number;
|
|
32
|
+
}
|
|
33
|
+
interface OpacityEffect extends BaseEffect {
|
|
34
|
+
readonly type: "opacity";
|
|
35
|
+
/**
|
|
36
|
+
* Value to multiply with the current color's alpha value.
|
|
37
|
+
*/
|
|
38
|
+
readonly opacity: number;
|
|
39
|
+
}
|
|
40
|
+
interface ReplaceEffect extends BaseEffect {
|
|
41
|
+
readonly type: "replace";
|
|
42
|
+
/**
|
|
43
|
+
* Replaces any given color with this color
|
|
44
|
+
*/
|
|
45
|
+
readonly color?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Replaces the alpha value with this opacity.
|
|
48
|
+
*
|
|
49
|
+
* Overrides the `color`'s opacity as well.
|
|
50
|
+
*/
|
|
51
|
+
readonly opacity?: number;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/index.d.ts
|
|
55
|
+
declare const GRADIENT_DIRECTIONS: readonly ["to top", "to bottom", "to left", "to right"];
|
|
56
|
+
type GradientDirection = (typeof GRADIENT_DIRECTIONS)[number];
|
|
57
|
+
declare function transparentGradient(color: string, defaultDirection?: GradientDirection): (direction?: GradientDirection | object) => Styles;
|
|
58
|
+
declare function gradient(toDirection?: GradientDirection): (value: GradientMaterial) => Styles;
|
|
59
|
+
declare function applyEffectToGradient(effect: Effects): (value: GradientMaterial) => GradientMaterial;
|
|
60
|
+
declare function applyEffect(baseColor: string | null, effects: Effects): string;
|
|
8
61
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
62
|
+
* affix `px` unit
|
|
63
|
+
*
|
|
64
|
+
* @param value pixel
|
|
65
|
+
*/
|
|
66
|
+
declare function px(value: number): string;
|
|
14
67
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
68
|
+
* affix `s` unit
|
|
69
|
+
*
|
|
70
|
+
* @param value second
|
|
71
|
+
*/
|
|
72
|
+
declare function dur(value: number): string;
|
|
73
|
+
declare const notDisabledSelector = "&:not(:disabled):not([aria-disabled]), &[aria-disabled=false]";
|
|
74
|
+
declare const disabledSelector = "&:disabled, &[aria-disabled]:not([aria-disabled=false])";
|
|
22
75
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
76
|
+
* Construct media query from breakpoint
|
|
77
|
+
*/
|
|
78
|
+
declare function maxWidth(breakpoint: number): string;
|
|
26
79
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
80
|
+
* Derive half-leading from typography size
|
|
81
|
+
*/
|
|
82
|
+
declare const halfLeading: ({
|
|
83
|
+
fontSize,
|
|
84
|
+
lineHeight
|
|
85
|
+
}: TypographyDescriptor) => number;
|
|
30
86
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
87
|
+
* Namespaced custom property
|
|
88
|
+
*/
|
|
89
|
+
declare const customPropertyToken: (id: string, modifiers?: readonly string[]) => `--charcoal-${string}`;
|
|
34
90
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
91
|
+
* @example
|
|
92
|
+
* ```js
|
|
93
|
+
* mapKeys({ a: 'aa', b: 'bb' }, (key) => key.toUpperCase()) // => { A: "aa", B: "bb" }
|
|
94
|
+
* ````
|
|
95
|
+
*/
|
|
96
|
+
declare function mapKeys<V, K extends string>(object: Record<string, V>, callback: (key: string) => K): Record<K, V>;
|
|
41
97
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
98
|
+
* @example
|
|
99
|
+
* ```js
|
|
100
|
+
* mapObject({ a: 'aa', b: 'bb', c: 'cc' }, (key, value) =>
|
|
101
|
+
* key === 'b' ? undefined : [key + '1', value.toUpperCase()]
|
|
102
|
+
* ) // => { a1: "AA", c1: "CC" }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function mapObject<SourceKey extends string, SourceValue, DestKey extends string, DestValue>(source: Record<SourceKey, SourceValue>, callback: (key: SourceKey, value: SourceValue) => [DestKey, DestValue] | null | undefined): Record<DestKey, DestValue>;
|
|
50
106
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
107
|
+
* @example
|
|
108
|
+
* ```js
|
|
109
|
+
* flatMapObject({ a: 'aa', b: 'bb' }, (key, value) => [
|
|
110
|
+
* [key + '1', value + '1'],
|
|
111
|
+
* [key + '2', value + '2'],
|
|
112
|
+
* ]) // => { a1: "aa1", a2: "aa2", b1: "bb1", b2: "bb2" }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function flatMapObject<SourceKey extends string, SourceValue, DestKey extends string, DestValue>(source: Record<SourceKey, SourceValue>, callback: (key: SourceKey, value: SourceValue) => [DestKey, DestValue][]): Record<DestKey, DestValue>;
|
|
60
116
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* filterObject(
|
|
120
|
+
* { a: 'aa', b: 'bb', c: 'cc' },
|
|
121
|
+
* (value): value is string => value !== 'bb'
|
|
122
|
+
* ) // => { a: "aa", c: "cc" }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare function filterObject<Source, Dest extends Source>(source: Record<string, Source>, fn: (value: Source) => value is Dest): Record<string, Dest>;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { GRADIENT_DIRECTIONS, GradientDirection, applyEffect, applyEffectToGradient, customPropertyToken, disabledSelector, dur, filterObject, flatMapObject, gradient, halfLeading, mapKeys, mapObject, maxWidth, notDisabledSelector, px, transparentGradient };
|
|
70
128
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../foundation/src/typography.ts","../../foundation/src/color.ts","../../foundation/src/effect.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;UAAiB,oBAAA;;;AAAjB;;;KCAY,QAAA;KAEA,gBAAA;kBACM;EDHlB,SAAiB,KAAA,EAAA,MAAA;;;;KEAL,OAAA,GAAU,SAAS,mBAAmB,SAAS;KAE/C,MAAA,GAAS,cAAc,gBAAgB;UAEzC,UAAA;AFJO,UEMA,WAAA,SAAoB,UFNpB,CAAA;;;;ACAjB;EAEA,SAAY,KAAA,EAAA,MAAA;;;;ACFZ;;WAA+B,OAAA,CAAA,EAAA,MAAA;;AAA4B,UAoB1C,aAAA,SAAsB,UApBoB,CAAA;WAAT,IAAA,EAAA,SAAA;EAAA;AAElD;;WAAqB,OAAA,EAAA,MAAA;;AAA8B,UA0BlC,aAAA,SAAsB,UA1BY,CAAA;EAAA,SAAA,IAAA,EAAA,SAAA;EAAA;AAInD;AAcA;EAQA,SAAiB,KAAA,CAAA,EAAA,MAAA;;;;ACdjB;AAOA;EAEA,SAAgB,OAAA,CAAA,EAAA,MAAA;;;;cATH;AHdI,KGqBL,iBAAA,GHrBK,CAAA,OGqBuB,mBHrBvB,CAAA,CAAA,MAAA,CAAA;iBGuBD,mBAAA,mCAEI,iCAGL,+BACV;iBAUW,QAAA,eAAsB,4BACI,qBAAmB;iBAS7C,qBAAA,SAA8B,kBACV,qBAAmB;AFlD3C,iBEmEI,WAAA,CFnEJ,SAAA,EAAA,MAAA,GAAA,IAAA,EAAA,OAAA,EEqED,OFrEC,CAAA,EAAA,MAAA;AAEZ;;;;ACFA;AAAY,iBCiKI,E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