praxis-kit 2.0.2 → 3.0.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.
@@ -111,25 +111,25 @@ type VariantSelection<V extends VariantMap> = {
111
111
  * Presets are named bundles of variant props that callers activate by key,
112
112
  * avoiding the need to repeat variant combinations at each call site.
113
113
  */
114
- type PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
114
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
115
115
 
116
- type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
116
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
117
117
 
118
118
  interface BaseClassOptions {
119
119
  baseClassName?: ClassName;
120
120
  }
121
121
 
122
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
122
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
123
123
 
124
- interface PresetOptions<TVariants extends VariantMap = VariantMap> {
125
- presetMap?: Record<string, PresetTarget<TVariants>>;
124
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
125
+ recipeMap?: Record<string, RecipeTarget<TVariants>>;
126
126
  }
127
127
 
128
128
  interface TagMapOptions {
129
129
  tagMap?: TagMap;
130
130
  }
131
131
 
132
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
132
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
133
133
 
134
134
  type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
135
135
 
@@ -204,7 +204,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
204
204
  readonly allowedAs?: readonly TAllowed[];
205
205
  };
206
206
 
207
- type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
207
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
208
208
  readonly base?: ClassName;
209
209
  readonly variants?: V;
210
210
  readonly defaults?: Partial<DefaultVariants<V>>;
@@ -218,8 +218,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
218
218
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
219
219
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
220
220
  }['normalize'];
221
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
222
- type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
221
+ type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyRecord>;
222
+ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
223
223
  readonly tag?: TDefault;
224
224
  readonly name?: string;
225
225
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -230,13 +230,15 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
230
230
 
231
231
  type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolean;
232
232
 
233
+ declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
234
+
233
235
  /**
234
236
  * Options accepted by createContractComponent in the web adapter.
235
237
  *
236
238
  * Identical shape to LitFactoryOptions — a plain HTMLElement subclass with
237
239
  * no framework dependency. Light DOM only; Shadow DOM is out of scope.
238
240
  */
