@craft-ts/style 0.7.0-beta.15
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/package.json +41 -0
- package/src/index.d.ts +18 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +18 -0
- package/src/index.js.map +1 -0
- package/src/lib/axes/define.d.ts +115 -0
- package/src/lib/axes/define.d.ts.map +1 -0
- package/src/lib/axes/define.js +81 -0
- package/src/lib/axes/define.js.map +1 -0
- package/src/lib/axes/index.d.ts +4 -0
- package/src/lib/axes/index.d.ts.map +1 -0
- package/src/lib/axes/index.js +4 -0
- package/src/lib/axes/index.js.map +1 -0
- package/src/lib/axes/standard.d.ts +85 -0
- package/src/lib/axes/standard.d.ts.map +1 -0
- package/src/lib/axes/standard.js +109 -0
- package/src/lib/axes/standard.js.map +1 -0
- package/src/lib/axes/types.d.ts +67 -0
- package/src/lib/axes/types.d.ts.map +1 -0
- package/src/lib/axes/types.js +21 -0
- package/src/lib/axes/types.js.map +1 -0
- package/src/lib/css-vars.d.ts +100 -0
- package/src/lib/css-vars.d.ts.map +1 -0
- package/src/lib/css-vars.js +96 -0
- package/src/lib/css-vars.js.map +1 -0
- package/src/lib/kinds.d.ts +84 -0
- package/src/lib/kinds.d.ts.map +1 -0
- package/src/lib/kinds.js +44 -0
- package/src/lib/kinds.js.map +1 -0
- package/src/lib/obligations.d.ts +99 -0
- package/src/lib/obligations.d.ts.map +1 -0
- package/src/lib/obligations.js +69 -0
- package/src/lib/obligations.js.map +1 -0
- package/src/lib/props/factory.d.ts +61 -0
- package/src/lib/props/factory.d.ts.map +1 -0
- package/src/lib/props/factory.js +35 -0
- package/src/lib/props/factory.js.map +1 -0
- package/src/lib/props/generated.d.ts +974 -0
- package/src/lib/props/generated.d.ts.map +1 -0
- package/src/lib/props/generated.js +2478 -0
- package/src/lib/props/generated.js.map +1 -0
- package/src/lib/props/index.d.ts +37 -0
- package/src/lib/props/index.d.ts.map +1 -0
- package/src/lib/props/index.js +27 -0
- package/src/lib/props/index.js.map +1 -0
- package/src/lib/styles.d.ts +201 -0
- package/src/lib/styles.d.ts.map +1 -0
- package/src/lib/styles.js +247 -0
- package/src/lib/styles.js.map +1 -0
- package/src/lib/tokens/index.d.ts +4 -0
- package/src/lib/tokens/index.d.ts.map +1 -0
- package/src/lib/tokens/index.js +4 -0
- package/src/lib/tokens/index.js.map +1 -0
- package/src/lib/tokens/palette.d.ts +97 -0
- package/src/lib/tokens/palette.d.ts.map +1 -0
- package/src/lib/tokens/palette.js +61 -0
- package/src/lib/tokens/palette.js.map +1 -0
- package/src/lib/tokens/scales.d.ts +47 -0
- package/src/lib/tokens/scales.d.ts.map +1 -0
- package/src/lib/tokens/scales.js +51 -0
- package/src/lib/tokens/scales.js.map +1 -0
- package/src/lib/tokens/units.d.ts +114 -0
- package/src/lib/tokens/units.d.ts.map +1 -0
- package/src/lib/tokens/units.js +54 -0
- package/src/lib/tokens/units.js.map +1 -0
- package/src/plugin/emit.d.ts +64 -0
- package/src/plugin/emit.d.ts.map +1 -0
- package/src/plugin/emit.js +134 -0
- package/src/plugin/emit.js.map +1 -0
- package/src/plugin/vite.d.ts +66 -0
- package/src/plugin/vite.d.ts.map +1 -0
- package/src/plugin/vite.js +150 -0
- package/src/plugin/vite.js.map +1 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the generated table is made of.
|
|
3
|
+
*
|
|
4
|
+
* Two shapes, and no third: a closed keyword set is a namespace object, a
|
|
5
|
+
* typed value is a callable. A typo is `Property 'inlineFlexx' does not exist`,
|
|
6
|
+
* never a CSS rule the browser drops on the floor.
|
|
7
|
+
*
|
|
8
|
+
* No signature here takes `string`. That is not a convention to remember, it is
|
|
9
|
+
* what `props.spec.ts` measures generically over every export of the generated
|
|
10
|
+
* file — the only form of the check that survives a regeneration.
|
|
11
|
+
*/
|
|
12
|
+
import type { AngleValue, ColorValue, CssStringValue, IdentValue, IntegerValue, LengthPercentageValue, LengthValue, NumberValue, PercentValue, TimeValue, UrlValue } from '../tokens/units.ts';
|
|
13
|
+
export interface Declaration {
|
|
14
|
+
readonly property: string;
|
|
15
|
+
readonly value: string;
|
|
16
|
+
/** Carried over from `unsafeLength`: the debt travels with the declaration. */
|
|
17
|
+
readonly unproven: string;
|
|
18
|
+
}
|
|
19
|
+
export type TerminalName = 'length' | 'percentage' | 'lengthPercentage' | 'number' | 'integer' | 'angle' | 'time' | 'color' | 'ident' | 'string' | 'url';
|
|
20
|
+
export interface TerminalValues {
|
|
21
|
+
readonly length: LengthValue;
|
|
22
|
+
readonly percentage: PercentValue;
|
|
23
|
+
readonly lengthPercentage: LengthPercentageValue;
|
|
24
|
+
readonly number: NumberValue;
|
|
25
|
+
readonly integer: IntegerValue;
|
|
26
|
+
readonly angle: AngleValue;
|
|
27
|
+
readonly time: TimeValue;
|
|
28
|
+
readonly color: ColorValue;
|
|
29
|
+
readonly ident: IdentValue;
|
|
30
|
+
readonly string: CssStringValue;
|
|
31
|
+
readonly url: UrlValue;
|
|
32
|
+
}
|
|
33
|
+
/** `min-content` reads as `minContent`; the CSS keyword itself is never retyped. */
|
|
34
|
+
export type Camel<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<Camel<Tail>>}` : Name;
|
|
35
|
+
export type KeywordMembers<Keywords extends string> = {
|
|
36
|
+
readonly [Keyword in Keywords as Camel<Keyword>]: Declaration;
|
|
37
|
+
};
|
|
38
|
+
export type ValueProp<Terminals extends TerminalName, Keywords extends string> = ((value: TerminalValues[Terminals]) => Declaration) & KeywordMembers<Keywords>;
|
|
39
|
+
export declare const declaration: (property: string, value: string) => Declaration;
|
|
40
|
+
export declare function keywordProp<const Keywords extends readonly string[]>(property: string, keywords: Keywords): KeywordMembers<Keywords[number]>;
|
|
41
|
+
export declare function valueProp<const Terminals extends readonly TerminalName[], const Keywords extends readonly string[]>(property: string, _terminals: Terminals, keywords: Keywords): ValueProp<Terminals[number], Keywords[number]>;
|
|
42
|
+
declare const PROPERTY_NAME: unique symbol;
|
|
43
|
+
/**
|
|
44
|
+
* A property *name*, for the places that name a property instead of setting it.
|
|
45
|
+
*
|
|
46
|
+
* The brand is **required**, not optional: an optional phantom on a string base
|
|
47
|
+
* brands nothing, and `global.inherit('whatever')` would compile.
|
|
48
|
+
*/
|
|
49
|
+
export type PropertyToken<Name extends string = string> = Name & {
|
|
50
|
+
readonly [PROPERTY_NAME]: true;
|
|
51
|
+
};
|
|
52
|
+
export declare const propertyName: <const Name extends string>(name: Name) => PropertyToken<Name>;
|
|
53
|
+
export declare const global: {
|
|
54
|
+
readonly inherit: (property: PropertyToken) => Declaration;
|
|
55
|
+
readonly initial: (property: PropertyToken) => Declaration;
|
|
56
|
+
readonly unset: (property: PropertyToken) => Declaration;
|
|
57
|
+
readonly revert: (property: PropertyToken) => Declaration;
|
|
58
|
+
readonly revertLayer: (property: PropertyToken) => Declaration;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../../../libs/style/src/lib/props/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,YAAY,GACZ,kBAAkB,GAClB,QAAQ,GACR,SAAS,GACT,OAAO,GACP,M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K,CAAC,QAAQ,SAAS,SAAS,MAAM,EAAE,EAClE,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAElC;AAED,wBAAgB,SAAS,CACvB,KAAK,CAAC,SAAS,SAAS,SAAS,YAAY,EAAE,EAC/C,KAAK,CAAC,QAAQ,SAAS,SAAS,MAAM,EAAE,EAExC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,QAAQ,GACjB,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAUhD;AAED,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,GAAG;IAC/D,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,KAAK,CAAC,IAAI,SAAS,MAAM,EACpD,MAAM,IAAI,KACT,aAAa,CAAC,IAAI,CAAgC,CAAC;AAYtD,eAAO,MAAM,MAAM;iCAHiC,aAAa;iCAAb,aAAa;+BAAb,aAAa;gCAAb,aAAa;qCAAb,aAAa;CASvD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const camel = (name) => name.replace(/-([a-z0-9])/g, (_, char) => char.toUpperCase());
|
|
2
|
+
export const declaration = (property, value) => ({
|
|
3
|
+
property,
|
|
4
|
+
value,
|
|
5
|
+
unproven: '',
|
|
6
|
+
});
|
|
7
|
+
const members = (property, keywords) => Object.fromEntries(keywords.map((keyword) => [camel(keyword), declaration(property, keyword)]));
|
|
8
|
+
export function keywordProp(property, keywords) {
|
|
9
|
+
return members(property, keywords);
|
|
10
|
+
}
|
|
11
|
+
export function valueProp(property, _terminals, keywords) {
|
|
12
|
+
const set = (value) => ({
|
|
13
|
+
property,
|
|
14
|
+
value: value.css,
|
|
15
|
+
unproven: value.unproven,
|
|
16
|
+
});
|
|
17
|
+
return Object.assign(set, members(property, keywords));
|
|
18
|
+
}
|
|
19
|
+
export const propertyName = (name) => name;
|
|
20
|
+
/**
|
|
21
|
+
* The CSS-wide keywords, as tokens applied to a named property.
|
|
22
|
+
*
|
|
23
|
+
* `global.inherit(prop.color)` and never `color('inherit')`: a helper that
|
|
24
|
+
* accepted the literal would be a helper that accepts a string, and the
|
|
25
|
+
* conformance spec would be right to fail it.
|
|
26
|
+
*/
|
|
27
|
+
const globalValue = (keyword) => (property) => declaration(property, keyword);
|
|
28
|
+
export const global = {
|
|
29
|
+
inherit: globalValue('inherit'),
|
|
30
|
+
initial: globalValue('initial'),
|
|
31
|
+
unset: globalValue('unset'),
|
|
32
|
+
revert: globalValue('revert'),
|
|
33
|
+
revertLayer: globalValue('revert-layer'),
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../../libs/style/src/lib/props/factory.ts"],"names":[],"mappings":"AA2EA,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CACrC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,KAAa,EAAe,EAAE,CAAC,CAAC;IAC5E,QAAQ;IACR,KAAK;IACL,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,CACd,QAAgB,EAChB,QAA2B,EACE,EAAE,CAC/B,MAAM,CAAC,WAAW,CAChB,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAC5E,CAAC;AAEJ,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,QAAkB;IAElB,OAAO,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAqC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,SAAS,CAIvB,QAAgB,EAChB,UAAqB,EACrB,QAAkB;IAElB,MAAM,GAAG,GAAG,CAAC,KAA0D,EAAE,EAAE,CAAC,CAAC;QAC3E,QAAQ;QACR,KAAK,EAAE,KAAK,CAAC,GAAG;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAClB,GAAG,EACH,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACiC,CAAC;AACjE,CAAC;AAcD,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAU,EACW,EAAE,CAAC,IAA2B,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC,QAAuB,EAAE,EAAE,CACnE,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAEjC,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC;IAC/B,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC;IAC/B,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC;IAC3B,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC,cAAc,CAAC;CAChC,CAAC","sourcesContent":["/**\n * What the generated table is made of.\n *\n * Two shapes, and no third: a closed keyword set is a namespace object, a\n * typed value is a callable. A typo is `Property 'inlineFlexx' does not exist`,\n * never a CSS rule the browser drops on the floor.\n *\n * No signature here takes `string`. That is not a convention to remember, it is\n * what `props.spec.ts` measures generically over every export of the generated\n * file — the only form of the check that survives a regeneration.\n */\nimport type {\n AngleValue,\n ColorValue,\n CssStringValue,\n IdentValue,\n IntegerValue,\n LengthPercentageValue,\n LengthValue,\n NumberValue,\n PercentValue,\n TimeValue,\n UrlValue,\n} from '../tokens/units.ts';\n\nexport interface Declaration {\n readonly property: string;\n readonly value: string;\n /** Carried over from `unsafeLength`: the debt travels with the declaration. */\n readonly unproven: string;\n}\n\nexport type TerminalName =\n | 'length'\n | 'percentage'\n | 'lengthPercentage'\n | 'number'\n | 'integer'\n | 'angle'\n | 'time'\n | 'color'\n | 'ident'\n | 'string'\n | 'url';\n\nexport interface TerminalValues {\n readonly length: LengthValue;\n readonly percentage: PercentValue;\n readonly lengthPercentage: LengthPercentageValue;\n readonly number: NumberValue;\n readonly integer: IntegerValue;\n readonly angle: AngleValue;\n readonly time: TimeValue;\n readonly color: ColorValue;\n readonly ident: IdentValue;\n readonly string: CssStringValue;\n readonly url: UrlValue;\n}\n\n/** `min-content` reads as `minContent`; the CSS keyword itself is never retyped. */\nexport type Camel<Name extends string> =\n Name extends `${infer Head}-${infer Tail}`\n ? `${Head}${Capitalize<Camel<Tail>>}`\n : Name;\n\nexport type KeywordMembers<Keywords extends string> = {\n readonly [Keyword in Keywords as Camel<Keyword>]: Declaration;\n};\n\nexport type ValueProp<\n Terminals extends TerminalName,\n Keywords extends string,\n> = ((value: TerminalValues[Terminals]) => Declaration) &\n KeywordMembers<Keywords>;\n\nconst camel = (name: string): string =>\n name.replace(/-([a-z0-9])/g, (_, char: string) => char.toUpperCase());\n\nexport const declaration = (property: string, value: string): Declaration => ({\n property,\n value,\n unproven: '',\n});\n\nconst members = (\n property: string,\n keywords: readonly string[],\n): Record<string, Declaration> =>\n Object.fromEntries(\n keywords.map((keyword) => [camel(keyword), declaration(property, keyword)]),\n );\n\nexport function keywordProp<const Keywords extends readonly string[]>(\n property: string,\n keywords: Keywords,\n): KeywordMembers<Keywords[number]> {\n return members(property, keywords) as KeywordMembers<Keywords[number]>;\n}\n\nexport function valueProp<\n const Terminals extends readonly TerminalName[],\n const Keywords extends readonly string[],\n>(\n property: string,\n _terminals: Terminals,\n keywords: Keywords,\n): ValueProp<Terminals[number], Keywords[number]> {\n const set = (value: { readonly css: string; readonly unproven: string }) => ({\n property,\n value: value.css,\n unproven: value.unproven,\n });\n return Object.assign(\n set,\n members(property, keywords),\n ) as unknown as ValueProp<Terminals[number], Keywords[number]>;\n}\n\ndeclare const PROPERTY_NAME: unique symbol;\n\n/**\n * A property *name*, for the places that name a property instead of setting it.\n *\n * The brand is **required**, not optional: an optional phantom on a string base\n * brands nothing, and `global.inherit('whatever')` would compile.\n */\nexport type PropertyToken<Name extends string = string> = Name & {\n readonly [PROPERTY_NAME]: true;\n};\n\nexport const propertyName = <const Name extends string>(\n name: Name,\n): PropertyToken<Name> => name as PropertyToken<Name>;\n\n/**\n * The CSS-wide keywords, as tokens applied to a named property.\n *\n * `global.inherit(prop.color)` and never `color('inherit')`: a helper that\n * accepted the literal would be a helper that accepts a string, and the\n * conformance spec would be right to fail it.\n */\nconst globalValue = (keyword: string) => (property: PropertyToken) =>\n declaration(property, keyword);\n\nexport const global = {\n inherit: globalValue('inherit'),\n initial: globalValue('initial'),\n unset: globalValue('unset'),\n revert: globalValue('revert'),\n revertLayer: globalValue('revert-layer'),\n} as const;\n"]}
|