@hypergood/css-core 0.1.0 → 0.1.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/runtime.ts"],"sourcesContent":["export * from \"./runtime.js\";\n","import type { CSSProperties } from \"./css-properties.js\";\n\nexport type { CSSProperties, CSSValue } from \"./css-properties.js\";\n\n/**\n * The style object accepted by `styled()`: top-level CSS properties plus the\n * optional `variants` and `defaultVariants` keys.\n */\nexport type StyledStyleObject = CSSProperties & {\n variants?: Record<string, Record<string, CSSProperties>>;\n defaultVariants?: Record<string, string | number | boolean>;\n};\n\nexport function css(styleObject: CSSProperties): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function keyframes(styleObject: Record<string, CSSProperties>): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function styled(component: any, styleObject: StyledStyleObject): any {\n throw new Error(\"RAHHH\");\n}\n\nexport function variants<\n T extends Record<string, Record<string, CSSProperties>>,\n>(variantsObject: T): { [K in keyof T]: string } {\n throw new Error(\"RAHHH\");\n}\n\nexport function mergeClassNames(\n classNames: Array<string | boolean | null | undefined>,\n): string {\n let cleanNames = classNames\n .filter((element) => typeof element === \"string\")\n .join(\" \")\n .split(/\\s+/);\n\n let classMap = Object.create(null) as Record<string, string>;\n for (let className of cleanNames) {\n if (className.startsWith(\"x\") && className.includes(\"-\")) {\n classMap[className.split(\"-\")[0]!] = className;\n } else {\n classMap[className] = className;\n }\n }\n\n return Object.values(classMap).join(\" \");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,SAAS,IAAI,aAAoC;AACtD,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,UAAU,aAAoD;AAC5E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,OAAO,WAAgB,aAAqC;AAC1E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,SAEd,gBAA+C;AAC/C,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,gBACd,YACQ;AACR,MAAI,aAAa,WACd,OAAO,CAAC,YAAY,OAAO,YAAY,QAAQ,EAC/C,KAAK,GAAG,EACR,MAAM,KAAK;AAEd,MAAI,WAAW,uBAAO,OAAO,IAAI;AACjC,WAAS,aAAa,YAAY;AAChC,QAAI,UAAU,WAAW,GAAG,KAAK,UAAU,SAAS,GAAG,GAAG;AACxD,eAAS,UAAU,MAAM,GAAG,EAAE,CAAC,CAAE,IAAI;AAAA,IACvC,OAAO;AACL,eAAS,SAAS,IAAI;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,QAAQ,EAAE,KAAK,GAAG;AACzC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/runtime.ts"],"sourcesContent":["export * from \"./runtime.js\";\n","import type { CSSProperties } from \"./css-properties.js\";\n\nexport type {\n CSSProp,\n CSSProperties,\n CSSPropItem,\n CSSValue,\n} from \"./css-properties.js\";\n\n/**\n * The style object accepted by `styled()`: top-level CSS properties plus the\n * optional `variants` and `defaultVariants` keys.\n */\nexport type StyledStyleObject = CSSProperties & {\n variants?: Record<string, Record<string, CSSProperties>>;\n defaultVariants?: Record<string, string | number | boolean>;\n};\n\nexport function css(styleObject: CSSProperties): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function keyframes(styleObject: Record<string, CSSProperties>): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function styled(component: any, styleObject: StyledStyleObject): any {\n throw new Error(\"RAHHH\");\n}\n\nexport function variants<\n T extends Record<string, Record<string, CSSProperties>>,\n>(variantsObject: T): { [K in keyof T]: string } {\n throw new Error(\"RAHHH\");\n}\n\nexport function mergeClassNames(\n classNames: Array<string | boolean | null | undefined>,\n): string {\n let cleanNames = classNames\n .filter((element) => typeof element === \"string\")\n .join(\" \")\n .split(/\\s+/);\n\n let classMap = Object.create(null) as Record<string, string>;\n for (let className of cleanNames) {\n if (className.startsWith(\"x\") && className.includes(\"-\")) {\n classMap[className.split(\"-\")[0]!] = className;\n } else {\n classMap[className] = className;\n }\n }\n\n return Object.values(classMap).join(\" \");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACkBO,SAAS,IAAI,aAAoC;AACtD,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,UAAU,aAAoD;AAC5E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,OAAO,WAAgB,aAAqC;AAC1E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,SAEd,gBAA+C;AAC/C,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,gBACd,YACQ;AACR,MAAI,aAAa,WACd,OAAO,CAAC,YAAY,OAAO,YAAY,QAAQ,EAC/C,KAAK,GAAG,EACR,MAAM,KAAK;AAEd,MAAI,WAAW,uBAAO,OAAO,IAAI;AACjC,WAAS,aAAa,YAAY;AAChC,QAAI,UAAU,WAAW,GAAG,KAAK,UAAU,SAAS,GAAG,GAAG;AACxD,eAAS,UAAU,MAAM,GAAG,EAAE,CAAC,CAAE,IAAI;AAAA,IACvC,OAAO;AACL,eAAS,SAAS,IAAI;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,QAAQ,EAAE,KAAK,GAAG;AACzC;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,36 +1,14 @@
1
1
  import * as CSS from 'csstype';
2
2
 
3
- /**
4
- * A value allowed inside a {@link CSSProperties} object: a string, a number, an
5
- * array of strings/numbers (e.g. for fallback values), or a nested
6
- * {@link CSSProperties} object (e.g. for selectors, media queries, or
7
- * at-rules).
8
- */
9
3
  type CSSValue = string | number | Array<string | number> | CSSProperties;
10
- /**
11
- * The value type for a *known* CSS property.
12
- *
13
- * We deliberately do NOT union in a bare `string` here: csstype's own property
14
- * types already permit any string via the `(string & {})` trick, which keeps
15
- * the literal value suggestions (e.g. `"center"` for `alignItems`) visible in
16
- * IntelliSense. Adding a bare `string` would collapse that union and suppress
17
- * the autocomplete. We still allow numbers, fallback arrays, and nested objects.
18
- */
19
4
  type KnownCSSValue<K extends keyof CSS.Properties> = CSS.Properties[K] | number | Array<string | number> | CSSProperties;
20
- /**
21
- * The shape of the style objects passed to `css()`, `variants()`, and
22
- * `styled()`.
23
- *
24
- * Known camelCase CSS properties (sourced from `csstype`) offer autocomplete
25
- * for both the property name and its value, but any other key is accepted
26
- * without a type error so that selectors, media queries, custom properties, and
27
- * other arbitrary keys can be used freely.
28
- */
29
5
  type CSSProperties = {
30
6
  [K in keyof CSS.Properties]?: KnownCSSValue<K>;
31
7
  } & {
32
8
  [key: string]: CSSValue;
33
9
  };
10
+ type CSSPropItem = string | boolean | CSSProperties | null | undefined;
11
+ type CSSProp = CSSPropItem | CSSPropItem[];
34
12
 
35
13
  /**
36
14
  * The style object accepted by `styled()`: top-level CSS properties plus the
@@ -48,4 +26,4 @@ declare function variants<T extends Record<string, Record<string, CSSProperties>
48
26
  };
49
27
  declare function mergeClassNames(classNames: Array<string | boolean | null | undefined>): string;
50
28
 
51
- export { type CSSProperties, type CSSValue, type StyledStyleObject, css, keyframes, mergeClassNames, styled, variants };
29
+ export { type CSSProp, type CSSPropItem, type CSSProperties, type CSSValue, type StyledStyleObject, css, keyframes, mergeClassNames, styled, variants };
package/dist/index.d.ts CHANGED
@@ -1,36 +1,14 @@
1
1
  import * as CSS from 'csstype';
2
2
 
3
- /**
4
- * A value allowed inside a {@link CSSProperties} object: a string, a number, an
5
- * array of strings/numbers (e.g. for fallback values), or a nested
6
- * {@link CSSProperties} object (e.g. for selectors, media queries, or
7
- * at-rules).
8
- */
9
3
  type CSSValue = string | number | Array<string | number> | CSSProperties;
10
- /**
11
- * The value type for a *known* CSS property.
12
- *
13
- * We deliberately do NOT union in a bare `string` here: csstype's own property
14
- * types already permit any string via the `(string & {})` trick, which keeps
15
- * the literal value suggestions (e.g. `"center"` for `alignItems`) visible in
16
- * IntelliSense. Adding a bare `string` would collapse that union and suppress
17
- * the autocomplete. We still allow numbers, fallback arrays, and nested objects.
18
- */
19
4
  type KnownCSSValue<K extends keyof CSS.Properties> = CSS.Properties[K] | number | Array<string | number> | CSSProperties;
20
- /**
21
- * The shape of the style objects passed to `css()`, `variants()`, and
22
- * `styled()`.
23
- *
24
- * Known camelCase CSS properties (sourced from `csstype`) offer autocomplete
25
- * for both the property name and its value, but any other key is accepted
26
- * without a type error so that selectors, media queries, custom properties, and
27
- * other arbitrary keys can be used freely.
28
- */
29
5
  type CSSProperties = {
30
6
  [K in keyof CSS.Properties]?: KnownCSSValue<K>;
31
7
  } & {
32
8
  [key: string]: CSSValue;
33
9
  };
10
+ type CSSPropItem = string | boolean | CSSProperties | null | undefined;
11
+ type CSSProp = CSSPropItem | CSSPropItem[];
34
12
 
35
13
  /**
36
14
  * The style object accepted by `styled()`: top-level CSS properties plus the
@@ -48,4 +26,4 @@ declare function variants<T extends Record<string, Record<string, CSSProperties>
48
26
  };
49
27
  declare function mergeClassNames(classNames: Array<string | boolean | null | undefined>): string;
50
28
 
51
- export { type CSSProperties, type CSSValue, type StyledStyleObject, css, keyframes, mergeClassNames, styled, variants };
29
+ export { type CSSProp, type CSSPropItem, type CSSProperties, type CSSValue, type StyledStyleObject, css, keyframes, mergeClassNames, styled, variants };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["import type { CSSProperties } from \"./css-properties.js\";\n\nexport type { CSSProperties, CSSValue } from \"./css-properties.js\";\n\n/**\n * The style object accepted by `styled()`: top-level CSS properties plus the\n * optional `variants` and `defaultVariants` keys.\n */\nexport type StyledStyleObject = CSSProperties & {\n variants?: Record<string, Record<string, CSSProperties>>;\n defaultVariants?: Record<string, string | number | boolean>;\n};\n\nexport function css(styleObject: CSSProperties): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function keyframes(styleObject: Record<string, CSSProperties>): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function styled(component: any, styleObject: StyledStyleObject): any {\n throw new Error(\"RAHHH\");\n}\n\nexport function variants<\n T extends Record<string, Record<string, CSSProperties>>,\n>(variantsObject: T): { [K in keyof T]: string } {\n throw new Error(\"RAHHH\");\n}\n\nexport function mergeClassNames(\n classNames: Array<string | boolean | null | undefined>,\n): string {\n let cleanNames = classNames\n .filter((element) => typeof element === \"string\")\n .join(\" \")\n .split(/\\s+/);\n\n let classMap = Object.create(null) as Record<string, string>;\n for (let className of cleanNames) {\n if (className.startsWith(\"x\") && className.includes(\"-\")) {\n classMap[className.split(\"-\")[0]!] = className;\n } else {\n classMap[className] = className;\n }\n }\n\n return Object.values(classMap).join(\" \");\n}\n"],"mappings":";AAaO,SAAS,IAAI,aAAoC;AACtD,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,UAAU,aAAoD;AAC5E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,OAAO,WAAgB,aAAqC;AAC1E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,SAEd,gBAA+C;AAC/C,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,gBACd,YACQ;AACR,MAAI,aAAa,WACd,OAAO,CAAC,YAAY,OAAO,YAAY,QAAQ,EAC/C,KAAK,GAAG,EACR,MAAM,KAAK;AAEd,MAAI,WAAW,uBAAO,OAAO,IAAI;AACjC,WAAS,aAAa,YAAY;AAChC,QAAI,UAAU,WAAW,GAAG,KAAK,UAAU,SAAS,GAAG,GAAG;AACxD,eAAS,UAAU,MAAM,GAAG,EAAE,CAAC,CAAE,IAAI;AAAA,IACvC,OAAO;AACL,eAAS,SAAS,IAAI;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,QAAQ,EAAE,KAAK,GAAG;AACzC;","names":[]}
1
+ {"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["import type { CSSProperties } from \"./css-properties.js\";\n\nexport type {\n CSSProp,\n CSSProperties,\n CSSPropItem,\n CSSValue,\n} from \"./css-properties.js\";\n\n/**\n * The style object accepted by `styled()`: top-level CSS properties plus the\n * optional `variants` and `defaultVariants` keys.\n */\nexport type StyledStyleObject = CSSProperties & {\n variants?: Record<string, Record<string, CSSProperties>>;\n defaultVariants?: Record<string, string | number | boolean>;\n};\n\nexport function css(styleObject: CSSProperties): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function keyframes(styleObject: Record<string, CSSProperties>): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function styled(component: any, styleObject: StyledStyleObject): any {\n throw new Error(\"RAHHH\");\n}\n\nexport function variants<\n T extends Record<string, Record<string, CSSProperties>>,\n>(variantsObject: T): { [K in keyof T]: string } {\n throw new Error(\"RAHHH\");\n}\n\nexport function mergeClassNames(\n classNames: Array<string | boolean | null | undefined>,\n): string {\n let cleanNames = classNames\n .filter((element) => typeof element === \"string\")\n .join(\" \")\n .split(/\\s+/);\n\n let classMap = Object.create(null) as Record<string, string>;\n for (let className of cleanNames) {\n if (className.startsWith(\"x\") && className.includes(\"-\")) {\n classMap[className.split(\"-\")[0]!] = className;\n } else {\n classMap[className] = className;\n }\n }\n\n return Object.values(classMap).join(\" \");\n}\n"],"mappings":";AAkBO,SAAS,IAAI,aAAoC;AACtD,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,UAAU,aAAoD;AAC5E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,OAAO,WAAgB,aAAqC;AAC1E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,SAEd,gBAA+C;AAC/C,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,gBACd,YACQ;AACR,MAAI,aAAa,WACd,OAAO,CAAC,YAAY,OAAO,YAAY,QAAQ,EAC/C,KAAK,GAAG,EACR,MAAM,KAAK;AAEd,MAAI,WAAW,uBAAO,OAAO,IAAI;AACjC,WAAS,aAAa,YAAY;AAChC,QAAI,UAAU,WAAW,GAAG,KAAK,UAAU,SAAS,GAAG,GAAG;AACxD,eAAS,UAAU,MAAM,GAAG,EAAE,CAAC,CAAE,IAAI;AAAA,IACvC,OAAO;AACL,eAAS,SAAS,IAAI;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,QAAQ,EAAE,KAAK,GAAG;AACzC;","names":[]}