239
- type WebFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = FactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps> & {
241
+ type WebFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = FactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps> & {
240
242
  readonly filterProps?: FilterPredicate;
241
243
  };
242
244
 
@@ -250,7 +252,7 @@ type UnknownProps = Record<string, unknown>;
250
252
  type WebContractComponent<TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>> = {
251
253
  new (): HTMLElement & {
252
254
  as: string | undefined;
253
- variantKey: string | undefined;
255
+ recipe: string | undefined;
254
256
  praxisClass: string | undefined;
255
257
  /** Re-runs the pipeline — call after setting non-reactive attributes (aria-*, role, data-*). */
256
258
  update(): void;
@@ -288,9 +290,7 @@ type WebContractComponent<TVariants extends Readonly<VariantMap> = Readonly<Empt
288
290
  * For non-reactive attributes (`aria-*`, `role`, `data-*`) call `element.update()`
289
291
  * after setting them to trigger an explicit pipeline re-run.
290
292
  */
291
- declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: WebFactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps>): WebContractComponent<TVariants>;
292
-
293
- declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
293
+ declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: WebFactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps>): WebContractComponent<TVariants>;
294
294
 
295
295
  /**
296
296
  * Renders a praxis-kit web component to an HTML string without requiring a DOM.
package/dist/web/index.js CHANGED
@@ -9,7 +9,12 @@ function applyFilter(props, filterProps, variantKeys) {
9
9
  return out;
10
10
  }
11
11
 
12
- // ../core/dist/chunk-XFCAUPVZ.js
12
+ // ../../lib/adapter-utils/src/define-component.ts
13
+ function defineContractComponent(options) {
14
+ return (factory) => factory(options);
15
+ }
16
+
17
+ // ../core/dist/chunk-KKSHJDE7.js
13
18
  function makeResolveTag(defaultTag) {
14
19
  return function tag(as) {
15
20
  return as ?? defaultTag;
@@ -78,7 +83,7 @@ function resolveFactoryOptions(options = {}) {
78
83
  ...whenDefined("defaultProps", options.defaults),
79
84
  ...whenDefined("baseClassName", styling?.base),
80
85
  ...whenDefined("tagMap", styling?.tags),
81
- ...whenDefined("presetMap", styling?.presets),
86
+ ...whenDefined("recipeMap", styling?.presets),
82
87
  ...whenDefined("variants", styling?.variants),
83
88
  ...whenDefined("defaultVariants", styling?.defaults),
84
89
  ...whenDefined("compoundVariants", styling?.compounds),
@@ -119,10 +124,10 @@ function validateFactoryOptions(resolved) {
119
124
  }
120
125
  }
121
126
  };
122
- const { presetMap } = resolved;
123
- if (presetMap) {
124
- for (const presetKey in presetMap) {
125
- checkSelection(`preset "${presetKey}"`, presetMap[presetKey]);
127
+ const { recipeMap } = resolved;
128
+ if (recipeMap) {
129
+ for (const recipeKey in recipeMap) {
130
+ checkSelection(`preset "${recipeKey}"`, recipeMap[recipeKey]);
126
131
  }
127
132
  }
128
133
  if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
@@ -158,12 +163,12 @@ function report2(strict, message) {
158
163
  function label(name) {
159
164
  return name ? `[${name}]` : "[createContractComponent]";
160
165
  }
161
- function validateRenderProps(options, props, presetKey) {
162
- const { strict, presetMap, variants, displayName } = options;
166
+ function validateRenderProps(options, props, recipeKey) {
167
+ const { strict, recipeMap, variants, displayName } = options;
163
168
  if (!strict) return;
164
169
  const tag = label(displayName);
165
- if (presetKey !== void 0 && (!presetMap || !Object.hasOwn(presetMap, presetKey))) {
166
- report2(strict, `${tag} Unknown presetKey "${presetKey}" \u2014 no preset with that name exists.`);
170
+ if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
171
+ report2(strict, `${tag} Unknown recipeKey "${recipeKey}" \u2014 no preset with that name exists.`);
167
172
  }
168
173
  if (variants) {
169
174
  for (const key in variants) {
@@ -201,8 +206,8 @@ function assertPluginShape(result) {
201
206
  }
202
207
  function guardPipeline(pipeline) {
203
208
  if (process.env.NODE_ENV === "production") return pipeline;
204
- return function guardedPipeline(tag, props, className, variantKey) {
205
- const result = pipeline(tag, props, className, variantKey);
209
+ return function guardedPipeline(tag, props, className, recipe) {
210
+ const result = pipeline(tag, props, className, recipe);
206
211
  if (typeof result !== "string")
207
212
  panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
208
213
  return result;
@@ -227,11 +232,11 @@ function createRuntimeMethods(resolved, classPipeline, engine) {
227
232
  resolveProps(props) {
228
233
  return mergeProps(resolved.defaultProps, props);
229
234
  },
230
- resolveClasses(tag, props, className, variantKey) {
235
+ resolveClasses(tag, props, className, recipe) {
231
236
  if (process.env.NODE_ENV !== "production") {
232
- validateRenderProps(resolved, props, variantKey);
237
+ validateRenderProps(resolved, props, recipe);
233
238
  }
234
- return classPipeline(tag, props, className, variantKey);
239
+ return classPipeline(tag, props, className, recipe);
235
240
  },
236
241
  resolveAria(tag, props) {
237
242
  if (!engine) return { props };
@@ -577,7 +582,7 @@ function isStandaloneTag(tag) {
577
582
  return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
578
583
  }
579
584
 
580
- // ../core/dist/chunk-VU44HAB7.js
585
+ // ../core/dist/chunk-BNVYTMYV.js
581
586
  var IMPLICIT_ROLE_RECORD2 = {
582
587
  article: "article",
583
588
  aside: "complementary",
@@ -1512,7 +1517,7 @@ function getHtmlPropNormalizers(tag) {
1512
1517
  return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
1513
1518
  }
1514
1519
 
1515
- // ../core/dist/chunk-EHCOMLJ4.js
1520
+ // ../core/dist/chunk-3T4EM5FG.js
1516
1521
  var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
1517
1522
  var cx = clsx;
1518
1523
  var cva = (base, config) => (props) => {
@@ -1589,18 +1594,18 @@ var StaticClassResolver = class {
1589
1594
  };
1590
1595
  var VariantClassResolver = class _VariantClassResolver {
1591
1596
  #cvaFn;
1592
- #presetMap;
1597
+ #recipeMap;
1593
1598
  #variantKeys;
1594
1599
  #precomputedClasses;
1595
1600
  #cache = /* @__PURE__ */ new Map();
1596
- constructor(cvaFn, presetMap, variantKeys, precomputedClasses) {
1601
+ constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
1597
1602
  this.#cvaFn = cvaFn ?? null;
1598
- this.#presetMap = Object.freeze(presetMap ?? {});
1603
+ this.#recipeMap = Object.freeze(recipeMap ?? {});
1599
1604
  this.#variantKeys = variantKeys ?? null;
1600
1605
  this.#precomputedClasses = precomputedClasses ?? null;
1601
1606
  }
1602
- resolve({ props, variantKey }) {
1603
- const normalizedKey = variantKey ?? "__none__";
1607
+ resolve({ props, recipe }) {
1608
+ const normalizedKey = recipe ?? "__none__";
1604
1609
  const cacheKey = this.#createCacheKey(props, normalizedKey);
1605
1610
  if (this.#precomputedClasses !== null) {
1606
1611
  const precomputed = this.#precomputedClasses[cacheKey];
@@ -1612,7 +1617,7 @@ var VariantClassResolver = class _VariantClassResolver {
1612
1617
  this.#cache.set(cacheKey, cached);
1613
1618
  return cached;
1614
1619
  }
1615
- const result = this.#compute(props, variantKey);
1620
+ const result = this.#compute(props, recipe);
1616
1621
  this.#cache.set(cacheKey, result);
1617
1622
  if (this.#cache.size > 1e3) {
1618
1623
  const lru = this.#cache.keys().next().value;
@@ -1620,10 +1625,10 @@ var VariantClassResolver = class _VariantClassResolver {
1620
1625
  }
1621
1626
  return result;
1622
1627
  }
1623
- #compute(props, variantKey) {
1628
+ #compute(props, recipe) {
1624
1629
  if (!this.#cvaFn) return "";
1625
- if (!variantKey) return this.#cvaFn(props);
1626
- const preset = this.#presetMap[variantKey];
1630
+ if (!recipe) return this.#cvaFn(props);
1631
+ const preset = this.#recipeMap[recipe];
1627
1632
  if (!preset) return this.#cvaFn(props);
1628
1633
  return this.#cvaFn({ ...preset, ...props });
1629
1634
  }
@@ -1631,15 +1636,15 @@ var VariantClassResolver = class _VariantClassResolver {
1631
1636
  // props (className, id, etc.) produce identical CVA output and must not fragment the cache.
1632
1637
  // Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
1633
1638
  // String is built incrementally to avoid a parts[] array allocation on every render.
1634
- #createCacheKey(props, variantKey) {
1639
+ #createCacheKey(props, recipe) {
1635
1640
  if (this.#variantKeys !== null) {
1636
- let key2 = variantKey;
1641
+ let key2 = recipe;
1637
1642
  for (const k of this.#variantKeys) {
1638
1643
  if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
1639
1644
  }
1640
1645
  return key2;
1641
1646
  }
1642
- let key = variantKey;
1647
+ let key = recipe;
1643
1648
  for (const k of Object.keys(props).sort()) {
1644
1649
  key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
1645
1650
  }
@@ -1664,13 +1669,13 @@ function createClassPipeline(resolved) {
1664
1669
  const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
1665
1670
  const variantResolver = new VariantClassResolver(
1666
1671
  cvaFn,
1667
- resolved.presetMap,
1672
+ resolved.recipeMap,
1668
1673
  variantKeys,
1669
1674
  resolved.precomputedClasses
1670
1675
  );
1671
- return function resolveClasses(tag, props, className, variantKey) {
1672
- const staticClasses = staticResolver.resolve(tag, variantKey !== void 0);
1673
- const variantClasses = variantResolver.resolve({ props, variantKey });
1676
+ return function resolveClasses(tag, props, className, recipe) {
1677
+ const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
1678
+ const variantClasses = variantResolver.resolve({ props, recipe });
1674
1679
  if (!className)
1675
1680
  return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
1676
1681
  return cn(staticClasses, variantClasses, className);
@@ -1771,14 +1776,14 @@ function renderToString(component, props = {}, innerHTML = "") {
1771
1776
  );
1772
1777
  }
1773
1778
  const { bundle } = entry;
1774
- const { as, className, variantKey, class: classAttr, ...rest } = props;
1779
+ const { as, className, recipe, class: classAttr, ...rest } = props;
1775
1780
  const tag = bundle.runtime.resolveTag(as);
1776
1781
  const mergedProps = bundle.runtime.resolveProps(rest);
1777
1782
  const resolvedClass = bundle.runtime.resolveClasses(
1778
1783
  tag,
1779
1784
  mergedProps,
1780
1785
  className ?? classAttr,
1781
- variantKey
1786
+ recipe
1782
1787
  );
1783
1788
  const ariaResult = bundle.runtime.resolveAria(tag, mergedProps);
1784
1789
  const filtered = applyFilter(
@@ -1814,7 +1819,7 @@ function toLooseBundle(bundle) {
1814
1819
  return bundle;
1815
1820
  }
1816
1821
  function resolveHostState(bundle, props) {
1817
- const { as, className, variantKey, ...rest } = props;
1822
+ const { as, className, recipe, ...rest } = props;
1818
1823
  const tag = bundle.runtime.resolveTag(as);
1819
1824
  const mergedProps = bundle.runtime.resolveProps(rest);
1820
1825
  const baseProps = bundle.runtime.options.normalizeFn ? bundle.runtime.options.normalizeFn(mergedProps) : mergedProps;
@@ -1824,7 +1829,7 @@ function resolveHostState(bundle, props) {
1824
1829
  tag,
1825
1830
  normalizedProps,
1826
1831
  className,
1827
- variantKey
1832
+ recipe
1828
1833
  );
1829
1834
  const ariaResult = bundle.runtime.resolveAria(tag, normalizedProps);
1830
1835
  const attributes = applyFilter(
@@ -1904,7 +1909,7 @@ function createContractComponent(options) {
1904
1909
  props[attr.name] = attr.value;
1905
1910
  }
1906
1911
  props["as"] = self.as ?? this.getAttribute("as") ?? void 0;
1907
- props["variantKey"] = self.variantKey ?? this.getAttribute("variant-key") ?? void 0;
1912
+ props["recipe"] = self.recipe ?? this.getAttribute("variant-key") ?? void 0;
1908
1913
  props["className"] = self.praxisClass ?? this.getAttribute("praxis-class") ?? void 0;
1909
1914
  for (const key of variantKeys) {
1910
1915
  const val = self[key] ?? this.getAttribute(key);
@@ -1920,11 +1925,6 @@ function createContractComponent(options) {
1920
1925
  registerForSsr(PolymorphicWebElement, looseBundle);
1921
1926
  return PolymorphicWebElement;
1922
1927
  }
1923
-
1924
- // ../../adapters/web/src/define-contract-component.ts
1925
- function defineContractComponent(options) {
1926
- return (factory) => factory(options);
1927
- }
1928
1928
  export {
1929
1929
  createContractComponent,
1930
1930
  defineContractComponent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "praxis-kit",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./react": {
@@ -130,8 +130,8 @@
130
130
  "vite": "^8.0.16",
131
131
  "vue": "^3.5.38",
132
132
  "@praxis-kit/adapter-utils": "0.0.0",
133
- "@praxis-kit/shared": "0.8.0-beta.4",
134
- "@praxis-kit/core": "0.8.0-beta.4"
133
+ "@praxis-kit/core": "0.8.0-beta.4",
134
+ "@praxis-kit/shared": "0.8.0-beta.4"
135
135
  },
136
136
  "publishConfig": {
137
137
  "access": "public"