@tokenami/config 0.0.77 → 0.0.78--canary.391.13466705179.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/index.cjs +30 -2
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +23 -3
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var hash = require('@emotion/hash');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var hash__default = /*#__PURE__*/_interopDefault(hash);
|
|
8
|
+
|
|
3
9
|
// src/config.ts
|
|
4
10
|
function createConfig(config) {
|
|
5
11
|
return config;
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
// src/common.ts
|
|
9
13
|
var gridPropertyRegex = /--_grid/;
|
|
10
14
|
var GridProperty = {
|
|
11
15
|
safeParse: (input) => validate(gridPropertyRegex, input)
|
|
@@ -111,6 +115,16 @@ function getTokenValueParts(tokenValue2) {
|
|
|
111
115
|
function getCSSPropertiesForAlias(alias, aliases) {
|
|
112
116
|
return (aliases == null ? void 0 : aliases[alias]) || [alias];
|
|
113
117
|
}
|
|
118
|
+
function generateClassName(properties) {
|
|
119
|
+
const entries = Object.entries(properties).map(([property, value]) => [property, String(value)]).sort(([keyA], [keyB]) => keyA.localeCompare(keyB));
|
|
120
|
+
const str = JSON.stringify(entries);
|
|
121
|
+
return `tk-${hash__default.default(str)}`;
|
|
122
|
+
}
|
|
123
|
+
function createLonghandProperty(tokenProperty2, cssProperty) {
|
|
124
|
+
const parts = getTokenPropertySplit(tokenProperty2);
|
|
125
|
+
const aliasRegex = new RegExp(`${parts.alias}$`);
|
|
126
|
+
return tokenProperty2.replace(aliasRegex, cssProperty);
|
|
127
|
+
}
|
|
114
128
|
var escapeSpecialCharsRegex = /[&#.:;>~*[\]=,"'()+{}]/g;
|
|
115
129
|
function parseProperty(str, options) {
|
|
116
130
|
const { escapeSpecialChars = true } = options || {};
|
|
@@ -124,6 +138,16 @@ function stringifyProperty(property) {
|
|
|
124
138
|
}
|
|
125
139
|
var encodeColon = (str) => str.replace(/:/g, ";");
|
|
126
140
|
var decodeColon = (str) => str.replace(/;/g, ":");
|
|
141
|
+
function* iterateAliasProperties(styleEntries, config) {
|
|
142
|
+
for (const [key, value] of styleEntries) {
|
|
143
|
+
const tokenProperty2 = key;
|
|
144
|
+
const parts = getTokenPropertySplit(tokenProperty2);
|
|
145
|
+
const cssProperties = getCSSPropertiesForAlias(parts.alias, config.aliases);
|
|
146
|
+
const isCalc = typeof value === "number" && value !== 0;
|
|
147
|
+
yield [key, value, { isCalc, cssProperties }];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
var calcProperty = (property) => property + "__calc";
|
|
127
151
|
|
|
128
152
|
// src/shorthands.ts
|
|
129
153
|
var shorthandsToLonghands = [
|
|
@@ -209,7 +233,10 @@ exports.TokenProperty = TokenProperty;
|
|
|
209
233
|
exports.TokenValue = TokenValue;
|
|
210
234
|
exports.VariantProperty = VariantProperty;
|
|
211
235
|
exports.arbitraryValue = arbitraryValue;
|
|
236
|
+
exports.calcProperty = calcProperty;
|
|
212
237
|
exports.createConfig = createConfig;
|
|
238
|
+
exports.createLonghandProperty = createLonghandProperty;
|
|
239
|
+
exports.generateClassName = generateClassName;
|
|
213
240
|
exports.getArbitrarySelector = getArbitrarySelector;
|
|
214
241
|
exports.getCSSPropertiesForAlias = getCSSPropertiesForAlias;
|
|
215
242
|
exports.getTokenPropertyName = getTokenPropertyName;
|
|
@@ -217,6 +244,7 @@ exports.getTokenPropertyParts = getTokenPropertyParts;
|
|
|
217
244
|
exports.getTokenPropertySplit = getTokenPropertySplit;
|
|
218
245
|
exports.getTokenValueParts = getTokenValueParts;
|
|
219
246
|
exports.gridProperty = gridProperty;
|
|
247
|
+
exports.iterateAliasProperties = iterateAliasProperties;
|
|
220
248
|
exports.mapShorthandToLonghands = mapShorthandToLonghands;
|
|
221
249
|
exports.parseProperty = parseProperty;
|
|
222
250
|
exports.parsedTokenProperty = parsedTokenProperty;
|
package/dist/index.d.cts
CHANGED
|
@@ -110,11 +110,18 @@ declare function getTokenValueParts(tokenValue: TokenValue): {
|
|
|
110
110
|
token: string;
|
|
111
111
|
};
|
|
112
112
|
declare function getCSSPropertiesForAlias(alias: string, aliases: Config['aliases']): string[];
|
|
113
|
+
declare function generateClassName(properties: Record<string, any>): string;
|
|
114
|
+
declare function createLonghandProperty(tokenProperty: TokenProperty, cssProperty: string): `--${string}`;
|
|
113
115
|
declare function parseProperty<T extends string>(str: T, options?: {
|
|
114
116
|
escapeSpecialChars?: boolean;
|
|
115
117
|
}): T;
|
|
116
118
|
declare function stringifyProperty<T extends string>(property: T): T;
|
|
119
|
+
declare function iterateAliasProperties(styleEntries: [key: string, value: any][], config: Pick<Config, 'aliases'>): Generator<[string, any, {
|
|
120
|
+
isCalc: boolean;
|
|
121
|
+
cssProperties: string[];
|
|
122
|
+
}]>;
|
|
123
|
+
declare const calcProperty: (property: string) => `--${string}`;
|
|
117
124
|
|
|
118
125
|
declare const mapShorthandToLonghands: Map<"flex" | "grid" | "all" | "border-block-color" | "border-block-style" | "border-block-width" | "border-inline-color" | "border-inline-style" | "border-inline-width" | "font-variant" | "animation" | "background" | "background-position" | "border" | "border-block" | "border-block-end" | "border-block-start" | "border-bottom" | "border-color" | "border-image" | "border-inline" | "border-inline-end" | "border-inline-start" | "border-left" | "border-radius" | "border-right" | "border-style" | "border-top" | "border-width" | "column-rule" | "columns" | "contain-intrinsic-size" | "container" | "flex-flow" | "font" | "gap" | "grid-area" | "grid-column" | "grid-row" | "grid-template" | "inset" | "inset-block" | "inset-inline" | "list-style" | "margin" | "margin-block" | "margin-inline" | "mask" | "mask-border" | "offset" | "outline" | "overflow" | "overscroll-behavior" | "padding" | "padding-block" | "padding-inline" | "place-content" | "place-items" | "place-self" | "scroll-margin" | "scroll-margin-block" | "scroll-margin-inline" | "scroll-padding" | "scroll-padding-block" | "scroll-padding-inline" | "scroll-timeline" | "text-decoration" | "text-emphasis" | "transition", string[]>;
|
|
119
126
|
|
|
120
|
-
export { type Aliases, ArbitraryValue, type CSSProperties, type CSSProperty, type Config, GridProperty, GridValue, type Theme, type ThemeModes, TokenProperty, TokenValue, VariantProperty, arbitraryValue, createConfig, getArbitrarySelector, getCSSPropertiesForAlias, getTokenPropertyName, getTokenPropertyParts, getTokenPropertySplit, getTokenValueParts, gridProperty, mapShorthandToLonghands, parseProperty, parsedTokenProperty, parsedVariantProperty, stringifyProperty, tokenProperty, tokenValue, variantProperty };
|
|
127
|
+
export { type Aliases, ArbitraryValue, type CSSProperties, type CSSProperty, type Config, GridProperty, GridValue, type Theme, type ThemeModes, TokenProperty, TokenValue, VariantProperty, arbitraryValue, calcProperty, createConfig, createLonghandProperty, generateClassName, getArbitrarySelector, getCSSPropertiesForAlias, getTokenPropertyName, getTokenPropertyParts, getTokenPropertySplit, getTokenValueParts, gridProperty, iterateAliasProperties, mapShorthandToLonghands, parseProperty, parsedTokenProperty, parsedVariantProperty, stringifyProperty, tokenProperty, tokenValue, variantProperty };
|
package/dist/index.d.ts
CHANGED
|
@@ -110,11 +110,18 @@ declare function getTokenValueParts(tokenValue: TokenValue): {
|
|
|
110
110
|
token: string;
|
|
111
111
|
};
|
|
112
112
|
declare function getCSSPropertiesForAlias(alias: string, aliases: Config['aliases']): string[];
|
|
113
|
+
declare function generateClassName(properties: Record<string, any>): string;
|
|
114
|
+
declare function createLonghandProperty(tokenProperty: TokenProperty, cssProperty: string): `--${string}`;
|
|
113
115
|
declare function parseProperty<T extends string>(str: T, options?: {
|
|
114
116
|
escapeSpecialChars?: boolean;
|
|
115
117
|
}): T;
|
|
116
118
|
declare function stringifyProperty<T extends string>(property: T): T;
|
|
119
|
+
declare function iterateAliasProperties(styleEntries: [key: string, value: any][], config: Pick<Config, 'aliases'>): Generator<[string, any, {
|
|
120
|
+
isCalc: boolean;
|
|
121
|
+
cssProperties: string[];
|
|
122
|
+
}]>;
|
|
123
|
+
declare const calcProperty: (property: string) => `--${string}`;
|
|
117
124
|
|
|
118
125
|
declare const mapShorthandToLonghands: Map<"flex" | "grid" | "all" | "border-block-color" | "border-block-style" | "border-block-width" | "border-inline-color" | "border-inline-style" | "border-inline-width" | "font-variant" | "animation" | "background" | "background-position" | "border" | "border-block" | "border-block-end" | "border-block-start" | "border-bottom" | "border-color" | "border-image" | "border-inline" | "border-inline-end" | "border-inline-start" | "border-left" | "border-radius" | "border-right" | "border-style" | "border-top" | "border-width" | "column-rule" | "columns" | "contain-intrinsic-size" | "container" | "flex-flow" | "font" | "gap" | "grid-area" | "grid-column" | "grid-row" | "grid-template" | "inset" | "inset-block" | "inset-inline" | "list-style" | "margin" | "margin-block" | "margin-inline" | "mask" | "mask-border" | "offset" | "outline" | "overflow" | "overscroll-behavior" | "padding" | "padding-block" | "padding-inline" | "place-content" | "place-items" | "place-self" | "scroll-margin" | "scroll-margin-block" | "scroll-margin-inline" | "scroll-padding" | "scroll-padding-block" | "scroll-padding-inline" | "scroll-timeline" | "text-decoration" | "text-emphasis" | "transition", string[]>;
|
|
119
126
|
|
|
120
|
-
export { type Aliases, ArbitraryValue, type CSSProperties, type CSSProperty, type Config, GridProperty, GridValue, type Theme, type ThemeModes, TokenProperty, TokenValue, VariantProperty, arbitraryValue, createConfig, getArbitrarySelector, getCSSPropertiesForAlias, getTokenPropertyName, getTokenPropertyParts, getTokenPropertySplit, getTokenValueParts, gridProperty, mapShorthandToLonghands, parseProperty, parsedTokenProperty, parsedVariantProperty, stringifyProperty, tokenProperty, tokenValue, variantProperty };
|
|
127
|
+
export { type Aliases, ArbitraryValue, type CSSProperties, type CSSProperty, type Config, GridProperty, GridValue, type Theme, type ThemeModes, TokenProperty, TokenValue, VariantProperty, arbitraryValue, calcProperty, createConfig, createLonghandProperty, generateClassName, getArbitrarySelector, getCSSPropertiesForAlias, getTokenPropertyName, getTokenPropertyParts, getTokenPropertySplit, getTokenValueParts, gridProperty, iterateAliasProperties, mapShorthandToLonghands, parseProperty, parsedTokenProperty, parsedVariantProperty, stringifyProperty, tokenProperty, tokenValue, variantProperty };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import hash from '@emotion/hash';
|
|
2
|
+
|
|
1
3
|
// src/config.ts
|
|
2
4
|
function createConfig(config) {
|
|
3
5
|
return config;
|
|
4
6
|
}
|
|
5
|
-
|
|
6
|
-
// src/common.ts
|
|
7
7
|
var gridPropertyRegex = /--_grid/;
|
|
8
8
|
var GridProperty = {
|
|
9
9
|
safeParse: (input) => validate(gridPropertyRegex, input)
|
|
@@ -109,6 +109,16 @@ function getTokenValueParts(tokenValue2) {
|
|
|
109
109
|
function getCSSPropertiesForAlias(alias, aliases) {
|
|
110
110
|
return (aliases == null ? void 0 : aliases[alias]) || [alias];
|
|
111
111
|
}
|
|
112
|
+
function generateClassName(properties) {
|
|
113
|
+
const entries = Object.entries(properties).map(([property, value]) => [property, String(value)]).sort(([keyA], [keyB]) => keyA.localeCompare(keyB));
|
|
114
|
+
const str = JSON.stringify(entries);
|
|
115
|
+
return `tk-${hash(str)}`;
|
|
116
|
+
}
|
|
117
|
+
function createLonghandProperty(tokenProperty2, cssProperty) {
|
|
118
|
+
const parts = getTokenPropertySplit(tokenProperty2);
|
|
119
|
+
const aliasRegex = new RegExp(`${parts.alias}$`);
|
|
120
|
+
return tokenProperty2.replace(aliasRegex, cssProperty);
|
|
121
|
+
}
|
|
112
122
|
var escapeSpecialCharsRegex = /[&#.:;>~*[\]=,"'()+{}]/g;
|
|
113
123
|
function parseProperty(str, options) {
|
|
114
124
|
const { escapeSpecialChars = true } = options || {};
|
|
@@ -122,6 +132,16 @@ function stringifyProperty(property) {
|
|
|
122
132
|
}
|
|
123
133
|
var encodeColon = (str) => str.replace(/:/g, ";");
|
|
124
134
|
var decodeColon = (str) => str.replace(/;/g, ":");
|
|
135
|
+
function* iterateAliasProperties(styleEntries, config) {
|
|
136
|
+
for (const [key, value] of styleEntries) {
|
|
137
|
+
const tokenProperty2 = key;
|
|
138
|
+
const parts = getTokenPropertySplit(tokenProperty2);
|
|
139
|
+
const cssProperties = getCSSPropertiesForAlias(parts.alias, config.aliases);
|
|
140
|
+
const isCalc = typeof value === "number" && value !== 0;
|
|
141
|
+
yield [key, value, { isCalc, cssProperties }];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
var calcProperty = (property) => property + "__calc";
|
|
125
145
|
|
|
126
146
|
// src/shorthands.ts
|
|
127
147
|
var shorthandsToLonghands = [
|
|
@@ -200,4 +220,4 @@ var replacedAmpersands = shorthandsToLonghands.map(
|
|
|
200
220
|
);
|
|
201
221
|
var mapShorthandToLonghands = new Map(replacedAmpersands);
|
|
202
222
|
|
|
203
|
-
export { ArbitraryValue, GridProperty, GridValue, TokenProperty, TokenValue, VariantProperty, arbitraryValue, createConfig, getArbitrarySelector, getCSSPropertiesForAlias, getTokenPropertyName, getTokenPropertyParts, getTokenPropertySplit, getTokenValueParts, gridProperty, mapShorthandToLonghands, parseProperty, parsedTokenProperty, parsedVariantProperty, stringifyProperty, tokenProperty, tokenValue, variantProperty };
|
|
223
|
+
export { ArbitraryValue, GridProperty, GridValue, TokenProperty, TokenValue, VariantProperty, arbitraryValue, calcProperty, createConfig, createLonghandProperty, generateClassName, getArbitrarySelector, getCSSPropertiesForAlias, getTokenPropertyName, getTokenPropertyParts, getTokenPropertySplit, getTokenValueParts, gridProperty, iterateAliasProperties, mapShorthandToLonghands, parseProperty, parsedTokenProperty, parsedVariantProperty, stringifyProperty, tokenProperty, tokenValue, variantProperty };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenami/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.78--canary.391.13466705179.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
"typecheck": "tsc --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@emotion/hash": "^0.9.2",
|
|
35
36
|
"csstype": "^3.1.2"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"tsup": "^7.0.0",
|
|
39
40
|
"typescript": "^5.1.3"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "e31fc8425e50eb5ba6e9ed9539d05a22774f609e"
|
|
42
43
|
}
|