praxis-kit 6.1.0 → 6.2.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.
@@ -138,7 +138,7 @@ interface BaseClassOptions {
138
138
  baseClassName?: ClassName;
139
139
  }
140
140
 
141
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
141
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string | undefined;
142
142
 
143
143
  interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
144
144
  recipeMap?: Record<string, RecipeTarget<TVariants>>;
@@ -214,8 +214,11 @@ type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
214
214
  };
215
215
  type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
216
216
  type AriaResult = ValidResult | AriaInvalidResult;
217
+ type AriaPhase = 'evaluate' | 'fix';
217
218
 
218
- type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly AriaResult[];
219
+ type AriaRule<C extends AriaContext = AriaContext> = ((context: C) => readonly AriaResult[]) & {
220
+ readonly readsProps?: readonly string[];
221
+ };
219
222
 
220
223
  type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
221
224
 
@@ -266,6 +269,11 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
266
269
  readonly normalize?: NormalizeFn<NoInfer<Props>>;
267
270
  readonly styling?: StylingOptions<V, TPreset, TPlugin>;
268
271
  readonly enforcement?: EnforcementOptions<TAllowed>;
272
+ /**
273
+ * Adapter-resolved diagnostics default, spread in by `resolveAdapterCommonOptions`. Not meant to
274
+ * be set directly by component authors — use `enforcement.diagnostics` to override per component.
275
+ */
276
+ readonly diagnostics?: Diagnostics$1;
269
277
  };
270
278
 
271
279
  declare const activeProps: PropNormalizer;
@@ -297,4 +305,4 @@ declare function mergeContracts(...contracts: readonly EnforcementOptions[]): En
297
305
 
298
306
  type Diagnostics = Diagnostics$1;
299
307
 
