@spark-ui/internal-utils 1.2.0 → 1.3.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.3.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@1.2.0...@spark-ui/internal-utils@1.3.0) (2023-04-05)
7
+
8
+ ### Features
9
+
10
+ - **internal-utils:** add variants folder ([c286382](https://github.com/adevinta/spark/commit/c28638297833ce50db909e1d43bdfd94bdb92ab8))
11
+
6
12
  # [1.2.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@1.1.0...@spark-ui/internal-utils@1.2.0) (2023-04-04)
7
13
 
8
14
  ### Features
package/dist/index.d.ts CHANGED
@@ -1,27 +1,4 @@
1
- /**
2
- * A utility function that serves as a workaround for Tailwind CSS IntelliSense issues
3
- * in large objects or when regex breaks in VSCode.
4
- *
5
- * @example
6
- *
7
- * // before
8
- * const styles: cva(['flex bg-primary', 'cursor-pointer'], {
9
- * variants: {
10
- * size: {
11
- * small: "h-sz-24",
12
- * medium: "h-sz-48"
13
- * }
14
- * }
15
- * })
16
- *
17
- * // after
18
- * const styles = cva(tw(['flex bg-primary', 'cursor-pointer']), {
19
- * variants: {
20
- * size: {
21
- * small: tw("h-sz-24"),
22
- * medium: tw("h-sz-48"),
23
- * }
24
- * }
25
- * })
26
- */
27
- export declare function tw<T>(v: T): T;
1
+ export { tw } from './tw';
2
+ export { makeDesigns, makeIntents, makeShapes, makeSizes } from './variants';
3
+ export * as VariantTypes from './variants/types';
4
+ export * as variantConstants from './variants/constants';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.tw=function(t){return t};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),n=Object.freeze(Object.defineProperty({__proto__:null,designs:["filled","outlined","tinted","ghost","contrast"],intents:["primary","secondary","success","error","info","alert","danger","neutral","surface"],shapes:["rounded","square","pill"],sizes:["sm","md","lg"]},Symbol.toStringTag,{value:"Module"}));exports.VariantTypes=t,exports.makeDesigns=function(e){return{design:e}},exports.makeIntents=function(e){return{intent:e}},exports.makeShapes=function(e){return{shape:e}},exports.makeSizes=function(e){return{size:e}},exports.tw=function(e){return e},exports.variantConstants=n;
package/dist/index.mjs CHANGED
@@ -1,6 +1,25 @@
1
- function t(n) {
2
- return n;
1
+ function n(e) {
2
+ return e;
3
3
  }
4
+ function t(e) {
5
+ return { size: e };
6
+ }
7
+ function r(e) {
8
+ return { intent: e };
9
+ }
10
+ function s(e) {
11
+ return { design: e };
12
+ }
13
+ function a(e) {
14
+ return { shape: e };
15
+ }
16
+ const o = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), i = Object.freeze(Object.defineProperty({ __proto__: null, designs: ["filled", "outlined", "tinted", "ghost", "contrast"], intents: ["primary", "secondary", "success", "error", "info", "alert", "danger", "neutral", "surface"], shapes: ["rounded", "square", "pill"], sizes: ["sm", "md", "lg"] }, Symbol.toStringTag, { value: "Module" }));
4
17
  export {
5
- t as tw
18
+ o as VariantTypes,
19
+ s as makeDesigns,
20
+ r as makeIntents,
21
+ a as makeShapes,
22
+ t as makeSizes,
23
+ n as tw,
24
+ i as variantConstants
6
25
  };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A utility function that serves as a workaround for Tailwind CSS IntelliSense issues
3
+ * in large objects or when regex breaks in VSCode.
4
+ *
5
+ * @example
6
+ *
7
+ * // before
8
+ * const styles: cva(['flex bg-primary', 'cursor-pointer'], {
9
+ * variants: {
10
+ * size: {
11
+ * small: "h-sz-24",
12
+ * medium: "h-sz-48"
13
+ * }
14
+ * }
15
+ * })
16
+ *
17
+ * // after
18
+ * const styles = cva(tw(['flex bg-primary', 'cursor-pointer']), {
19
+ * variants: {
20
+ * size: {
21
+ * small: tw("h-sz-24"),
22
+ * medium: tw("h-sz-48"),
23
+ * }
24
+ * }
25
+ * })
26
+ */
27
+ export declare function tw<T>(v: T): T;
@@ -0,0 +1,5 @@
1
+ declare const sizes: readonly ["sm", "md", "lg"];
2
+ declare const intents: readonly ["primary", "secondary", "success", "error", "info", "alert", "danger", "neutral", "surface"];
3
+ declare const designs: readonly ["filled", "outlined", "tinted", "ghost", "contrast"];
4
+ declare const shapes: readonly ["rounded", "square", "pill"];
5
+ export { sizes, intents, designs, shapes };
@@ -0,0 +1,14 @@
1
+ import { Design, DesignLookup, Intent, IntentLookup, Picks, Shape, ShapeLookup, Size, SizeLookup } from './types';
2
+ declare function makeSizes<P extends Size[] = []>(sizes: P extends [] ? SizeLookup : Picks<SizeLookup, P>): {
3
+ size: P extends [] ? SizeLookup : Picks<SizeLookup, P>;
4
+ };
5
+ declare function makeIntents<P extends Intent[] = []>(intents: P extends [] ? IntentLookup : Picks<IntentLookup, P>): {
6
+ intent: P extends [] ? IntentLookup : Picks<IntentLookup, P>;
7
+ };
8
+ declare function makeDesigns<P extends Design[] = []>(designs: P extends [] ? DesignLookup : Picks<DesignLookup, P>): {
9
+ design: P extends [] ? DesignLookup : Picks<DesignLookup, P>;
10
+ };
11
+ declare function makeShapes<P extends Shape[] = []>(shapes: P extends [] ? ShapeLookup : Picks<ShapeLookup, P>): {
12
+ shape: P extends [] ? ShapeLookup : Picks<ShapeLookup, P>;
13
+ };
14
+ export { makeSizes, makeIntents, makeDesigns, makeShapes };
@@ -0,0 +1,14 @@
1
+ import { designs, intents, shapes, sizes } from './constants';
2
+ type Picks<T extends object, Entries extends (keyof T)[], Acc = {}> = Entries extends [
3
+ infer Entry,
4
+ ...infer Rest
5
+ ] ? Rest extends (keyof T)[] ? Entry extends keyof T ? Picks<T, Rest, Acc & Pick<T, Entry>> : Acc : Acc : Acc;
6
+ type Size = (typeof sizes)[number];
7
+ type SizeLookup = Record<Size, string[]>;
8
+ type Intent = (typeof intents)[number];
9
+ type IntentLookup = Record<Intent, string[]>;
10
+ type Design = (typeof designs)[number];
11
+ type DesignLookup = Record<Design, string[]>;
12
+ type Shape = (typeof shapes)[number];
13
+ type ShapeLookup = Record<Shape, string[]>;
14
+ export type { Size, SizeLookup, Intent, IntentLookup, Design, DesignLookup, Shape, ShapeLookup, Picks, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-ui/internal-utils",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "package for sharing reusable code and resources across the codebase",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,5 +11,5 @@
11
11
  "scripts": {
12
12
  "build": "vite build"
13
13
  },
14
- "gitHead": "ee44f7b27e2a524e29c17e55d81550de7dff47a9"
14
+ "gitHead": "2b57fad10e74d51ea57d0bfff9bb636dbdd8914b"
15
15
  }