praxis-kit 3.1.0 → 4.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.
@@ -241697,17 +241697,17 @@ Node text: ${this.#forgottenText}`;
241697
241697
  }
241698
241698
  });
241699
241699
 
241700
- // ../codemod/src/index.ts
241700
+ // ../../tooling/codemod/src/index.ts
241701
241701
  import { fileURLToPath } from "url";
241702
241702
 
241703
- // ../codemod/src/cli/usage.ts
241703
+ // ../../tooling/codemod/src/cli/usage.ts
241704
241704
  import { readFileSync } from "fs";
241705
241705
  var usage = readFileSync(new URL("./usage.md", import.meta.url), "utf8");
241706
241706
  function printUsage() {
241707
241707
  console.error(usage);
241708
241708
  }
241709
241709
 
241710
- // ../codemod/src/cli/build-project.ts
241710
+ // ../../tooling/codemod/src/cli/build-project.ts
241711
241711
  var import_ts_morph = __toESM(require_ts_morph(), 1);
241712
241712
  function buildProject(glob, tsconfig) {
241713
241713
  const project = tsconfig ? new import_ts_morph.Project({ tsConfigFilePath: tsconfig }) : new import_ts_morph.Project({ skipAddingFilesFromTsConfig: true });
@@ -241715,7 +241715,7 @@ function buildProject(glob, tsconfig) {
241715
241715
  return project;
241716
241716
  }
241717
241717
 
241718
- // ../codemod/src/cli/create-command.ts
241718
+ // ../../tooling/codemod/src/cli/create-command.ts
241719
241719
  function createCommand(command) {
241720
241720
  return (argv) => {
241721
241721
  const options = command.parse(argv);
@@ -241732,16 +241732,16 @@ function createCommand(command) {
241732
241732
  };
241733
241733
  }
241734
241734
 
241735
- // ../codemod/src/cli/parse-options.ts
241735
+ // ../../tooling/codemod/src/cli/parse-options.ts
241736
241736
  import { parseArgs } from "util";
241737
241737
 
241738
- // ../codemod/src/cli/constants.ts
241738
+ // ../../tooling/codemod/src/cli/constants.ts
241739
241739
  var DEFAULT_FROM = "createPolymorphicComponent";
241740
241740
  var DEFAULT_TO = "createContractComponent";
241741
241741
  var TS_ONLY_GLOB = "**/*.{ts,tsx}";
241742
241742
  var ALL_SOURCE_GLOB = "**/*.{ts,tsx,cts,mts,js,jsx,cjs,mjs}";
241743
241743
 
241744
- // ../codemod/src/cli/options.ts
241744
+ // ../../tooling/codemod/src/cli/options.ts
241745
241745
  var sharedOptions = {
241746
241746
  "dry-run": { type: "boolean", default: false },
241747
241747
  verbose: { type: "boolean", default: false },
@@ -241755,7 +241755,7 @@ var tsconfigOption = {
241755
241755
  tsconfig: { type: "string" }
241756
241756
  };
241757
241757
 
241758
- // ../codemod/src/cli/parse-options.ts
241758
+ // ../../tooling/codemod/src/cli/parse-options.ts
241759
241759
  function parseOptions(argv, options) {
241760
241760
  return parseArgs({ args: argv, options, strict: true }).values;
241761
241761
  }
@@ -241789,34 +241789,34 @@ var parseMigrateOptions = (argv) => parseRenameLikeOptions(argv, ALL_SOURCE_GLOB
241789
241789
  var parseRenameOptions = (argv) => parseRenameLikeOptions(argv, TS_ONLY_GLOB);
241790
241790
  var parseMigratePathsOptions = (argv) => parseBaseOptions(argv, ALL_SOURCE_GLOB);
241791
241791
 
241792
- // ../codemod/src/utils.ts
241792
+ // ../../tooling/codemod/src/utils.ts
241793
241793
  function dryRunSuffix(isDryRun) {
241794
241794
  return isDryRun ? " (dry run \u2014 no files written)" : "";
241795
241795
  }
241796
241796
 
241797
- // ../codemod/src/transforms/migrate-paths.ts
241797
+ // ../../tooling/codemod/src/transforms/migrate-paths.ts
241798
241798
  var import_ts_morph2 = __toESM(require_ts_morph(), 1);
241799
241799
 
241800
- // ../codemod/src/transforms/constants.ts
241800
+ // ../../tooling/codemod/src/transforms/constants.ts
241801
241801
  var SPECIAL_CASES = {
241802
241802
  "@praxis-kit/eslint-plugin": "praxis-kit/eslint"
241803
241803
  };
241804
241804
  var PRAXIS_PACKAGE = /^(?:@praxis-kit|praxis-kit)\//;
241805
241805
 
241806
- // ../codemod/src/transforms/resolve-replacement.ts
241806
+ // ../../tooling/codemod/src/transforms/resolve-replacement.ts
241807
241807
  function resolveReplacement(specifier) {
241808
241808
  if (!specifier.startsWith("@praxis-kit/")) return void 0;
241809
241809
  return SPECIAL_CASES[specifier] ?? specifier.replace("@praxis-kit/", "praxis-kit/");
241810
241810
  }
241811
241811
 
241812
- // ../codemod/src/transforms/utils.ts
241812
+ // ../../tooling/codemod/src/transforms/utils.ts
241813
241813
  function logRewrite(isVerbose, isDryRun, message) {
241814
241814
  if (!isVerbose) return;
241815
241815
  const prefix = isDryRun ? "[dry-run] " : "";
241816
241816
  console.log(prefix + message);
241817
241817
  }
241818
241818
 
241819
- // ../codemod/src/transforms/migrate-paths.ts
241819
+ // ../../tooling/codemod/src/transforms/migrate-paths.ts
241820
241820
  function rewriteModuleSpecifier(decl, options, filePath) {
241821
241821
  const specifier = decl.getModuleSpecifierValue();
241822
241822
  if (specifier === void 0) return 0;
@@ -241874,7 +241874,7 @@ function migratePathsInProject(project, options) {
241874
241874
  };
241875
241875
  }
241876
241876
 
241877
- // ../codemod/src/transforms/rename.ts
241877
+ // ../../tooling/codemod/src/transforms/rename.ts
241878
241878
  var import_ts_morph3 = __toESM(require_ts_morph(), 1);
241879
241879
  function renameInProject(project, options) {
241880
241880
  const { from, to, isDryRun, isVerbose } = options;
@@ -241912,7 +241912,7 @@ function renameInProject(project, options) {
241912
241912
  };
241913
241913
  }
241914
241914
 
241915
- // ../codemod/src/transforms/migrate.ts
241915
+ // ../../tooling/codemod/src/transforms/migrate.ts
241916
241916
  function migrate(project, options) {
241917
241917
  const renames = renameInProject(project, options);
241918
241918
  const paths = migratePathsInProject(project, options);
@@ -241924,25 +241924,25 @@ function migrate(project, options) {
241924
241924
  };
241925
241925
  }
241926
241926
 
241927
- // ../codemod/src/commands/migrate.ts
241927
+ // ../../tooling/codemod/src/commands/migrate.ts
241928
241928
  var runMigrate = createCommand({
241929
241929
  parse: parseMigrateOptions,
241930
241930
  execute: migrate
241931
241931
  });
241932
241932
 
241933
- // ../codemod/src/commands/migrate-paths.ts
241933
+ // ../../tooling/codemod/src/commands/migrate-paths.ts
241934
241934
  var runMigratePaths = createCommand({
241935
241935
  parse: parseMigratePathsOptions,
241936
241936
  execute: migratePathsInProject
241937
241937
  });
241938
241938
 
241939
- // ../codemod/src/commands/rename.ts
241939
+ // ../../tooling/codemod/src/commands/rename.ts
241940
241940
  var runRename = createCommand({
241941
241941
  parse: parseRenameOptions,
241942
241942
  execute: renameInProject
241943
241943
  });
241944
241944
 
241945
- // ../codemod/src/index.ts
241945
+ // ../../tooling/codemod/src/index.ts
241946
241946
  function main() {
241947
241947
  const [, , command, ...rest] = process.argv;
241948
241948
  if (!command || command === "--help" || command === "-h") {
@@ -1,258 +1,2 @@
1
- import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
2
-
3
- type AnyRecord = Record<string, unknown>;
4
-
5
- type IntrinsicTag = keyof HTMLElementTagNameMap;
6
-
7
- type ElementType = IntrinsicTag | (string & {});
8
-
9
- declare const KNOWN_ARIA_ROLES: readonly ["alert", "alertdialog", "application", "article", "banner", "blockquote", "button", "caption", "cell", "checkbox", "code", "columnheader", "combobox", "complementary", "contentinfo", "definition", "deletion", "dialog", "document", "emphasis", "feed", "figure", "form", "generic", "grid", "gridcell", "group", "heading", "img", "insertion", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "meter", "navigation", "none", "note", "option", "paragraph", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "strong", "subscript", "superscript", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "time", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem"];
10
- type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
11
-
12
- type AriaRole = KnownAriaRole | (string & {});
13
-
14
- type Booleanish = boolean | 'true' | 'false';
15
-
16
- type ClassName = string | string[];
17
-
18
- type EmptyRecord = Record<never, never>;
19
-
20
- type IntrinsicProps = AnyRecord & {
21
- role?: AriaRole;
22
- };
23
-
24
- type NonEmptyArray<T> = [T, ...T[]];
25
-
26
- type Numberish = number | `${number}`;
27
-
28
- type Primitive = string | number | boolean;
29
-
30
- type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
31
-
32
- type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
33
-
34
- type CardinalityInput = {
35
- min?: number;
36
- max?: number;
37
- };
38
-
39
- type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
40
-
41
- type ChildRulePosition = 'first' | 'last' | 'any';
42
-
43
- type ChildRuleInput<T = unknown, U extends T = T> = {
44
- name: string;
45
- match: ChildRuleMatch<T, U>;
46
- cardinality?: CardinalityInput;
47
- position?: ChildRulePosition;
48
- /**
49
- * Optional component-type reference for O(1) dispatch index.
50
- * When provided for every rule, the matcher reads child.type instead of
51
- * calling every match function on every child (O(n×m) → O(n+m)).
52
- */
53
- type?: unknown;
54
- };
55
-
56
- type ValidResult = {
57
- valid: true;
58
- };
59
-
60
- type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
61
-
62
- type VariantValue$1 = string | string[];
63
-
64
- type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
65
-
66
- type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
67
-
68
- type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
69
-
70
- type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
71
- type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
72
- type CompoundVariantConditions<V extends VariantMap> = Simplify<{
73
- [K in keyof V]: CompoundVariantConditionValue<V, K>;
74
- }>;
75
- type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
76
- type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
77
- type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
78
- class: VariantValue$1;
79
- };
80
-
81
- interface CVACompounds<V extends VariantMap> {
82
- compoundVariants?: readonly CompoundVariant<V>[];
83
- }
84
-
85
- type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
86
- type DefaultVariants<V extends VariantMap> = {
87
- [K in keyof V]?: VariantValue<keyof V[K] & string>;
88
- };
89
-
90
- interface CVADefaults<V extends VariantMap> {
91
- defaultVariants?: DefaultVariants<V>;
92
- }
93
-
94
- interface CVAVariants<V extends VariantMap> {
95
- variants?: V;
96
- }
97
-
98
- /**
99
- * A partial selection of variant states authored at factory definition time.
100
- *
101
- * Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
102
- * resolve the union at constraint-check time without deferred conditional types.
103
- */
104
- type VariantSelection<V extends VariantMap> = {
105
- [K in keyof V]?: keyof V[K];
106
- };
107
-
108
- /**
109
- * A static, immutable map of named presets to partial variant selections.
110
- *
111
- * Presets are named bundles of variant props that callers activate by key,
112
- * avoiding the need to repeat variant combinations at each call site.
113
- */
114
- type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
115
-
116
- type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
117
-
118
- interface BaseClassOptions {
119
- baseClassName?: ClassName;
120
- }
121
-
122
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
123
-
124
- interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
125
- recipeMap?: Record<string, RecipeTarget<TVariants>>;
126
- }
127
-
128
- interface TagMapOptions {
129
- tagMap?: TagMap;
130
- }
131
-
132
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
133
-
134
- type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
135
-
136
- type StyleOptions<TVariants extends VariantMap = VariantMap> = Simplify<BaseClassOptions & CVASystemOptions<TVariants>>;
137
-
138
- type ClassPipelineOptions<TVariants extends VariantMap = VariantMap> = Simplify<StyleOptions<TVariants> & CompositionOptions<TVariants>>;
139
-
140
- type OwnedPropKeys = ReadonlySet<string>;
141
-
142
- type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
143
- pipeline: ClassPipelineFn;
144
- ownedKeys?: OwnedPropKeys;
145
- readonly _pluginProps?: TProps;
146
- }>;
147
-
148
- type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, strict: StrictMode) => ClassPlugin<TProps>;
149
-
150
- type AriaContext = {
151
- readonly tag: IntrinsicTag;
152
- readonly implicitRole: AriaRole | undefined;
153
- readonly effectiveRole: string | undefined;
154
- readonly props: ReadonlyDeep<IntrinsicProps>;
155
- };
156
-
157
- type RemoveAttributeFixKind = `removeAttribute:${string}`;
158
- type InjectLiveFixKind = `injectLive:${string}`;
159
- type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
160
-
161
- type AriaFixResult = {
162
- applied: false;
163
- next: ReadonlyDeep<IntrinsicProps>;
164
- } | {
165
- applied: true;
166
- next: ReadonlyDeep<IntrinsicProps>;
167
- previous: ReadonlyDeep<IntrinsicProps>;
168
- };
169
- type AriaFix = {
170
- readonly kind: FixKind;
171
- readonly priority?: number;
172
- readonly source?: string;
173
- readonly apply: (context: AriaContext) => AriaFixResult;
174
- };
175
-
176
- type Severity = 'error' | 'warning' | (string & {});
177
-
178
- type AriaInvalidBase<M extends string = string> = {
179
- valid: false;
180
- severity: Severity;
181
- message: M;
182
- attribute?: string;
183
- };
184
- type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
185
- fixable: true;
186
- fix: AriaFix;
187
- };
188
- type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
189
- fixable: false;
190
- };
191
- type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
192
- type AriaResult = ValidResult | AriaInvalidResult;
193
-
194
- type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly AriaResult[];
195
-
196
- type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
197
-
198
- type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
199
- readonly strict?: StrictMode;
200
- readonly aria?: readonly AriaRule[];
201
- readonly children?: readonly ChildRuleInput[];
202
- readonly props?: readonly PropNormalizer[];
203
- /** Restricts the `as` prop to this set of tags. Violations route through strict mode. */
204
- readonly allowedAs?: readonly TAllowed[];
205
- };
206
-
207
- type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
208
- readonly base?: ClassName;
209
- readonly variants?: V;
210
- readonly defaults?: Partial<DefaultVariants<V>>;
211
- readonly compounds?: readonly CompoundVariant<V>[];
212
- readonly presets?: TPreset;
213
- readonly tags?: Readonly<TagMap>;
214
- readonly plugin?: ClassPluginFactory<TPluginProps>;
215
- readonly precomputedClasses?: Readonly<Record<string, string>>;
216
- };
217
-
218
- type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
219
- normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
220
- }['normalize'];
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
- readonly tag?: TDefault;
224
- readonly name?: string;
225
- readonly defaults?: Partial<NoInfer<Props>>;
226
- readonly normalize?: NormalizeFn<NoInfer<Props>>;
227
- readonly styling?: StylingOptions<V, TPreset, TPluginProps>;
228
- readonly enforcement?: EnforcementOptions<TAllowed>;
229
- };
230
-
231
- declare const activeProps: PropNormalizer;
232
-
233
- declare const disabledProps: PropNormalizer;
234
-
235
- declare const expandedProps: PropNormalizer;
236
-
237
- declare const invalidProps: PropNormalizer;
238
-
239
- declare const loadingProps: PropNormalizer;
240
-
241
- declare const pressedProps: PropNormalizer;
242
-
243
- declare const readonlyProps: PropNormalizer;
244
-
245
- declare const selectedProps: PropNormalizer;
246
-
247
- declare const activeContract: EnforcementOptions;
248
- declare const disabledContract: EnforcementOptions;
249
- declare const expandedContract: EnforcementOptions;
250
- declare const invalidContract: EnforcementOptions;
251
- declare const loadingContract: EnforcementOptions;
252
- declare const pressedContract: EnforcementOptions;
253
- declare const readonlyContract: EnforcementOptions;
254
- declare const selectedContract: EnforcementOptions;
255
-
256
- declare function mergeContracts(...contracts: readonly EnforcementOptions[]): EnforcementOptions;
257
-
258
- export { type AnyFactoryOptions, type PropNormalizer, activeContract, activeProps, disabledContract, disabledProps, expandedContract, expandedProps, invalidContract, invalidProps, loadingContract, loadingProps, mergeContracts, pressedContract, pressedProps, readonlyContract, readonlyProps, selectedContract, selectedProps };
1
+ export { AnyFactoryOptions, PropNormalizer, activeProps, disabledProps, expandedProps, invalidProps, loadingProps, pressedProps, readonlyProps, selectedProps } from '@praxis-kit/core';
2
+ export { activeContract, disabledContract, expandedContract, invalidContract, loadingContract, mergeContracts, pressedContract, readonlyContract, selectedContract } from '@praxis-kit/core/contract';