@manyducks.co/dolla-styled 0.0.2 → 0.0.3

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.mjs CHANGED
@@ -50,41 +50,42 @@ function h(e) {
50
50
  }
51
51
  var g = 0;
52
52
  function _(i, a = {}) {
53
- let o = {}, s = (a, ...s) => {
54
- let c = h(a.join("||")), l = "", u = [];
53
+ let { __name: o, ...s } = a, c = (a, ...c) => {
54
+ let l = h(a.join("||")), u = "", d = [];
55
55
  return a.forEach((e, t) => {
56
- if (l += e, t < s.length) {
57
- let e = s[t], n = "*", r = null;
56
+ if (u += e, t < c.length) {
57
+ let e = c[t], n = "*", r = null;
58
58
  if (Array.isArray(e) && ([e, n, r = null] = e), typeof e == "function") {
59
- let i = `--${c}-${t}`;
60
- r === null ? l += `var(${i})` : (l += `var(${i}, ${r})`, n !== "*" && m.register(i, n, r)), u.push({
59
+ let i = `--${l}-${t}`;
60
+ r === null ? u += `var(${i})` : (u += `var(${i}, ${r})`, n !== "*" && m.register(i, n, r)), d.push({
61
61
  varName: i,
62
62
  fn: e,
63
63
  initialValue: r
64
64
  });
65
- } else l += e;
65
+ } else u += e;
66
66
  }
67
- }), f.insert(c, l), (a, s) => {
68
- let l = [c];
69
- if (u.length > 0) {
67
+ }), f.insert(l, u), (a, c) => {
68
+ o && (c.name = o);
69
+ let u = [l];
70
+ if (d.length > 0) {
70
71
  let e = `styled-inst-${(g++).toString(36)}`;
71
- l.push(e);
72
+ u.push(e);
72
73
  let t = p.createInstanceRule(e);
73
- n(s, () => {
74
- u.forEach(({ varName: e, fn: n, initialValue: r }) => {
74
+ n(c, () => {
75
+ d.forEach(({ varName: e, fn: n, initialValue: r }) => {
75
76
  let i = n(a);
76
77
  i == null || i === r ? t.removeProperty(e) : t.setProperty(e, i);
77
78
  });
78
79
  });
79
80
  }
80
81
  return t(typeof i == "string" && a.as || i, {
81
- ...o,
82
+ ...s,
82
83
  ...a,
83
- class: e(() => [a.class && r(a.class), ...l])
84
+ class: e(() => [a.class && r(a.class), ...u])
84
85
  });
85
86
  };
86
87
  };
87
- return s.with = () => s, s.defaults = (e) => _(i, Object.assign({}, a, e)), s;
88
+ return c.with = () => c, c.named = (e) => _(i, Object.assign({}, a, { __name: e })), c.defaults = (e) => _(i, Object.assign({}, a, e)), c;
88
89
  }
89
90
  var v = new Proxy(_, { get(e, t) {
90
91
  return _(t);
package/dist/styled.d.ts CHANGED
@@ -9,6 +9,10 @@ type Flatten<T> = {
9
9
  } & {};
10
10
  interface TypedTemplateFn<Props> {
11
11
  (strings: TemplateStringsArray, ...interpolations: any[]): StyledView<Props>;
12
+ /**
13
+ * Provides a name for the underlying view.
14
+ */
15
+ named(name: string): TypedTemplateFn<Props>;
12
16
  /**
13
17
  * Provides default props that are passed to all instances unless overridden.
14
18
  */
@@ -16,10 +20,18 @@ interface TypedTemplateFn<Props> {
16
20
  }
17
21
  interface TemplateFn<BaseProps = {}> {
18
22
  (strings: TemplateStringsArray, ...interpolations: any[]): StyledView<BaseProps>;
23
+ /**
24
+ * Provides a name for the underlying view.
25
+ */
26
+ named(name: string): TemplateFn<BaseProps>;
19
27
  /**
20
28
  * Defines additional props the resulting view takes.
21
29
  */
22
30
  with<T>(): TypedTemplateFn<BaseProps & T>;
31
+ /**
32
+ * Provides default props that are passed to all instances unless overridden.
33
+ */
34
+ defaults<D extends Partial<BaseProps>>(defaultProps: D): (strings: TemplateStringsArray, ...interpolations: any[]) => StyledView<Flatten<ApplyDefaults<BaseProps, D>>>;
23
35
  }
24
36
  declare function createBuilder<Tag extends keyof JSX.IntrinsicElements>(tag: Tag, boundDefaults?: Partial<JSX.IntrinsicElements[Tag]>): TemplateFn<JSX.IntrinsicElements[Tag]>;
25
37
  declare function createBuilder<Props>(view: View<Props>, boundDefaults?: Partial<Props>): TemplateFn<Props>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manyducks.co/dolla-styled",
3
3
  "description": "Styled Components for Dolla",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {