@spark-ui/internal-utils 1.3.0 → 1.5.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.5.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@1.4.0...@spark-ui/internal-utils@1.5.0) (2023-04-19)
7
+
8
+ ### Features
9
+
10
+ - **internal-utils:** add current values and make variants partial ([5b1eb81](https://github.com/adevinta/spark/commit/5b1eb817fcbf1f05143e919fb4d37864828c257c))
11
+
12
+ # [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)
13
+
14
+ ### Features
15
+
16
+ - **internal-utils:** add comment ([fde9ab5](https://github.com/adevinta/spark/commit/fde9ab550895a0d362aaf7edb3975bf89560f965))
17
+ - **internal-utils:** clean up code (variants folder) ([9f62a0f](https://github.com/adevinta/spark/commit/9f62a0f876d37c4962704c107eb0567bef2eeb1c))
18
+
6
19
  # [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
20
 
8
21
  ### Features
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { tw } from './tw';
2
- export { makeDesigns, makeIntents, makeShapes, makeSizes } from './variants';
2
+ export { makeVariants } from './variants';
3
3
  export * as VariantTypes from './variants/types';
4
4
  export * as variantConstants from './variants/constants';
package/dist/index.js CHANGED
@@ -1 +1 @@
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;
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:["current","primary","secondary","success","error","info","alert","danger","neutral","surface"],shapes:["rounded","square","pill"],sizes:["current","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,25 +1,13 @@
1
- function n(e) {
2
- return e;
3
- }
4
1
  function t(e) {
5
- return { size: e };
2
+ return e;
6
3
  }
7
4
  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 };
5
+ return e;
15
6
  }
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" }));
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: ["current", "primary", "secondary", "success", "error", "info", "alert", "danger", "neutral", "surface"], shapes: ["rounded", "square", "pill"], sizes: ["current", "sm", "md", "lg"] }, Symbol.toStringTag, { value: "Module" }));
17
8
  export {
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
9
+ n as VariantTypes,
10
+ r as makeVariants,
11
+ t as tw,
12
+ a as variantConstants
25
13
  };
@@ -2,6 +2,8 @@
2
2
  * A utility function that serves as a workaround for Tailwind CSS IntelliSense issues
3
3
  * in large objects or when regex breaks in VSCode.
4
4
  *
5
+ * For more context, see: https://github.com/joe-bell/cva/discussions/85#discussioncomment-4568738
6
+ *
5
7
  * @example
6
8
  *
7
9
  * // before
@@ -1,5 +1,5 @@
1
- declare const sizes: readonly ["sm", "md", "lg"];
2
- declare const intents: readonly ["primary", "secondary", "success", "error", "info", "alert", "danger", "neutral", "surface"];
1
+ declare const sizes: readonly ["current", "sm", "md", "lg"];
2
+ declare const intents: readonly ["current", "primary", "secondary", "success", "error", "info", "alert", "danger", "neutral", "surface"];
3
3
  declare const designs: readonly ["filled", "outlined", "tinted", "ghost", "contrast"];
4
4
  declare const shapes: readonly ["rounded", "square", "pill"];
5
5
  export { sizes, intents, designs, shapes };
@@ -1,14 +1,3 @@
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 };
1
+ import { VariantLookup } from './types';
2
+ declare function makeVariants<Variant extends 'design' | 'intent' | 'shape' | 'size'>(variants: Partial<VariantLookup[Variant]>): Partial<VariantLookup[Variant]>;
3
+ export { makeVariants };
@@ -1,8 +1,8 @@
1
1
  import { designs, intents, shapes, sizes } from './constants';
2
- type Picks<T extends object, Entries extends (keyof T)[], Acc = {}> = Entries extends [
3
- infer Entry,
2
+ type Picks<T extends object, PickedItems extends (keyof T)[], Acc = {}> = PickedItems extends [
3
+ infer Head,
4
4
  ...infer Rest
5
- ] ? Rest extends (keyof T)[] ? Entry extends keyof T ? Picks<T, Rest, Acc & Pick<T, Entry>> : Acc : Acc : Acc;
5
+ ] ? Rest extends (keyof T)[] ? Head extends keyof T ? Picks<T, Rest, Acc & Pick<T, Head>> : Acc : Acc : Acc;
6
6
  type Size = (typeof sizes)[number];
7
7
  type SizeLookup = Record<Size, string[]>;
8
8
  type Intent = (typeof intents)[number];
@@ -11,4 +11,10 @@ type Design = (typeof designs)[number];
11
11
  type DesignLookup = Record<Design, string[]>;
12
12
  type Shape = (typeof shapes)[number];
13
13
  type ShapeLookup = Record<Shape, string[]>;
14
- export type { Size, SizeLookup, Intent, IntentLookup, Design, DesignLookup, Shape, ShapeLookup, Picks, };
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.3.0",
3
+ "version": "1.5.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": "2b57fad10e74d51ea57d0bfff9bb636dbdd8914b"
14
+ "gitHead": "ad5cc14d188d9e9319f7782cd1a454bd926f0a67"
15
15
  }