300
- export { type AnyFactoryOptions, type Diagnostics, type PropNormalizer, activeContract, activeProps, disabledContract, disabledProps, expandedContract, expandedProps, invalidContract, invalidProps, loadingContract, loadingProps, mergeContracts, pressedContract, pressedProps, readonlyContract, readonlyProps, selectedContract, selectedProps };
308
+ export { type AnyFactoryOptions, type AriaContext, type AriaFix, type AriaFixResult, type AriaPhase, type AriaResult, type AriaRule, type Diagnostics, type FixKind, type AriaInvalidResult as InvalidResult, type AriaInvalidWithFix as InvalidWithFix, type AriaInvalidWithoutFix as InvalidWithoutFix, type PropNormalizer, type RemoveAttributeFixKind, type Severity, type ValidResult, activeContract, activeProps, disabledContract, disabledProps, expandedContract, expandedProps, invalidContract, invalidProps, loadingContract, loadingProps, mergeContracts, pressedContract, pressedProps, readonlyContract, readonlyProps, selectedContract, selectedProps };
@@ -244,7 +244,7 @@ var require_eslint_utils = __commonJS({
244
244
  // ../../plugins/eslint/src/rules/no-dead-compound.ts
245
245
  var import_eslint_utils = __toESM(require_eslint_utils(), 1);
246
246
 
247
- // ../../lib/primitive/src/utils/is-object.ts
247
+ // ../../lib/primitive/src/utils/type-guards.ts
248
248
  function isString(value) {
249
249
  return typeof value === "string";
250
250
  }
@@ -0,0 +1,36 @@
1
+ type StringMap<T = unknown> = Record<string, T>;
2
+ type AnyRecord = StringMap<unknown>;
3
+
4
+ /**
5
+ * Resolves the effective HTML tag for a vnode:
6
+ * - native element: returns its type string directly
7
+ * - praxis-kit component: resolves `as ?? defaultTag`, mirroring render-time logic
8
+ * - anything else: returns undefined
9
+ */
10
+ declare function getTag(child: unknown): string | undefined;
11
+ /**
12
+ * Checks whether a vnode resolves to one of the given intrinsic tag names.
13
+ * Matches native elements directly, and praxis-kit components by resolving
14
+ * `as ?? defaultTag` — the same logic used at render time.
15
+ *
16
+ * Two call forms are supported:
17
+ * isTag('img')(child) — curried, composable with Array#filter
18
+ * isTag(child, 'img') — direct, reads naturally in if-blocks
19
+ */
20
+ type TagChild = {
21
+ type: unknown;
22
+ };
23
+ declare function isTag(tag: string, ...tags: readonly string[]): (child: unknown) => child is TagChild;
24
+ declare function isTag(child: unknown, tag: string, ...tags: readonly string[]): boolean;
25
+ /**
26
+ * Checks whether a vnode is flow content per the HTML content model: text nodes
27
+ * (string/number) always qualify, and elements/components qualify unless their
28
+ * resolved tag is in the blocked set.
29
+ */
30
+ declare function isFlowContent(...blockedTags: readonly string[]): (child: unknown) => boolean;
31
+
32
+ declare function isObject(value: unknown, excludeArrays: true): value is AnyRecord;
33
+ declare function isObject(value: unknown, excludeArrays?: false): value is object;
34
+ declare function isString(value: unknown): value is string;
35
+
36
+ export { getTag, isFlowContent, isObject, isString, isTag };
@@ -0,0 +1,62 @@
1
+ // ../../lib/primitive/src/utils/type-guards.ts
2
+ function isObject(value, excludeArrays = false) {
3
+ if (value === null || typeof value !== "object") return false;
4
+ return excludeArrays ? !Array.isArray(value) : true;
5
+ }
6
+ function isString(value) {
7
+ return typeof value === "string";
8
+ }
9
+ function isNumber(value) {
10
+ return typeof value === "number";
11
+ }
12
+
13
+ // ../../lib/primitive/src/guards/children/component-id.ts
14
+ var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
15
+
16
+ // ../../lib/primitive/src/guards/children/is-tag.ts
17
+ function getAsProp(child) {
18
+ if (!isObject(child) || !("props" in child)) return void 0;
19
+ const props = child.props;
20
+ if (!isObject(props)) return void 0;
21
+ const as = props.as;
22
+ return isString(as) && as !== "" ? as : void 0;
23
+ }
24
+ function getTag(child) {
25
+ if (!isObject(child) || !("type" in child)) return void 0;
26
+ const t = child.type;
27
+ if (isString(t)) return t;
28
+ if (typeof t === "function" || isObject(t)) {
29
+ const defaultTag = t[COMPONENT_DEFAULT_TAG];
30
+ if (!isString(defaultTag)) return void 0;
31
+ return getAsProp(child) ?? defaultTag;
32
+ }
33
+ return void 0;
34
+ }
35
+ function isTag(...args) {
36
+ if (isString(args[0])) {
37
+ const set2 = new Set(args);
38
+ return (child2) => {
39
+ const tag2 = getTag(child2);
40
+ return tag2 !== void 0 && set2.has(tag2);
41
+ };
42
+ }
43
+ const [child, ...tags] = args;
44
+ const set = new Set(tags);
45
+ const tag = getTag(child);
46
+ return tag !== void 0 && set.has(tag);
47
+ }
48
+ function isFlowContent(...blockedTags) {
49
+ const set = new Set(blockedTags);
50
+ return (child) => {
51
+ if (isString(child) || isNumber(child)) return true;
52
+ const tag = getTag(child);
53
+ return tag === void 0 || !set.has(tag);
54
+ };
55
+ }
56
+ export {
57
+ getTag,
58
+ isFlowContent,
59
+ isObject,
60
+ isString,
61
+ isTag
62
+ };
@@ -139,7 +139,7 @@ interface BaseClassOptions {
139
139
  baseClassName?: ClassName;
140
140
  }
141
141
 
142
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
142
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string | undefined;
143
143
 
144
144
  interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
145
145
  recipeMap?: Record<string, RecipeTarget<TVariants>>;
@@ -217,7 +217,9 @@ type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
217
217
  type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
218
218
  type AriaResult = ValidResult | AriaInvalidResult;
219
219
 
220
- type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly AriaResult[];
220
+ type AriaRule<C extends AriaContext = AriaContext> = ((context: C) => readonly AriaResult[]) & {
221
+ readonly readsProps?: readonly string[];
222
+ };
221
223
 
222
224
  type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
223
225
 
@@ -268,6 +270,11 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
268
270
  readonly normalize?: NormalizeFn<NoInfer<Props>>;
269
271
  readonly styling?: StylingOptions<V, TPreset, TPlugin>;
270
272
  readonly enforcement?: EnforcementOptions<TAllowed>;
273
+ /**
274
+ * Adapter-resolved diagnostics default, spread in by `resolveAdapterCommonOptions`. Not meant to
275
+ * be set directly by component authors — use `enforcement.diagnostics` to override per component.
276
+ */
277
+ readonly diagnostics?: Diagnostics;
271
278
  };
272
279
 
273
280
  type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolean;