@salty-css/core 0.0.1-alpha.8 → 0.0.1-alpha.9

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/README.md CHANGED
@@ -54,8 +54,10 @@ export const IndexPage = () => {
54
54
  import { styled } from '@salty-css/react/styled';
55
55
 
56
56
  export const Wrapper = styled('div', {
57
- display: 'block',
58
- padding: '2vw',
57
+ base: {
58
+ display: 'block',
59
+ padding: '2vw',
60
+ },
59
61
  });
60
62
  ```
61
63
 
@@ -65,22 +67,24 @@ export const Wrapper = styled('div', {
65
67
  import { styled } from '@salty-css/react/styled';
66
68
 
67
69
  export const Button = styled('button', {
68
- display: 'block',
69
- padding: `0.6em 1.2em`,
70
- border: '1px solid currentColor',
71
- background: 'transparent',
72
- color: 'currentColor/40',
73
- cursor: 'pointer',
74
- transition: '200ms',
75
- textDecoration: 'none',
76
- '&:hover': {
77
- background: 'black',
78
- borderColor: 'black',
79
- color: 'white',
80
- },
81
- '&:disabled': {
82
- opacity: 0.25,
83
- pointerEvents: 'none',
70
+ base: {
71
+ display: 'block',
72
+ padding: `0.6em 1.2em`,
73
+ border: '1px solid currentColor',
74
+ background: 'transparent',
75
+ color: 'currentColor/40',
76
+ cursor: 'pointer',
77
+ transition: '200ms',
78
+ textDecoration: 'none',
79
+ '&:hover': {
80
+ background: 'black',
81
+ borderColor: 'black',
82
+ color: 'white',
83
+ },
84
+ '&:disabled': {
85
+ opacity: 0.25,
86
+ pointerEvents: 'none',
87
+ },
84
88
  },
85
89
  variants: {
86
90
  variant: {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../util/index.cjs"),a=require("../parse-templates-BY1Xai-_.cjs");class o{constructor(t,s,e){this.tagName=t,this.styles=s,this.options=e}get hash(){return n.toHash(this.styles)}get priority(){var t;return typeof this.tagName=="function"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:s}=this.options;return s&&t.push(s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?a.getTemplateKeys(this._context.config.templates):[]}get css(){var t;return a.parseStyles(this.styles,`.${this.cssClassName}`,this.priority,(t=this._context)==null?void 0:t.config)}get props(){const{element:t}=this.options,s=this.styles.variants?Object.keys(this.styles.variants).map(e=>{var r;const i=(r=this.styles.defaultVariants)==null?void 0:r[e];return i!==void 0?`${e}=${String(i)}`:e}):void 0;return{element:t,variantKeys:s}}_withBuildContext(t){this._context=t;const{name:s,config:e}=t;return this._callerName=s,this}}exports.StyleComponentGenerator=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../util/index.cjs"),i=require("../parse-templates-BY1Xai-_.cjs");class o{constructor(t,s){this.tagName=t,this.params=s}get hash(){return n.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:s}=this.params;return s&&t.push(s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?i.getTemplateKeys(this._context.config.templates):[]}get css(){var a;const{base:t={},variants:s={},compoundVariants:e=[]}=this.params,r={...t,variants:s,compoundVariants:e};return i.parseStyles(r,`.${this.cssClassName}`,this.priority,(a=this._context)==null?void 0:a.config)}get props(){const{element:t}=this.params,s=this.params.variants?Object.keys(this.params.variants).map(e=>{var a;const r=(a=this.params.defaultVariants)==null?void 0:a[e];return r!==void 0?`${e}=${String(r)}`:e}):void 0;return{element:t,variantKeys:s}}_withBuildContext(t){this._context=t;const{name:s,config:e}=t;return this._callerName=s,this}}exports.StyleComponentGenerator=o;
@@ -1,18 +1,18 @@
1
- import { toHash as a } from "../util/index.js";
1
+ import { toHash as i } from "../util/index.js";
2
2
  import { g as n, p as o } from "../parse-templates-BOSK0Tb6.js";
3
3
  class p {
4
- constructor(t, s, e) {
5
- this.tagName = t, this.styles = s, this.options = e;
4
+ constructor(t, s) {
5
+ this.tagName = t, this.params = s;
6
6
  }
7
7
  get hash() {
8
- return a(this.styles);
8
+ return i(this.params.base || this.params);
9
9
  }
10
10
  get priority() {
11
11
  var t;
12
- return typeof this.tagName == "function" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
12
+ return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
13
13
  }
14
14
  get classNames() {
15
- const t = [this.hash], { className: s } = this.options;
15
+ const t = [this.hash], { className: s } = this.params;
16
16
  return s && t.push(s), t.join(" ");
17
17
  }
18
18
  get cssClassName() {
@@ -26,14 +26,15 @@ class p {
26
26
  return (t = this._context) != null && t.config.templates ? n(this._context.config.templates) : [];
27
27
  }
28
28
  get css() {
29
- var t;
30
- return o(this.styles, `.${this.cssClassName}`, this.priority, (t = this._context) == null ? void 0 : t.config);
29
+ var e;
30
+ const { base: t = {}, variants: s = {}, compoundVariants: a = [] } = this.params, r = { ...t, variants: s, compoundVariants: a };
31
+ return o(r, `.${this.cssClassName}`, this.priority, (e = this._context) == null ? void 0 : e.config);
31
32
  }
32
33
  get props() {
33
- const { element: t } = this.options, s = this.styles.variants ? Object.keys(this.styles.variants).map((e) => {
34
- var r;
35
- const i = (r = this.styles.defaultVariants) == null ? void 0 : r[e];
36
- return i !== void 0 ? `${e}=${String(i)}` : e;
34
+ const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((a) => {
35
+ var e;
36
+ const r = (e = this.params.defaultVariants) == null ? void 0 : e[a];
37
+ return r !== void 0 ? `${a}=${String(r)}` : a;
37
38
  }) : void 0;
38
39
  return {
39
40
  element: t,
@@ -42,7 +43,7 @@ class p {
42
43
  }
43
44
  _withBuildContext(t) {
44
45
  this._context = t;
45
- const { name: s, config: e } = t;
46
+ const { name: s, config: a } = t;
46
47
  return this._callerName = s, this;
47
48
  }
48
49
  }
@@ -1,14 +1,13 @@
1
- import { GeneratorOptions, Styles, Tag } from '../types';
1
+ import { StyledParams, Tag } from '../types';
2
2
  export declare class StyleComponentGenerator {
3
3
  tagName: Tag<any>;
4
- styles: Styles;
5
- private options;
4
+ params: StyledParams;
6
5
  _callerName: string | undefined;
7
6
  _context: {
8
7
  name: string;
9
8
  config: any;
10
9
  } | undefined;
11
- constructor(tagName: Tag<any>, styles: Styles, options: GeneratorOptions);
10
+ constructor(tagName: Tag<any>, params: StyledParams);
12
11
  get hash(): string;
13
12
  get priority(): number;
14
13
  get classNames(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.8",
3
+ "version": "0.0.1-alpha.9",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
package/types/index.d.ts CHANGED
@@ -38,7 +38,7 @@ type Variants = {
38
38
  compoundVariants?: CompoundVariant[];
39
39
  };
40
40
  type VariantPropValue<T> = T extends 'true' ? 'true' | true : T;
41
- export type VariantProps<STYLES extends Styles> = STYLES['variants'] extends undefined ? {} : {
41
+ export type VariantProps<STYLES extends StyledParams> = STYLES['variants'] extends undefined ? {} : {
42
42
  [K in keyof STYLES['variants']]?: VariantPropValue<keyof STYLES['variants'][K]> | '';
43
43
  };
44
44
  export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : unknown;
@@ -52,4 +52,7 @@ export interface GeneratorOptions {
52
52
  displayName?: string;
53
53
  element?: string;
54
54
  }
55
+ export interface StyledParams extends GeneratorOptions, Variants {
56
+ base?: CssStyles;
57
+ }
55
58
  export {};