calame 0.0.1
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/constants.d.ts +33 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +56 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/insertionFactory.d.ts +3 -0
- package/dist/insertionFactory.d.ts.map +1 -0
- package/dist/insertionFactory.js +9 -0
- package/dist/makeResetStyles.d.ts +7 -0
- package/dist/makeResetStyles.d.ts.map +1 -0
- package/dist/makeResetStyles.js +17 -0
- package/dist/makeStaticStyles.d.ts +6 -0
- package/dist/makeStaticStyles.d.ts.map +1 -0
- package/dist/makeStaticStyles.js +11 -0
- package/dist/makeStyles.d.ts +7 -0
- package/dist/makeStyles.d.ts.map +1 -0
- package/dist/makeStyles.js +32 -0
- package/dist/mergeClasses.d.ts +3 -0
- package/dist/mergeClasses.d.ts.map +1 -0
- package/dist/mergeClasses.js +63 -0
- package/dist/resolveStyleRulesForSlots.d.ts +6 -0
- package/dist/resolveStyleRulesForSlots.d.ts.map +1 -0
- package/dist/resolveStyleRulesForSlots.js +17 -0
- package/dist/runtime/compileAtomicCSSRule.d.ts +13 -0
- package/dist/runtime/compileAtomicCSSRule.d.ts.map +1 -0
- package/dist/runtime/compileAtomicCSSRule.js +41 -0
- package/dist/runtime/compileCSSRules.d.ts +2 -0
- package/dist/runtime/compileCSSRules.d.ts.map +1 -0
- package/dist/runtime/compileCSSRules.js +17 -0
- package/dist/runtime/compileKeyframeCSS.d.ts +4 -0
- package/dist/runtime/compileKeyframeCSS.d.ts.map +1 -0
- package/dist/runtime/compileKeyframeCSS.js +21 -0
- package/dist/runtime/compileResetCSSRules.d.ts +2 -0
- package/dist/runtime/compileResetCSSRules.d.ts.map +1 -0
- package/dist/runtime/compileResetCSSRules.js +23 -0
- package/dist/runtime/compileStaticCSS.d.ts +2 -0
- package/dist/runtime/compileStaticCSS.d.ts.map +1 -0
- package/dist/runtime/compileStaticCSS.js +6 -0
- package/dist/runtime/getStyleBucketName.d.ts +4 -0
- package/dist/runtime/getStyleBucketName.d.ts.map +1 -0
- package/dist/runtime/getStyleBucketName.js +30 -0
- package/dist/runtime/reduceToClassNameForSlots.d.ts +4 -0
- package/dist/runtime/reduceToClassNameForSlots.d.ts.map +1 -0
- package/dist/runtime/reduceToClassNameForSlots.js +37 -0
- package/dist/runtime/resolveResetStyleRules.d.ts +3 -0
- package/dist/runtime/resolveResetStyleRules.d.ts.map +1 -0
- package/dist/runtime/resolveResetStyleRules.js +108 -0
- package/dist/runtime/resolveStaticStyleRules.d.ts +3 -0
- package/dist/runtime/resolveStaticStyleRules.d.ts.map +1 -0
- package/dist/runtime/resolveStaticStyleRules.js +17 -0
- package/dist/runtime/resolveStyleRules.d.ts +9 -0
- package/dist/runtime/resolveStyleRules.d.ts.map +1 -0
- package/dist/runtime/resolveStyleRules.js +189 -0
- package/dist/runtime/shorthands.d.ts +2 -0
- package/dist/runtime/shorthands.d.ts.map +1 -0
- package/dist/runtime/shorthands.js +50 -0
- package/dist/runtime/stylis/globalPlugin.d.ts +3 -0
- package/dist/runtime/stylis/globalPlugin.d.ts.map +1 -0
- package/dist/runtime/stylis/globalPlugin.js +26 -0
- package/dist/runtime/stylis/isAtRuleElement.d.ts +3 -0
- package/dist/runtime/stylis/isAtRuleElement.d.ts.map +1 -0
- package/dist/runtime/stylis/isAtRuleElement.js +11 -0
- package/dist/runtime/stylis/prefixerPlugin.d.ts +4 -0
- package/dist/runtime/stylis/prefixerPlugin.d.ts.map +1 -0
- package/dist/runtime/stylis/prefixerPlugin.js +97 -0
- package/dist/runtime/stylis/rulesheetPlugin.d.ts +8 -0
- package/dist/runtime/stylis/rulesheetPlugin.d.ts.map +1 -0
- package/dist/runtime/stylis/rulesheetPlugin.js +13 -0
- package/dist/runtime/stylis/sortClassesInAtRulesPlugin.d.ts +3 -0
- package/dist/runtime/stylis/sortClassesInAtRulesPlugin.d.ts.map +1 -0
- package/dist/runtime/stylis/sortClassesInAtRulesPlugin.js +6 -0
- package/dist/runtime/utils/cssifyObject.d.ts +2 -0
- package/dist/runtime/utils/cssifyObject.d.ts.map +1 -0
- package/dist/runtime/utils/cssifyObject.js +20 -0
- package/dist/runtime/utils/generateCombinedMediaQuery.d.ts +2 -0
- package/dist/runtime/utils/generateCombinedMediaQuery.d.ts.map +1 -0
- package/dist/runtime/utils/generateCombinedMediaQuery.js +6 -0
- package/dist/runtime/utils/hashClassName.d.ts +10 -0
- package/dist/runtime/utils/hashClassName.d.ts.map +1 -0
- package/dist/runtime/utils/hashClassName.js +7 -0
- package/dist/runtime/utils/hashPropertyKey.d.ts +5 -0
- package/dist/runtime/utils/hashPropertyKey.d.ts.map +1 -0
- package/dist/runtime/utils/hashPropertyKey.js +21 -0
- package/dist/runtime/utils/hashSequence.d.ts +3 -0
- package/dist/runtime/utils/hashSequence.d.ts.map +1 -0
- package/dist/runtime/utils/hashSequence.js +11 -0
- package/dist/runtime/utils/hyphenateProperty.d.ts +2 -0
- package/dist/runtime/utils/hyphenateProperty.d.ts.map +1 -0
- package/dist/runtime/utils/hyphenateProperty.js +16 -0
- package/dist/runtime/utils/isContainerQuerySelector.d.ts +2 -0
- package/dist/runtime/utils/isContainerQuerySelector.d.ts.map +1 -0
- package/dist/runtime/utils/isContainerQuerySelector.js +3 -0
- package/dist/runtime/utils/isLayerSelector.d.ts +2 -0
- package/dist/runtime/utils/isLayerSelector.d.ts.map +1 -0
- package/dist/runtime/utils/isLayerSelector.js +3 -0
- package/dist/runtime/utils/isMediaQuerySelector.d.ts +2 -0
- package/dist/runtime/utils/isMediaQuerySelector.d.ts.map +1 -0
- package/dist/runtime/utils/isMediaQuerySelector.js +3 -0
- package/dist/runtime/utils/isNestedSelector.d.ts +2 -0
- package/dist/runtime/utils/isNestedSelector.d.ts.map +1 -0
- package/dist/runtime/utils/isNestedSelector.js +4 -0
- package/dist/runtime/utils/isObject.d.ts +2 -0
- package/dist/runtime/utils/isObject.d.ts.map +1 -0
- package/dist/runtime/utils/isObject.js +4 -0
- package/dist/runtime/utils/isResetValue.d.ts +2 -0
- package/dist/runtime/utils/isResetValue.d.ts.map +1 -0
- package/dist/runtime/utils/isResetValue.js +4 -0
- package/dist/runtime/utils/isSupportQuerySelector.d.ts +2 -0
- package/dist/runtime/utils/isSupportQuerySelector.d.ts.map +1 -0
- package/dist/runtime/utils/isSupportQuerySelector.js +3 -0
- package/dist/runtime/utils/normalizeNestedProperty.d.ts +2 -0
- package/dist/runtime/utils/normalizeNestedProperty.d.ts.map +1 -0
- package/dist/runtime/utils/normalizeNestedProperty.js +6 -0
- package/dist/runtime/utils/trimSelector.d.ts +2 -0
- package/dist/runtime/utils/trimSelector.d.ts.map +1 -0
- package/dist/runtime/utils/trimSelector.js +3 -0
- package/dist/runtime/utils/types.d.ts +7 -0
- package/dist/runtime/utils/types.d.ts.map +1 -0
- package/dist/runtime/utils/types.js +1 -0
- package/dist/runtime/warnings/logError.d.ts +2 -0
- package/dist/runtime/warnings/logError.d.ts.map +1 -0
- package/dist/runtime/warnings/logError.js +3 -0
- package/dist/runtime/warnings/warnAboutUnresolvedRule.d.ts +2 -0
- package/dist/runtime/warnings/warnAboutUnresolvedRule.d.ts.map +1 -0
- package/dist/runtime/warnings/warnAboutUnresolvedRule.js +13 -0
- package/dist/runtime/warnings/warnAboutUnsupportedProperties.d.ts +2 -0
- package/dist/runtime/warnings/warnAboutUnsupportedProperties.d.ts.map +1 -0
- package/dist/runtime/warnings/warnAboutUnsupportedProperties.js +7 -0
- package/dist/types.d.ts +355 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/package.json +29 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { LookupItem } from './types';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const DEFINITION_LOOKUP_TABLE: Record<string, LookupItem>;
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare const DATA_BUCKET_ATTR = "data-make-styles-bucket";
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare const DATA_PRIORITY_ATTR = "data-priority";
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare const HASH_PREFIX = "f";
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare const RESET_HASH_PREFIX = "r";
|
|
12
|
+
/** @internal */
|
|
13
|
+
export declare const SEQUENCE_HASH_LENGTH = 7;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare const SEQUENCE_PREFIX = "___";
|
|
16
|
+
/** @internal */
|
|
17
|
+
export declare const SEQUENCE_SIZE: number;
|
|
18
|
+
/** @internal */
|
|
19
|
+
export declare const LOOKUP_DEFINITIONS_INDEX = 0;
|
|
20
|
+
/** @internal */
|
|
21
|
+
export declare const LOOKUP_DIR_INDEX = 1;
|
|
22
|
+
/**
|
|
23
|
+
* CSS shorthands that are not supported — they must be expanded to longhands.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare const UNSUPPORTED_CSS_PROPERTIES: Record<string, 1>;
|
|
27
|
+
/**
|
|
28
|
+
* Sentinel value that resets a CSS property (removes the generated class).
|
|
29
|
+
* Do not use directly — use the `RESET` export from the public API.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare const RESET: "unset";
|
|
33
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,SAAS,CAAC;AAiBxD,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,4BAAgF,CAAC;AAIrH,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,4BAA4B,CAAC;AAE1D,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD,gBAAgB;AAChB,eAAO,MAAM,WAAW,MAAM,CAAC;AAE/B,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,gBAAgB;AAChB,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,gBAAgB;AAChB,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,gBAAgB;AAChB,eAAO,MAAM,aAAa,QAAgD,CAAC;AAG3E,gBAAgB;AAChB,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAW/C,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAA4D,OAAO,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// ----
|
|
2
|
+
// These constants are global and shared between Calame instances.
|
|
3
|
+
// Any change should happen only in a MAJOR version.
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
const __GLOBAL__ = typeof globalThis !== 'undefined' ? globalThis : window;
|
|
6
|
+
const __NAMESPACE_PREFIX__ = '@calame/';
|
|
7
|
+
function getGlobalVar(name, defaultValue) {
|
|
8
|
+
if (!__GLOBAL__[Symbol.for(__NAMESPACE_PREFIX__ + name)]) {
|
|
9
|
+
__GLOBAL__[Symbol.for(__NAMESPACE_PREFIX__ + name)] = defaultValue;
|
|
10
|
+
}
|
|
11
|
+
return __GLOBAL__[Symbol.for(__NAMESPACE_PREFIX__ + name)];
|
|
12
|
+
}
|
|
13
|
+
/** @internal */
|
|
14
|
+
export const DEFINITION_LOOKUP_TABLE = getGlobalVar('DEFINITION_LOOKUP_TABLE', {});
|
|
15
|
+
// ----
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const DATA_BUCKET_ATTR = 'data-make-styles-bucket';
|
|
18
|
+
/** @internal */
|
|
19
|
+
export const DATA_PRIORITY_ATTR = 'data-priority';
|
|
20
|
+
/** @internal */
|
|
21
|
+
export const HASH_PREFIX = 'f';
|
|
22
|
+
/** @internal */
|
|
23
|
+
export const RESET_HASH_PREFIX = 'r';
|
|
24
|
+
/** @internal */
|
|
25
|
+
export const SEQUENCE_HASH_LENGTH = 7;
|
|
26
|
+
/** @internal */
|
|
27
|
+
export const SEQUENCE_PREFIX = '___';
|
|
28
|
+
/** @internal */
|
|
29
|
+
export const SEQUENCE_SIZE = SEQUENCE_PREFIX.length + SEQUENCE_HASH_LENGTH;
|
|
30
|
+
// Indexes for values in LookupItem tuple
|
|
31
|
+
/** @internal */
|
|
32
|
+
export const LOOKUP_DEFINITIONS_INDEX = 0;
|
|
33
|
+
/** @internal */
|
|
34
|
+
export const LOOKUP_DIR_INDEX = 1;
|
|
35
|
+
/**
|
|
36
|
+
* CSS shorthands that are not supported — they must be expanded to longhands.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export const UNSUPPORTED_CSS_PROPERTIES = {
|
|
40
|
+
all: 1,
|
|
41
|
+
borderColor: 1,
|
|
42
|
+
borderStyle: 1,
|
|
43
|
+
borderWidth: 1,
|
|
44
|
+
borderBlock: 1,
|
|
45
|
+
borderBlockEnd: 1,
|
|
46
|
+
borderBlockStart: 1,
|
|
47
|
+
borderInline: 1,
|
|
48
|
+
borderInlineEnd: 1,
|
|
49
|
+
borderInlineStart: 1,
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Sentinel value that resets a CSS property (removes the generated class).
|
|
53
|
+
* Do not use directly — use the `RESET` export from the public API.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export const RESET = 'DO_NOT_USE_DIRECTLY: @calame/reset-value';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { makeStyles } from './makeStyles';
|
|
2
|
+
export type { MakeStylesOptions } from './makeStyles';
|
|
3
|
+
export { makeResetStyles } from './makeResetStyles';
|
|
4
|
+
export type { MakeResetStylesOptions } from './makeResetStyles';
|
|
5
|
+
export { makeStaticStyles } from './makeStaticStyles';
|
|
6
|
+
export type { MakeStaticStylesOptions } from './makeStaticStyles';
|
|
7
|
+
export { mergeClasses } from './mergeClasses';
|
|
8
|
+
export { RESET } from './constants';
|
|
9
|
+
export type { CalameRenderer, CalameInsertionFactory, CalameAnimation, CalameStylesCSSValue, CalameStylesCSSProperties, CalameStylesStrictCSSObject, CalameStylesCSSObjectCustom, CalameStyle, CalameResetStyle, CalameStaticStyle, CalameStaticStyles, StylesBySlots, StyleBucketName, CSSRulesByBucket, IsomorphicStyleSheet, } from './types';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,YAAY,EACR,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,EAC3B,2BAA2B,EAC3B,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertionFactory.d.ts","sourceRoot":"","sources":["../src/insertionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,sBAAsB,EAAkB,MAAM,SAAS,CAAC;AAExF,eAAO,MAAM,gBAAgB,EAAE,sBAS9B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CalameInsertionFactory, CalameRenderer, CalameResetStyle } from './types';
|
|
2
|
+
export interface MakeResetStylesOptions {
|
|
3
|
+
dir: 'ltr' | 'rtl';
|
|
4
|
+
renderer: CalameRenderer;
|
|
5
|
+
}
|
|
6
|
+
export declare function makeResetStyles(styles: CalameResetStyle, factory?: CalameInsertionFactory): (options: MakeResetStylesOptions) => string;
|
|
7
|
+
//# sourceMappingURL=makeResetStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeResetStyles.d.ts","sourceRoot":"","sources":["../src/makeResetStyles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,sBAAsB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE1G,MAAM,WAAW,sBAAsB;IACnC,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,eAAe,CAC3B,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,sBAAyC,aAQf,sBAAsB,KAAG,MAAM,CAarE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { insertionFactory } from './insertionFactory';
|
|
2
|
+
import { resolveResetStyleRules } from './runtime/resolveResetStyleRules';
|
|
3
|
+
export function makeResetStyles(styles, factory = insertionFactory) {
|
|
4
|
+
const insertStyles = factory();
|
|
5
|
+
let ltrClassName = null;
|
|
6
|
+
let rtlClassName = null;
|
|
7
|
+
let cssRules = null;
|
|
8
|
+
function computeClassName(options) {
|
|
9
|
+
const { dir, renderer } = options;
|
|
10
|
+
if (ltrClassName === null) {
|
|
11
|
+
[ltrClassName, rtlClassName, cssRules] = resolveResetStyleRules(styles, renderer.classNameHashSalt);
|
|
12
|
+
}
|
|
13
|
+
insertStyles(renderer, Array.isArray(cssRules) ? { r: cssRules } : cssRules);
|
|
14
|
+
return dir === 'ltr' ? ltrClassName : (rtlClassName ?? ltrClassName);
|
|
15
|
+
}
|
|
16
|
+
return computeClassName;
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CalameInsertionFactory, CalameRenderer, CalameStaticStyle } from './types';
|
|
2
|
+
export interface MakeStaticStylesOptions {
|
|
3
|
+
renderer: CalameRenderer;
|
|
4
|
+
}
|
|
5
|
+
export declare function makeStaticStyles(styles: CalameStaticStyle | CalameStaticStyle[], factory?: CalameInsertionFactory): (options: MakeStaticStylesOptions) => void;
|
|
6
|
+
//# sourceMappingURL=makeStaticStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeStaticStyles.d.ts","sourceRoot":"","sources":["../src/makeStaticStyles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEzF,MAAM,WAAW,uBAAuB;IACpC,QAAQ,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,EAC/C,OAAO,GAAE,sBAAyC,aAKhB,uBAAuB,KAAG,IAAI,CAMnE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { insertionFactory } from './insertionFactory';
|
|
2
|
+
import { resolveStaticStyleRules } from './runtime/resolveStaticStyleRules';
|
|
3
|
+
export function makeStaticStyles(styles, factory = insertionFactory) {
|
|
4
|
+
const insertStyles = factory();
|
|
5
|
+
const stylesSet = Array.isArray(styles) ? styles : [styles];
|
|
6
|
+
function useStaticStyles(options) {
|
|
7
|
+
// Static rules are inserted into the default bucket
|
|
8
|
+
insertStyles(options.renderer, { d: resolveStaticStyleRules(stylesSet) });
|
|
9
|
+
}
|
|
10
|
+
return useStaticStyles;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StylesBySlots, CalameInsertionFactory, CalameRenderer } from './types';
|
|
2
|
+
export interface MakeStylesOptions {
|
|
3
|
+
dir: 'ltr' | 'rtl';
|
|
4
|
+
renderer: CalameRenderer;
|
|
5
|
+
}
|
|
6
|
+
export declare function makeStyles<Slots extends string | number>(stylesBySlots: StylesBySlots<Slots>, factory?: CalameInsertionFactory): (options: MakeStylesOptions) => Record<Slots, string>;
|
|
7
|
+
//# sourceMappingURL=makeStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeStyles.d.ts","sourceRoot":"","sources":["../src/makeStyles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAyC,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5H,MAAM,WAAW,iBAAiB;IAC9B,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,UAAU,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACpD,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,EACnC,OAAO,GAAE,sBAAyC,aAUjB,iBAAiB,KAAG,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CA2B7E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { insertionFactory } from './insertionFactory';
|
|
2
|
+
import { resolveStyleRulesForSlots } from './resolveStyleRulesForSlots';
|
|
3
|
+
import { reduceToClassNameForSlots } from './runtime/reduceToClassNameForSlots';
|
|
4
|
+
export function makeStyles(stylesBySlots, factory = insertionFactory) {
|
|
5
|
+
const insertStyles = factory();
|
|
6
|
+
let classesMapBySlot = null;
|
|
7
|
+
let cssRules = null;
|
|
8
|
+
let ltrClassNamesForSlots = null;
|
|
9
|
+
let rtlClassNamesForSlots = null;
|
|
10
|
+
function computeClasses(options) {
|
|
11
|
+
const { dir, renderer } = options;
|
|
12
|
+
if (classesMapBySlot === null) {
|
|
13
|
+
[classesMapBySlot, cssRules] = resolveStyleRulesForSlots(stylesBySlots, renderer.classNameHashSalt);
|
|
14
|
+
}
|
|
15
|
+
const isLTR = dir === 'ltr';
|
|
16
|
+
if (isLTR) {
|
|
17
|
+
if (ltrClassNamesForSlots === null) {
|
|
18
|
+
ltrClassNamesForSlots = reduceToClassNameForSlots(classesMapBySlot, dir);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
if (rtlClassNamesForSlots === null) {
|
|
23
|
+
rtlClassNamesForSlots = reduceToClassNameForSlots(classesMapBySlot, dir);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
insertStyles(renderer, cssRules);
|
|
27
|
+
return isLTR
|
|
28
|
+
? ltrClassNamesForSlots
|
|
29
|
+
: rtlClassNamesForSlots;
|
|
30
|
+
}
|
|
31
|
+
return computeClasses;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeClasses.d.ts","sourceRoot":"","sources":["../src/mergeClasses.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAC;AAEpE,wBAAgB,YAAY,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DEFINITION_LOOKUP_TABLE, LOOKUP_DEFINITIONS_INDEX, LOOKUP_DIR_INDEX, SEQUENCE_PREFIX, SEQUENCE_SIZE, } from './constants';
|
|
2
|
+
import { hashSequence } from './runtime/utils/hashSequence';
|
|
3
|
+
import { reduceToClassName } from './runtime/reduceToClassNameForSlots';
|
|
4
|
+
// Cache of previously resolved merged class sequences to avoid redundant work
|
|
5
|
+
export const mergeClassesCachedResults = {};
|
|
6
|
+
export function mergeClasses() {
|
|
7
|
+
// arguments are parsed manually to avoid the extra loop Babel/TS add for rest params
|
|
8
|
+
/* eslint-disable prefer-rest-params */
|
|
9
|
+
let dir = null;
|
|
10
|
+
let resultClassName = '';
|
|
11
|
+
// Key used to look up / store in the cache
|
|
12
|
+
let sequenceMatch = '';
|
|
13
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
14
|
+
const className = arguments[i];
|
|
15
|
+
if (typeof className === 'string' && className !== '') {
|
|
16
|
+
const sequenceIndex = className.indexOf(SEQUENCE_PREFIX);
|
|
17
|
+
if (sequenceIndex === -1) {
|
|
18
|
+
// Plain class name (not from makeStyles) — pass through as-is
|
|
19
|
+
resultClassName += className + ' ';
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// Handles mixed strings like "ui-button ATOMIC_CLASSES"
|
|
23
|
+
if (sequenceIndex > 0) {
|
|
24
|
+
resultClassName += className.slice(0, sequenceIndex);
|
|
25
|
+
}
|
|
26
|
+
sequenceMatch += className.substr(sequenceIndex, SEQUENCE_SIZE);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// No atomic classes — just trim the trailing space and return
|
|
31
|
+
if (sequenceMatch === '') {
|
|
32
|
+
return resultClassName.slice(0, -1);
|
|
33
|
+
}
|
|
34
|
+
// Return cached result if this exact combination was seen before
|
|
35
|
+
const cached = mergeClassesCachedResults[sequenceMatch];
|
|
36
|
+
if (cached !== undefined) {
|
|
37
|
+
return resultClassName + cached;
|
|
38
|
+
}
|
|
39
|
+
// Collect the CSSClassesMap for every atomic sequence, in order
|
|
40
|
+
const sequenceMappings = [];
|
|
41
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
42
|
+
const className = arguments[i];
|
|
43
|
+
if (typeof className !== 'string' || className === '')
|
|
44
|
+
continue;
|
|
45
|
+
const sequenceIndex = className.indexOf(SEQUENCE_PREFIX);
|
|
46
|
+
if (sequenceIndex === -1)
|
|
47
|
+
continue;
|
|
48
|
+
const sequenceId = className.substr(sequenceIndex, SEQUENCE_SIZE);
|
|
49
|
+
const sequenceMapping = DEFINITION_LOOKUP_TABLE[sequenceId];
|
|
50
|
+
if (sequenceMapping) {
|
|
51
|
+
sequenceMappings.push(sequenceMapping[LOOKUP_DEFINITIONS_INDEX]);
|
|
52
|
+
dir = sequenceMapping[LOOKUP_DIR_INDEX];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Merge all maps left-to-right so later slots win (last-write-wins per property hash)
|
|
56
|
+
const resultClassesMap = Object.assign({}, ...sequenceMappings);
|
|
57
|
+
const [atomicClasses, classesMapHash] = reduceToClassName(resultClassesMap, dir);
|
|
58
|
+
const newSequenceHash = hashSequence(classesMapHash, dir);
|
|
59
|
+
const newClassName = newSequenceHash + ' ' + atomicClasses;
|
|
60
|
+
mergeClassesCachedResults[sequenceMatch] = newClassName;
|
|
61
|
+
DEFINITION_LOOKUP_TABLE[newSequenceHash] = [resultClassesMap, dir];
|
|
62
|
+
return resultClassName + newClassName;
|
|
63
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CSSClassesMapBySlot, CSSRulesByBucket, StylesBySlots } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Calls resolveStyleRules() for each slot. Also used by build-time transforms.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveStyleRulesForSlots<Slots extends string | number>(stylesBySlots: StylesBySlots<Slots>, classNameHashSalt?: string): [CSSClassesMapBySlot<Slots>, CSSRulesByBucket];
|
|
6
|
+
//# sourceMappingURL=resolveStyleRulesForSlots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveStyleRulesForSlots.d.ts","sourceRoot":"","sources":["../src/resolveStyleRulesForSlots.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AAErG;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACnE,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,EACnC,iBAAiB,GAAE,MAAW,GAC/B,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAgBhD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolveStyleRules } from './runtime/resolveStyleRules';
|
|
2
|
+
/**
|
|
3
|
+
* Calls resolveStyleRules() for each slot. Also used by build-time transforms.
|
|
4
|
+
*/
|
|
5
|
+
export function resolveStyleRulesForSlots(stylesBySlots, classNameHashSalt = '') {
|
|
6
|
+
const classesMapBySlot = {};
|
|
7
|
+
const cssRules = {};
|
|
8
|
+
// eslint-disable-next-line guard-for-in
|
|
9
|
+
for (const slotName in stylesBySlots) {
|
|
10
|
+
const [cssClassMap, cssRulesByBucket] = resolveStyleRules(stylesBySlots[slotName], classNameHashSalt);
|
|
11
|
+
classesMapBySlot[slotName] = cssClassMap;
|
|
12
|
+
Object.keys(cssRulesByBucket).forEach(bucketName => {
|
|
13
|
+
cssRules[bucketName] = (cssRules[bucketName] || []).concat(cssRulesByBucket[bucketName]);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return [classesMapBySlot, cssRules];
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AtRules } from './utils/types';
|
|
2
|
+
export interface CompileAtomicCSSOptions {
|
|
3
|
+
className: string;
|
|
4
|
+
selectors: string[];
|
|
5
|
+
property: string;
|
|
6
|
+
value: number | string | Array<number | string>;
|
|
7
|
+
rtlClassName?: string;
|
|
8
|
+
rtlProperty?: string;
|
|
9
|
+
rtlValue?: number | string | Array<number | string>;
|
|
10
|
+
}
|
|
11
|
+
export declare function normalizePseudoSelector(pseudoSelector: string): string;
|
|
12
|
+
export declare function compileAtomicCSSRule(options: CompileAtomicCSSOptions, atRules: AtRules): [string?, string?];
|
|
13
|
+
//# sourceMappingURL=compileAtomicCSSRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileAtomicCSSRule.d.ts","sourceRoot":"","sources":["../../src/runtime/compileAtomicCSSRule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,WAAW,uBAAuB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACvD;AAID,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEtE;AAcD,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,OAAO,GACjB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CA0BpB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { hyphenateProperty } from './utils/hyphenateProperty';
|
|
2
|
+
import { normalizeNestedProperty } from './utils/normalizeNestedProperty';
|
|
3
|
+
import { compileCSSRules } from './compileCSSRules';
|
|
4
|
+
const PSEUDO_SELECTOR_REGEX = /,( *[^ &])/g;
|
|
5
|
+
export function normalizePseudoSelector(pseudoSelector) {
|
|
6
|
+
return '&' + normalizeNestedProperty(pseudoSelector.replace(PSEUDO_SELECTOR_REGEX, ',&$1'));
|
|
7
|
+
}
|
|
8
|
+
function createCSSRule(classNameSelector, cssDeclaration, pseudos) {
|
|
9
|
+
let cssRule = cssDeclaration;
|
|
10
|
+
if (pseudos.length > 0) {
|
|
11
|
+
cssRule = pseudos.reduceRight((acc, selector) => {
|
|
12
|
+
return `${normalizePseudoSelector(selector)} { ${acc} }`;
|
|
13
|
+
}, cssDeclaration);
|
|
14
|
+
}
|
|
15
|
+
return `${classNameSelector}{${cssRule}}`;
|
|
16
|
+
}
|
|
17
|
+
export function compileAtomicCSSRule(options, atRules) {
|
|
18
|
+
const { className, selectors, property, rtlClassName, rtlProperty, rtlValue, value } = options;
|
|
19
|
+
const { container, layer, media, supports } = atRules;
|
|
20
|
+
const classNameSelector = `.${className}`;
|
|
21
|
+
const cssDeclaration = Array.isArray(value)
|
|
22
|
+
? `${value.map(v => `${hyphenateProperty(property)}: ${v}`).join(';')};`
|
|
23
|
+
: `${hyphenateProperty(property)}: ${value};`;
|
|
24
|
+
let cssRule = createCSSRule(classNameSelector, cssDeclaration, selectors);
|
|
25
|
+
if (rtlProperty && rtlClassName) {
|
|
26
|
+
const rtlClassNameSelector = `.${rtlClassName}`;
|
|
27
|
+
const rtlCSSDeclaration = Array.isArray(rtlValue)
|
|
28
|
+
? `${rtlValue.map(v => `${hyphenateProperty(rtlProperty)}: ${v}`).join(';')};`
|
|
29
|
+
: `${hyphenateProperty(rtlProperty)}: ${rtlValue};`;
|
|
30
|
+
cssRule += createCSSRule(rtlClassNameSelector, rtlCSSDeclaration, selectors);
|
|
31
|
+
}
|
|
32
|
+
if (media)
|
|
33
|
+
cssRule = `@media ${media} { ${cssRule} }`;
|
|
34
|
+
if (layer)
|
|
35
|
+
cssRule = `@layer ${layer} { ${cssRule} }`;
|
|
36
|
+
if (supports)
|
|
37
|
+
cssRule = `@supports ${supports} { ${cssRule} }`;
|
|
38
|
+
if (container)
|
|
39
|
+
cssRule = `@container ${container} { ${cssRule} }`;
|
|
40
|
+
return compileCSSRules(cssRule, true);
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileCSSRules.d.ts","sourceRoot":"","sources":["../../src/runtime/compileCSSRules.ts"],"names":[],"mappings":"AASA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,GAAG,MAAM,EAAE,CAezF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { compile, middleware, rulesheet, serialize, stringify } from 'stylis';
|
|
2
|
+
import { globalPlugin } from './stylis/globalPlugin';
|
|
3
|
+
import { prefixerPlugin } from './stylis/prefixerPlugin';
|
|
4
|
+
import { sortClassesInAtRulesPlugin } from './stylis/sortClassesInAtRulesPlugin';
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
6
|
+
function noop() { }
|
|
7
|
+
export function compileCSSRules(cssRules, sortClassesInAtRules) {
|
|
8
|
+
const rules = [];
|
|
9
|
+
serialize(compile(cssRules), middleware([
|
|
10
|
+
globalPlugin,
|
|
11
|
+
sortClassesInAtRules ? sortClassesInAtRulesPlugin : noop,
|
|
12
|
+
prefixerPlugin,
|
|
13
|
+
stringify,
|
|
14
|
+
rulesheet(rule => rules.push(rule)),
|
|
15
|
+
]));
|
|
16
|
+
return rules;
|
|
17
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CalameAnimation } from '../types';
|
|
2
|
+
export declare function compileKeyframeRule(keyframeObject: CalameAnimation): string;
|
|
3
|
+
export declare function compileKeyframesCSS(keyframeName: string, keyframeCSS: string): string[];
|
|
4
|
+
//# sourceMappingURL=compileKeyframeCSS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileKeyframeCSS.d.ts","sourceRoot":"","sources":["../../src/runtime/compileKeyframeCSS.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhD,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,eAAe,GAAG,MAAM,CAO3E;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAcvF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { compile, middleware, serialize, rulesheet, stringify } from 'stylis';
|
|
2
|
+
import { prefixerPlugin } from './stylis/prefixerPlugin';
|
|
3
|
+
import { cssifyObject } from './utils/cssifyObject';
|
|
4
|
+
export function compileKeyframeRule(keyframeObject) {
|
|
5
|
+
let css = '';
|
|
6
|
+
// eslint-disable-next-line guard-for-in
|
|
7
|
+
for (const percentage in keyframeObject) {
|
|
8
|
+
css += `${percentage}{${cssifyObject(keyframeObject[percentage])}}`;
|
|
9
|
+
}
|
|
10
|
+
return css;
|
|
11
|
+
}
|
|
12
|
+
export function compileKeyframesCSS(keyframeName, keyframeCSS) {
|
|
13
|
+
const cssRule = `@keyframes ${keyframeName} {${keyframeCSS}}`;
|
|
14
|
+
const rules = [];
|
|
15
|
+
serialize(compile(cssRule), middleware([
|
|
16
|
+
stringify,
|
|
17
|
+
prefixerPlugin,
|
|
18
|
+
rulesheet(rule => rules.push(rule)),
|
|
19
|
+
]));
|
|
20
|
+
return rules;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileResetCSSRules.d.ts","sourceRoot":"","sources":["../../src/runtime/compileResetCSSRules.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAqB3E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { compile, middleware, serialize, stringify } from 'stylis';
|
|
2
|
+
import { globalPlugin } from './stylis/globalPlugin';
|
|
3
|
+
import { isAtRuleElement } from './stylis/isAtRuleElement';
|
|
4
|
+
import { prefixerPlugin } from './stylis/prefixerPlugin';
|
|
5
|
+
import { rulesheetPlugin } from './stylis/rulesheetPlugin';
|
|
6
|
+
export function compileResetCSSRules(cssRules) {
|
|
7
|
+
const rules = [];
|
|
8
|
+
const atRules = [];
|
|
9
|
+
serialize(compile(cssRules), middleware([
|
|
10
|
+
globalPlugin,
|
|
11
|
+
prefixerPlugin,
|
|
12
|
+
stringify,
|
|
13
|
+
rulesheetPlugin((element, rule) => {
|
|
14
|
+
if (isAtRuleElement(element)) {
|
|
15
|
+
atRules.push(rule);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
rules.push(rule);
|
|
19
|
+
}
|
|
20
|
+
}),
|
|
21
|
+
]));
|
|
22
|
+
return [rules, atRules];
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileStaticCSS.d.ts","sourceRoot":"","sources":["../../src/runtime/compileStaticCSS.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAGzF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStyleBucketName.d.ts","sourceRoot":"","sources":["../../src/runtime/getStyleBucketName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAgB7C,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe,CAkBzF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a slice of the pseudo name to its bucket. Using a substring avoids
|
|
3
|
+
* collisions between e.g. `:focus-visible` and `:focus`.
|
|
4
|
+
*/
|
|
5
|
+
const pseudosMap = {
|
|
6
|
+
'us-w': 'w', // :focus-within
|
|
7
|
+
'us-v': 'i', // :focus-visible
|
|
8
|
+
nk: 'l', // :link
|
|
9
|
+
si: 'v', // :visited
|
|
10
|
+
cu: 'f', // :focus
|
|
11
|
+
ve: 'h', // :hover
|
|
12
|
+
ti: 'a', // :active
|
|
13
|
+
};
|
|
14
|
+
export function getStyleBucketName(selectors, atRules) {
|
|
15
|
+
if (atRules.media)
|
|
16
|
+
return 'm';
|
|
17
|
+
if (atRules.layer || atRules.supports)
|
|
18
|
+
return 't';
|
|
19
|
+
if (atRules.container)
|
|
20
|
+
return 'c';
|
|
21
|
+
if (selectors.length > 0) {
|
|
22
|
+
const normalizedPseudo = selectors[0].trim();
|
|
23
|
+
if (normalizedPseudo.charCodeAt(0) === 58 /* ":" */) {
|
|
24
|
+
return (pseudosMap[normalizedPseudo.slice(4, 8)] ||
|
|
25
|
+
pseudosMap[normalizedPseudo.slice(3, 5)] ||
|
|
26
|
+
'd');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return 'd';
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CSSClassesMapBySlot, CSSClassesMap } from '../types';
|
|
2
|
+
export declare function reduceToClassName(classMap: CSSClassesMap, dir: 'ltr' | 'rtl'): [string, string];
|
|
3
|
+
export declare function reduceToClassNameForSlots<Slots extends string | number>(classesMapBySlot: CSSClassesMapBySlot<Slots>, dir: 'ltr' | 'rtl'): Record<Slots, string>;
|
|
4
|
+
//# sourceMappingURL=reduceToClassNameForSlots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reduceToClassNameForSlots.d.ts","sourceRoot":"","sources":["../../src/runtime/reduceToClassNameForSlots.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAc,MAAM,UAAU,CAAC;AAE/E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,GAAG,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAwB/F;AAED,wBAAgB,yBAAyB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACnE,gBAAgB,EAAE,mBAAmB,CAAC,KAAK,CAAC,EAC5C,GAAG,EAAE,KAAK,GAAG,KAAK,GACnB,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAoBvB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DEFINITION_LOOKUP_TABLE } from '../constants';
|
|
2
|
+
import { hashSequence } from './utils/hashSequence';
|
|
3
|
+
export function reduceToClassName(classMap, dir) {
|
|
4
|
+
let classString = '';
|
|
5
|
+
let hashString = '';
|
|
6
|
+
// eslint-disable-next-line guard-for-in
|
|
7
|
+
for (const propertyHash in classMap) {
|
|
8
|
+
const classNameMapping = classMap[propertyHash];
|
|
9
|
+
if (classNameMapping === 0) {
|
|
10
|
+
hashString += propertyHash + ' ';
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const hasRTLClassName = Array.isArray(classNameMapping);
|
|
14
|
+
const className = dir === 'rtl'
|
|
15
|
+
? (hasRTLClassName ? classNameMapping[1] : classNameMapping) + ' '
|
|
16
|
+
: (hasRTLClassName ? classNameMapping[0] : classNameMapping) + ' ';
|
|
17
|
+
classString += className;
|
|
18
|
+
hashString += className;
|
|
19
|
+
}
|
|
20
|
+
return [classString.slice(0, -1), hashString.slice(0, -1)];
|
|
21
|
+
}
|
|
22
|
+
export function reduceToClassNameForSlots(classesMapBySlot, dir) {
|
|
23
|
+
const classNamesForSlots = {};
|
|
24
|
+
// eslint-disable-next-line guard-for-in
|
|
25
|
+
for (const slotName in classesMapBySlot) {
|
|
26
|
+
const [slotClasses, slotClassesHash] = reduceToClassName(classesMapBySlot[slotName], dir);
|
|
27
|
+
if (slotClassesHash === '') {
|
|
28
|
+
classNamesForSlots[slotName] = '';
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const sequenceHash = hashSequence(slotClassesHash, dir);
|
|
32
|
+
const resultSlotClasses = sequenceHash + (slotClasses === '' ? '' : ' ' + slotClasses);
|
|
33
|
+
DEFINITION_LOOKUP_TABLE[sequenceHash] = [classesMapBySlot[slotName], dir];
|
|
34
|
+
classNamesForSlots[slotName] = resultSlotClasses;
|
|
35
|
+
}
|
|
36
|
+
return classNamesForSlots;
|
|
37
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CSSRulesByBucket, CalameResetStyle } from '../types';
|
|
2
|
+
export declare function resolveResetStyleRules(styles: CalameResetStyle, classNameHashSalt?: string): [string, string | null, CSSRulesByBucket | string[]];
|
|
3
|
+
//# sourceMappingURL=resolveResetStyleRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveResetStyleRules.d.ts","sourceRoot":"","sources":["../../src/runtime/resolveResetStyleRules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAC;AAgHpF,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,gBAAgB,EACxB,iBAAiB,GAAE,MAAW,GAC/B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAAC,CAsBtD"}
|