@spark-ui/internal-utils 1.2.0 → 1.4.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,19 @@
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.4.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@1.3.0...@spark-ui/internal-utils@1.4.0) (2023-04-06)
7
+
8
+ ### Features
9
+
10
+ - **internal-utils:** add comment ([fde9ab5](https://github.com/adevinta/spark/commit/fde9ab550895a0d362aaf7edb3975bf89560f965))
11
+ - **internal-utils:** clean up code (variants folder) ([9f62a0f](https://github.com/adevinta/spark/commit/9f62a0f876d37c4962704c107eb0567bef2eeb1c))
12
+
13
+ # [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)
14
+
15
+ ### Features
16
+
17
+ - **internal-utils:** add variants folder ([c286382](https://github.com/adevinta/spark/commit/c28638297833ce50db909e1d43bdfd94bdb92ab8))
18
+
6
19
  # [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
20
 
8
21
  ### 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 { makeVariants } 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"})),r=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.makeVariants=function(e){return e},exports.tw=function(e){return e},exports.variantConstants=r;
package/dist/index.mjs CHANGED
@@ -1,6 +1,13 @@
1
- function t(n) {
2
- return n;
1
+ function t(e) {
2
+ return e;
3
3
  }
4
+ function r(e) {
5
+ return e;
6
+ }
7
+ const n = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), a = 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
8
  export {
5
- t as tw
9
+ n as VariantTypes,
10
+ r as makeVariants,
11
+ t as tw,
12
+ a as variantConstants
6
13
  };
@@ -0,0 +1,29 @@
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
+ * For more context, see: https://github.com/joe-bell/cva/discussions/85#discussioncomment-4568738
6
+ *
7
+ * @example
8
+ *
9
+ * // before
10
+ * const styles: cva(['flex bg-primary', 'cursor-pointer'], {
11
+ * variants: {
12
+ * size: {
13
+ * small: "h-sz-24",
14
+ * medium: "h-sz-48"
15
+ * }
16
+ * }
17
+ * })
18
+ *
19
+ * // after
20
+ * const styles = cva(tw(['flex bg-primary', 'cursor-pointer']), {
21
+ * variants: {
22
+ * size: {
23
+ * small: tw("h-sz-24"),
24
+ * medium: tw("h-sz-48"),
25
+ * }
26
+ * }
27
+ * })
28
+ */
29
+ 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,3 @@
1
+ import { Picks, VariantLookup } from './types';
2
+ declare function makeVariants<Variant extends 'design' | 'intent' | 'shape' | 'size', P extends (keyof VariantLookup[Variant])[] = []>(variants: P extends [] ? VariantLookup[Variant] : Picks<VariantLookup[Variant], P>): P extends [] ? VariantLookup[Variant] : Picks<VariantLookup[Variant], P>;
3
+ export { makeVariants };
@@ -0,0 +1,20 @@
1
+ import { designs, intents, shapes, sizes } from './constants';
2
+ type Picks<T extends object, PickedItems extends (keyof T)[], Acc = {}> = PickedItems extends [
3
+ infer Head,
4
+ ...infer Rest
5
+ ] ? Rest extends (keyof T)[] ? Head extends keyof T ? Picks<T, Rest, Acc & Pick<T, Head>> : 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
+ interface VariantLookup {
15
+ design: DesignLookup;
16
+ intent: IntentLookup;
17
+ shape: ShapeLookup;
18
+ size: SizeLookup;
19
+ }
20
+ export type { Size, SizeLookup, Intent, IntentLookup, Design, DesignLookup, Shape, ShapeLookup, Picks, VariantLookup, };
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.4.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": "a5a87741408264a57672bf562f14b97a3a63582a"
15
15
  }