@panneau/codemods 5.0.0-alpha.12 → 5.0.0-alpha.14

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.
@@ -1 +1 @@
1
- {"version":3,"file":"mappings.d.ts","sourceRoot":"","sources":["../src/mappings.ts"],"names":[],"mappings":"AAIA,mDAAmD;AACnD,MAAM,WAAW,WAAW;IACxB,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,uFAAuF;IACvF,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IACnE,2FAA2F;IAC3F,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,0FAA0F;IAC1F,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uFAAuF;AACvF,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAmBxC,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAA+B,CAAC;AAqE3F;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CA6G/D,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQlE,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,WA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CAAC"}
package/dist/mappings.js CHANGED
@@ -66,6 +66,19 @@ var text = {
66
66
  renames: TEXT_RENAMES,
67
67
  valueType: "string"
68
68
  };
69
+ var tel = {
70
+ source: "@panneau/fields/tel",
71
+ name: "TelField",
72
+ props: [...TEXT_PROPS.filter((prop) => ![
73
+ "maxLength",
74
+ "prefix",
75
+ "type",
76
+ "inputMode"
77
+ ].includes(prop)), "country"],
78
+ renames: { append: "suffix" },
79
+ valueType: "string",
80
+ note: "Its value is now E.164 (`+15145550199`): convert the numbers kept as typed."
81
+ };
69
82
  var select = {
70
83
  source: "@panneau/fields/select",
71
84
  name: "SelectField",
@@ -134,16 +147,8 @@ var FIELD_TARGETS = {
134
147
  props: [...TEXT_PROPS.filter((prop) => prop !== "suffix"), "defaultScheme"],
135
148
  renames: { prepend: "prefix" }
136
149
  },
137
- telephone: {
138
- ...text,
139
- source: "@panneau/fields/tel",
140
- name: "TelField"
141
- },
142
- tel: {
143
- ...text,
144
- source: "@panneau/fields/tel",
145
- name: "TelField"
146
- },
150
+ telephone: tel,
151
+ tel,
147
152
  number: {
148
153
  source: "@panneau/fields/number",
149
154
  name: "NumberField",
@@ -1 +1 @@
1
- {"version":3,"file":"mappings.js","names":[],"sources":["../src/mappings.ts"],"sourcesContent":["// What v4 code becomes in Panneau 5: the field components, the modules and their exports. The\n// codemods only rewrite what these tables settle, and report the rest.\nimport { kebabCase } from './names';\n\n/** A v5 field component that replaces a v4 one. */\nexport interface FieldTarget {\n /** Module of the v5 component. */\n source: string;\n /** Export of the v5 component. */\n name: string;\n /** Props of the v5 component besides those of every field (`FieldProps`). */\n props: readonly string[];\n /** v4 props that have another name in v5. */\n renames?: Readonly<Record<string, string>>;\n /** Props that give the v5 component the behavior of the v4 one (`widget=\"radios\"`). */\n adds?: Readonly<Record<string, string | true | readonly string[]>>;\n /** The type of the value, for the input of a locale of a localized field in TypeScript. */\n valueType?: 'string' | 'number' | 'boolean';\n /** What to check after the rewrite, when the props of the v4 and v5 components differ. */\n note?: string;\n}\n\n/** Props of every v5 field (`FieldProps` of `@panneau/fields`), plus React's `key`. */\nexport const FIELD_PROPS: readonly string[] = [\n 'key',\n 'value',\n 'onChange',\n 'onBlur',\n 'errors',\n 'disabled',\n 'readOnly',\n 'required',\n 'label',\n 'description',\n 'name',\n 'id',\n 'autoFocus',\n 'aria-label',\n 'className',\n 'labelClassName',\n 'descriptionClassName',\n 'errorsClassName',\n];\n\n/** v4 props of every field with another name in v5. */\nexport const FIELD_RENAMES: Readonly<Record<string, string>> = { helpText: 'description' };\n\nconst TEXT_PROPS = [\n 'placeholder',\n 'maxLength',\n 'prefix',\n 'suffix',\n 'type',\n 'inputMode',\n 'autoComplete',\n 'controlClassName',\n 'inputClassName',\n];\nconst TEXT_RENAMES = { prepend: 'prefix', append: 'suffix' };\nconst SELECT_PROPS = ['options', 'placeholder', 'multiple', 'widget', 'controlClassName'];\nconst MEDIA_PROPS = [\n 'accept',\n 'adapter',\n 'image',\n 'itemTitle',\n 'maxSize',\n 'multiple',\n 'refreshInterval',\n 'resource',\n 'sources',\n 'stateKey',\n 'uploadSource',\n];\nconst MEDIA_NOTE = 'it needs `resource`, the id of the media library, and the `mediaPlugin`';\n\nconst text: FieldTarget = {\n source: '@panneau/fields/text',\n name: 'TextField',\n props: TEXT_PROPS,\n renames: TEXT_RENAMES,\n valueType: 'string',\n};\nconst select: FieldTarget = {\n source: '@panneau/fields/select',\n name: 'SelectField',\n props: SELECT_PROPS,\n};\nconst relation: FieldTarget = {\n source: '@panneau/fields/relation',\n name: 'RelationField',\n props: ['resource', 'multiple', 'onCreate', 'placeholder', 'source', 'controlClassName'],\n note: 'it searches the resource through the relation source of the app: `resource` is its id',\n};\nconst media: FieldTarget = {\n source: '@panneau/media',\n name: 'MediaField',\n props: MEDIA_PROPS,\n note: MEDIA_NOTE,\n};\nconst image: FieldTarget = {\n source: '@panneau/media',\n name: 'ImageField',\n props: [\n ...MEDIA_PROPS,\n 'cropRequired',\n 'enforceRatios',\n 'focalPoint',\n 'ratios',\n 'rotate',\n 'transformBase',\n ],\n note: MEDIA_NOTE,\n};\n\n/**\n * The v5 component of each v4 field, by the v4 id in kebab case: `useFieldComponent('date_time')`\n * and `@panneau/field-date-time` both give `date-time`, as v4 looked components up by their name\n * in Pascal case.\n */\nexport const FIELD_TARGETS: Readonly<Record<string, FieldTarget>> = {\n text,\n textarea: {\n source: '@panneau/fields/textarea',\n name: 'TextAreaField',\n valueType: 'string',\n props: ['maxLength', 'placeholder', 'rows', 'textAreaClassName'],\n },\n email: { ...text, source: '@panneau/fields/email', name: 'EmailField' },\n url: {\n source: '@panneau/fields/url',\n name: 'UrlField',\n valueType: 'string',\n props: [...TEXT_PROPS.filter((prop) => prop !== 'suffix'), 'defaultScheme'],\n renames: { prepend: 'prefix' },\n },\n telephone: { ...text, source: '@panneau/fields/tel', name: 'TelField' },\n tel: { ...text, source: '@panneau/fields/tel', name: 'TelField' },\n number: {\n source: '@panneau/fields/number',\n name: 'NumberField',\n valueType: 'number',\n props: [\n 'controlClassName',\n 'formatOptions',\n 'inputClassName',\n 'max',\n 'min',\n 'placeholder',\n 'step',\n 'suffix',\n ],\n renames: { append: 'suffix' },\n },\n color: {\n source: '@panneau/fields/color',\n name: 'ColorField',\n valueType: 'string',\n props: TEXT_PROPS.filter((prop) => !['type', 'prefix', 'maxLength'].includes(prop)),\n },\n date: {\n source: '@panneau/fields/date',\n name: 'DateField',\n valueType: 'string',\n props: ['controlClassName', 'max', 'min'],\n },\n 'date-time': {\n source: '@panneau/fields/datetime',\n name: 'DateTimeField',\n valueType: 'string',\n props: ['controlClassName', 'hourCycle', 'timeZone', 'withSeconds'],\n },\n datetime: {\n source: '@panneau/fields/datetime',\n name: 'DateTimeField',\n valueType: 'string',\n props: ['controlClassName', 'hourCycle', 'timeZone', 'withSeconds'],\n },\n select,\n radios: { ...select, adds: { widget: 'radios' } },\n checkboxes: { ...select, adds: { multiple: true, widget: 'checkboxes' } },\n toggles: { ...select, adds: { multiple: true, widget: 'checkboxes' } },\n toggle: {\n source: '@panneau/fields/boolean',\n name: 'BooleanField',\n valueType: 'boolean',\n props: ['widget', 'controlClassName'],\n adds: { widget: 'switch' },\n },\n checkbox: {\n source: '@panneau/fields/boolean',\n name: 'BooleanField',\n valueType: 'boolean',\n props: ['widget', 'controlClassName'],\n },\n embed: {\n source: '@panneau/fields/embed',\n name: 'EmbedField',\n props: ['embedSource', 'placeholder'],\n },\n localized: {\n source: '@panneau/fields/localized',\n name: 'LocalizedField',\n props: ['children', 'localeClassName', 'locales'],\n },\n fields: {\n source: '@panneau/fields/group',\n name: 'GroupField',\n props: ['fields', 'fieldsClassName', 'path'],\n note: '`fields` are fields of the definition of Panneau 5 (`Field[]` of `@panneau/protocol`)',\n },\n items: {\n source: '@panneau/fields/repeater',\n name: 'RepeaterField',\n props: ['fields', 'itemClassName', 'max', 'min', 'path', 'types'],\n note: 'its items are made of fields of the definition of Panneau 5, or of block `types`',\n },\n item: relation,\n 'resource-item': relation,\n upload: media,\n media,\n video: { ...media, adds: { accept: ['video/*'] } },\n audio: { ...media, adds: { accept: ['audio/*'] } },\n document: media,\n image,\n 'image-upload': image,\n 'video-upload': { ...media, adds: { accept: ['video/*'] } },\n 'audio-upload': { ...media, adds: { accept: ['audio/*'] } },\n 'document-upload': media,\n};\n\n/** v4 fields with no v5 component, and what replaces them. */\nexport const FIELDS_WITHOUT_TARGET: Readonly<Record<string, string>> = {\n html: 'the `richtext` field of `@panneau/editor` replaces it',\n password: 'Panneau 5 has no password field',\n autocomplete: 'Panneau 5 has no autocomplete field: a `select` or a `relation` replaces it',\n display: 'Panneau 5 has no display field: read-only fields (`readOnly`) replace it',\n 'input-group':\n 'Panneau 5 has no input group: the `prefix` and `suffix` of text fields replace it',\n import: 'Panneau 5 has no import field: the `import` action replaces it',\n};\n\n/** The v5 component of a v4 field id (`date_time`, `DateTime`, `date-time`). */\nexport function getFieldTarget(id: string): FieldTarget | null {\n return FIELD_TARGETS[kebabCase(id)] ?? null;\n}\n\n/** v4 namespaces of the `components` prop of the app, and the kinds of v5 plugins. */\nexport const NAMESPACES: Readonly<\n Record<string, { kind: string | null; note?: string; constant: string }>\n> = {\n fields: { kind: 'fields', constant: 'FIELDS_NAMESPACE' },\n displays: {\n kind: 'displays',\n constant: 'DISPLAYS_NAMESPACE',\n note: 'displays of Panneau 5 get `value`, `item`, `field` and `column` (`DisplayProps` of `@panneau/lists`)',\n },\n actions: {\n kind: 'actions',\n constant: 'ACTIONS_NAMESPACE',\n note: 'actions of Panneau 5 are handlers of `client` actions of the definition, not buttons: see decision 0017',\n },\n pages: {\n kind: 'pages',\n constant: 'PAGES_NAMESPACE',\n note: 'pages of Panneau 5 render inside the shell of the app: drop `MainLayout` and `PageHeader`',\n },\n previews: {\n kind: 'previews',\n constant: 'PREVIEWS_NAMESPACE',\n note: 'previews of Panneau 5 get `PreviewProps` of `@panneau/core`',\n },\n lists: {\n kind: 'listLayouts',\n constant: 'LISTS_NAMESPACE',\n note: 'list layouts of Panneau 5 render the list state of `@panneau/lists`',\n },\n forms: { kind: null, constant: 'FORMS_NAMESPACE' },\n filters: { kind: null, constant: 'FILTERS_NAMESPACE' },\n modals: { kind: null, constant: 'MODALS_NAMESPACE' },\n buttons: { kind: null, constant: 'BUTTONS_NAMESPACE' },\n app: { kind: null, constant: 'APP_NAMESPACE' },\n};\n\n/** The namespace of a constant of `@panneau/core/contexts` (`FIELDS_NAMESPACE`). */\nexport function getNamespaceOfConstant(constant: string): string | null {\n return (\n Object.entries(NAMESPACES).find(([, namespace]) => namespace.constant === constant)?.[0] ??\n null\n );\n}\n\n/**\n * Packages of v4 that have a package of the same name in v5. Their main entry point is v5 for\n * every name but those listed here, which only v4 exported (`default` is the default export).\n */\nexport const SHARED_PACKAGES: Readonly<Record<string, readonly string[]>> = {\n '@panneau/actions': ['default'],\n '@panneau/app': [\n 'default',\n 'MainLayout',\n 'GuestLayout',\n 'PageHeader',\n 'ResourceFilters',\n 'ResourceItemsList',\n 'ResourceForm',\n ],\n '@panneau/auth': [\n 'default',\n 'AuthProvider',\n 'useAuth',\n 'useUser',\n 'useSetUser',\n 'useLogout',\n 'useLoggedIn',\n 'useAuthCheck',\n 'useAuthLogin',\n 'useAuthLogout',\n 'useAuthRegister',\n 'useAuthRequestPassword',\n 'useAuthResetPassword',\n ],\n '@panneau/core': [\n 'default',\n 'ComponentsManager',\n 'DefinitionsManager',\n 'EventsManager',\n 'FieldsManager',\n 'FontsParser',\n 'FormsManager',\n 'MediasParser',\n 'Tracking',\n // Types of v4. `Form` and `FormStatus` are left out: v5 exports types of the same names.\n 'Action',\n 'ActionDefinition',\n 'ActionValue',\n 'AudioMedia',\n 'Breadcrumb',\n 'BreakpointsSize',\n 'Button',\n 'ButtonElement',\n 'ButtonSize',\n 'ButtonTheme',\n 'ButtonType',\n 'Column',\n 'ComponentsMap',\n 'ControlSize',\n 'Definition',\n 'DialogSize',\n 'DropdownAlign',\n 'Feedback',\n 'Field',\n 'FieldDefinition',\n 'FieldOption',\n 'FieldSettings',\n 'Filter',\n 'Font',\n 'FormDefinition',\n 'FormError',\n 'ImageMedia',\n 'Item',\n 'Label',\n 'Media',\n 'MediaFile',\n 'MediaType',\n 'MenuItem',\n 'Message',\n 'MessageValue',\n 'MessageValues',\n 'Modal',\n 'PageDefinition',\n 'Pagination',\n 'PanneauAuth',\n 'PanneauComponents',\n 'PanneauDefinition',\n 'PanneauIntl',\n 'PanneauIntlValues',\n 'PanneauMenuItem',\n 'PanneauMenus',\n 'PanneauPages',\n 'PanneauTheme',\n 'Preview',\n 'Resource',\n 'ResourceForm',\n 'ResourceForms',\n 'ResourceIndex',\n 'ResourceIntl',\n 'ResourceIntlValues',\n 'ResourceItem',\n 'ResourcePages',\n 'ResourceType',\n 'RouteDefinition',\n 'Routes',\n 'SelectOption',\n 'StatusCode',\n 'TableColumn',\n 'Toggle',\n 'TrackingVariables',\n 'TriggerUpdate',\n 'Uppy',\n 'User',\n 'VideoMedia',\n ],\n '@panneau/data': [\n 'default',\n 'Api',\n 'BaseApi',\n 'DataProvider',\n 'ApiProvider',\n 'useApi',\n 'QueryProvider',\n 'useQueryContext',\n 'useItem',\n 'useItems',\n 'UseItemsResponse',\n 'useResourceDestroy',\n 'useResourceItem',\n 'useResourceItems',\n 'useResourceStore',\n 'useResourceUpdate',\n 'useResourceClone',\n 'useResourceRestore',\n ],\n '@panneau/fields': ['default'],\n '@panneau/forms': ['default'],\n '@panneau/intl': [\n 'default',\n 'IntlManager',\n 'IntlProvider',\n 'ResourceMessage',\n 'useResourceValues',\n ],\n '@panneau/lists': ['default'],\n};\n\n/** Packages that only exist in v4. Their imports are rewritten or reported. */\nexport function isV4Package(name: string): boolean {\n return (\n /^@panneau\\/(action|display|element|field|filter|form|list|modal)-/.test(name) ||\n [\n '@panneau/ckeditor',\n '@panneau/displays',\n '@panneau/filters',\n '@panneau/form',\n '@panneau/medias',\n '@panneau/modals',\n '@panneau/panneau',\n '@panneau/themes',\n '@panneau/uppy',\n ].includes(name)\n );\n}\n\n/** What replaces v4 exports, by module and name, for the messages of the report. */\nexport const REPLACEMENTS: Readonly<Record<string, Readonly<Record<string, string>>>> = {\n '@panneau/core/contexts': {\n usePanneauResource:\n '`useResource(id)` of `@panneau/core` gives `{ resource, form, list }`: the fields of the resource are `resource.fields`, fields of the protocol',\n usePanneauResources:\n '`useDefinition()` of `@panneau/data/query` gives the definition, with its `resources`',\n useResource:\n 'a field of Panneau 5 gets its values from its props: `useResource(id)` of `@panneau/core` resolves a resource of the definition',\n useUrlGenerator:\n 'Panneau 5 has no named routes: link to `{basePath}/resources/{resource}/{id}` (decision 0019), or run a resource action',\n usePanneau:\n '`usePanneau()` of `@panneau/core` gives the definition and the plugins: custom keys of the definition move to `settings` of the resources or fields',\n useFormSetValue:\n '`useFormContext().setValue(path, value)` of `@panneau/forms` sets the value of another field',\n useForm:\n 'a field of Panneau 5 reads its form through `useFormContext()` of `@panneau/forms`',\n useLocales: '`useFieldsContext().locales` of `@panneau/fields`',\n useListComponent:\n 'list layouts come from plugins (`listLayouts`); `ListView` of `@panneau/lists` renders one',\n useModalComponent: '`Dialog` of `@panneau/ui`',\n useDisplayComponent:\n 'displays come from plugins (`displays`); `@panneau/lists` exports the built-in ones',\n ResourceProvider: 'Panneau 5 has no resource context: pass the resource id as a prop',\n },\n '@panneau/data': {\n useResourceItems:\n '`useResourceList(resource, query)` of `@panneau/data/query`: its `data.data` are the items, and the query is a list query of the protocol (`page`, `perPage`, `filter`)',\n useResourceItem:\n '`useResourceItem(resource, id)` of `@panneau/data/query`: its `data` is the item',\n useItems: '`useResourceList(resource, query)` of `@panneau/data/query`',\n useItem: '`useResourceItem(resource, id)` of `@panneau/data/query`',\n },\n '@panneau/app': {\n MainLayout: 'pages of Panneau 5 render inside the shell of the app: drop the layout',\n PageHeader:\n 'pages of Panneau 5 render inside the shell of the app, which shows their title',\n ResourceItemsList:\n '`ListView` of `@panneau/lists`, with `useResourceList()` of `@panneau/data/query`',\n ResourceForm: '`FormView` of `@panneau/forms`',\n },\n '@panneau/medias': {\n MediasBrowserProvider:\n 'the media field and picker of `@panneau/media` (`mediaPlugin`) browse the media libraries through the adapter',\n },\n '@panneau/intl': {\n default: 'messages come with the packages and with plugins (`locales`)',\n useResourceValues: 'labels of resources come from the definition, already translated',\n },\n '@panneau/element-button': {\n default:\n '`Button` of `@panneau/ui` (`variant` and `tone` instead of `theme`, Lucide icons)',\n },\n '@panneau/element-buttons': { default: '`Inline` and `Button` of `@panneau/ui`' },\n '@panneau/element-modal': { default: '`Dialog` of `@panneau/ui`' },\n '@panneau/modal-dialog': { default: '`Dialog` of `@panneau/ui`' },\n '@panneau/element-card': { default: '`Card` of `@panneau/ui`' },\n '@panneau/element-alert': { default: '`Alert` of `@panneau/ui`' },\n '@panneau/element-loading': {\n default:\n '`Skeleton` of `@panneau/ui` while content loads, `Spinner` for an operation in progress',\n },\n '@panneau/element-icon': { default: '`Icon` of `@panneau/ui`, with Lucide icons' },\n '@panneau/element-label': { default: 'labels are given to fields and primitives as `label`' },\n '@panneau/element-select': {\n default: '`Select` of `@panneau/ui`, or `SelectField` of `@panneau/fields/select`',\n },\n '@panneau/element-radios': { default: '`RadioGroup` of `@panneau/ui`' },\n '@panneau/element-range': { default: '`Slider` of `@panneau/ui`' },\n '@panneau/element-table': { default: '`ListView` of `@panneau/lists`' },\n '@panneau/form': { default: '`Form` of `@panneau/forms`, with fields of the protocol' },\n};\n"],"mappings":";;;AAuBA,IAAa,cAAiC;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;;AAGA,IAAa,gBAAkD,EAAE,UAAU,cAAc;AAEzF,IAAM,aAAa;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AACA,IAAM,eAAe;CAAE,SAAS;CAAU,QAAQ;AAAS;AAC3D,IAAM,eAAe;CAAC;CAAW;CAAe;CAAY;CAAU;AAAkB;AACxF,IAAM,cAAc;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AACA,IAAM,aAAa;AAEnB,IAAM,OAAoB;CACtB,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW;AACf;AACA,IAAM,SAAsB;CACxB,QAAQ;CACR,MAAM;CACN,OAAO;AACX;AACA,IAAM,WAAwB;CAC1B,QAAQ;CACR,MAAM;CACN,OAAO;EAAC;EAAY;EAAY;EAAY;EAAe;EAAU;CAAkB;CACvF,MAAM;AACV;AACA,IAAM,QAAqB;CACvB,QAAQ;CACR,MAAM;CACN,OAAO;CACP,MAAM;AACV;AACA,IAAM,QAAqB;CACvB,QAAQ;CACR,MAAM;CACN,OAAO;EACH,GAAG;EACH;EACA;EACA;EACA;EACA;EACA;CACJ;CACA,MAAM;AACV;;;;;;AAOA,IAAa,gBAAuD;CAChE;CACA,UAAU;EACN,QAAQ;EACR,MAAM;EACN,WAAW;EACX,OAAO;GAAC;GAAa;GAAe;GA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A,OAAO;EACH,MAAM;EACN,UAAU;EACV,MAAM;CACV;CACA,OAAO;EAAE,MAAM;EAAM,UAAU;CAAkB;CACjD,SAAS;EAAE,MAAM;EAAM,UAAU;CAAoB;CACrD,QAAQ;EAAE,MAAM;EAAM,UAAU;CAAmB;CACnD,SAAS;EAAE,MAAM;EAAM,UAAU;CAAoB;CACrD,KAAK;EAAE,MAAM;EAAM,UAAU;CAAgB;AACjD;;AAGA,SAAgB,uBAAuB,UAAiC;CACpE,OACI,OAAO,QAAQ,UAAU,CAAC,CAAC,MAAM,GAAG,eAAe,UAAU,aAAa,QAAQ,CAAC,GAAG,MACtF;AAER;;;;;AAMA,IAAa,kBAA+D;CACxE,oBAAoB,CAAC,SAAS;CAC9B,gBAAgB;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;CACA,iBAAiB;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;CACA,iBAAiB;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;CACA,iBAAiB;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;CACA,mBAAmB,CAAC,SAAS;CAC7B,kBAAkB,CAAC,SAAS;CAC5B,iBAAiB;EACb;EACA;EACA;EACA;EACA;CACJ;CACA,kBAAkB,CAAC,SAAS;AAChC;;AAGA,SAAgB,YAAY,MAAuB;CAC/C,OACI,oEAAoE,KAAK,IAAI,KAC7E;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC,CAAC,SAAS,IAAI;AAEvB;;AAGA,IAAa,eAA2E;CACpF,0BAA0B;EACtB,oBACI;EACJ,qBACI;EACJ,aACI;EACJ,iBACI;EACJ,YACI;EACJ,iBACI;EACJ,SACI;EACJ,YAAY;EACZ,kBACI;EACJ,mBAAmB;EACnB,qBACI;EACJ,kBAAkB;CACtB;CACA,iBAAiB;EACb,kBACI;EACJ,iBACI;EACJ,UAAU;EACV,SAAS;CACb;CACA,gBAAgB;EACZ,YAAY;EACZ,YACI;EACJ,mBACI;EACJ,cAAc;CAClB;CACA,mBAAmB,EACf,uBACI,gHACR;CACA,iBAAiB;EACb,SAAS;EACT,mBAAmB;CACvB;CACA,2BAA2B,EACvB,SACI,oFACR;CACA,4BAA4B,EAAE,SAAS,yCAAyC;CAChF,0BAA0B,EAAE,SAAS,4BAA4B;CACjE,yBAAyB,EAAE,SAAS,4BAA4B;CAChE,yBAAyB,EAAE,SAAS,0BAA0B;CAC9D,0BAA0B,EAAE,SAAS,2BAA2B;CAChE,4BAA4B,EACxB,SACI,0FACR;CACA,yBAAyB,EAAE,SAAS,6CAA6C;CACjF,0BAA0B,EAAE,SAAS,uDAAuD;CAC5F,2BAA2B,EACvB,SAAS,0EACb;CACA,2BAA2B,EAAE,SAAS,gCAAgC;CACtE,0BAA0B,EAAE,SAAS,4BAA4B;CACjE,0BAA0B,EAAE,SAAS,iCAAiC;CACtE,iBAAiB,EAAE,SAAS,0DAA0D;AAC1F"}
1
+ {"version":3,"file":"mappings.js","names":[],"sources":["../src/mappings.ts"],"sourcesContent":["// What v4 code becomes in Panneau 5: the field components, the modules and their exports. The\n// codemods only rewrite what these tables settle, and report the rest.\nimport { kebabCase } from './names';\n\n/** A v5 field component that replaces a v4 one. */\nexport interface FieldTarget {\n /** Module of the v5 component. */\n source: string;\n /** Export of the v5 component. */\n name: string;\n /** Props of the v5 component besides those of every field (`FieldProps`). */\n props: readonly string[];\n /** v4 props that have another name in v5. */\n renames?: Readonly<Record<string, string>>;\n /** Props that give the v5 component the behavior of the v4 one (`widget=\"radios\"`). */\n adds?: Readonly<Record<string, string | true | readonly string[]>>;\n /** The type of the value, for the input of a locale of a localized field in TypeScript. */\n valueType?: 'string' | 'number' | 'boolean';\n /** What to check after the rewrite, when the props of the v4 and v5 components differ. */\n note?: string;\n}\n\n/** Props of every v5 field (`FieldProps` of `@panneau/fields`), plus React's `key`. */\nexport const FIELD_PROPS: readonly string[] = [\n 'key',\n 'value',\n 'onChange',\n 'onBlur',\n 'errors',\n 'disabled',\n 'readOnly',\n 'required',\n 'label',\n 'description',\n 'name',\n 'id',\n 'autoFocus',\n 'aria-label',\n 'className',\n 'labelClassName',\n 'descriptionClassName',\n 'errorsClassName',\n];\n\n/** v4 props of every field with another name in v5. */\nexport const FIELD_RENAMES: Readonly<Record<string, string>> = { helpText: 'description' };\n\nconst TEXT_PROPS = [\n 'placeholder',\n 'maxLength',\n 'prefix',\n 'suffix',\n 'type',\n 'inputMode',\n 'autoComplete',\n 'controlClassName',\n 'inputClassName',\n];\nconst TEXT_RENAMES = { prepend: 'prefix', append: 'suffix' };\nconst SELECT_PROPS = ['options', 'placeholder', 'multiple', 'widget', 'controlClassName'];\nconst MEDIA_PROPS = [\n 'accept',\n 'adapter',\n 'image',\n 'itemTitle',\n 'maxSize',\n 'multiple',\n 'refreshInterval',\n 'resource',\n 'sources',\n 'stateKey',\n 'uploadSource',\n];\nconst MEDIA_NOTE = 'it needs `resource`, the id of the media library, and the `mediaPlugin`';\n\nconst text: FieldTarget = {\n source: '@panneau/fields/text',\n name: 'TextField',\n props: TEXT_PROPS,\n renames: TEXT_RENAMES,\n valueType: 'string',\n};\nconst tel: FieldTarget = {\n source: '@panneau/fields/tel',\n name: 'TelField',\n props: [\n ...TEXT_PROPS.filter(\n (prop) => !['maxLength', 'prefix', 'type', 'inputMode'].includes(prop),\n ),\n 'country',\n ],\n renames: { append: 'suffix' },\n valueType: 'string',\n note: 'Its value is now E.164 (`+15145550199`): convert the numbers kept as typed.',\n};\nconst select: FieldTarget = {\n source: '@panneau/fields/select',\n name: 'SelectField',\n props: SELECT_PROPS,\n};\nconst relation: FieldTarget = {\n source: '@panneau/fields/relation',\n name: 'RelationField',\n props: ['resource', 'multiple', 'onCreate', 'placeholder', 'source', 'controlClassName'],\n note: 'it searches the resource through the relation source of the app: `resource` is its id',\n};\nconst media: FieldTarget = {\n source: '@panneau/media',\n name: 'MediaField',\n props: MEDIA_PROPS,\n note: MEDIA_NOTE,\n};\nconst image: FieldTarget = {\n source: '@panneau/media',\n name: 'ImageField',\n props: [\n ...MEDIA_PROPS,\n 'cropRequired',\n 'enforceRatios',\n 'focalPoint',\n 'ratios',\n 'rotate',\n 'transformBase',\n ],\n note: MEDIA_NOTE,\n};\n\n/**\n * The v5 component of each v4 field, by the v4 id in kebab case: `useFieldComponent('date_time')`\n * and `@panneau/field-date-time` both give `date-time`, as v4 looked components up by their name\n * in Pascal case.\n */\nexport const FIELD_TARGETS: Readonly<Record<string, FieldTarget>> = {\n text,\n textarea: {\n source: '@panneau/fields/textarea',\n name: 'TextAreaField',\n valueType: 'string',\n props: ['maxLength', 'placeholder', 'rows', 'textAreaClassName'],\n },\n email: { ...text, source: '@panneau/fields/email', name: 'EmailField' },\n url: {\n source: '@panneau/fields/url',\n name: 'UrlField',\n valueType: 'string',\n props: [...TEXT_PROPS.filter((prop) => prop !== 'suffix'), 'defaultScheme'],\n renames: { prepend: 'prefix' },\n },\n telephone: tel,\n tel,\n number: {\n source: '@panneau/fields/number',\n name: 'NumberField',\n valueType: 'number',\n props: [\n 'controlClassName',\n 'formatOptions',\n 'inputClassName',\n 'max',\n 'min',\n 'placeholder',\n 'step',\n 'suffix',\n ],\n renames: { append: 'suffix' },\n },\n color: {\n source: '@panneau/fields/color',\n name: 'ColorField',\n valueType: 'string',\n props: TEXT_PROPS.filter((prop) => !['type', 'prefix', 'maxLength'].includes(prop)),\n },\n date: {\n source: '@panneau/fields/date',\n name: 'DateField',\n valueType: 'string',\n props: ['controlClassName', 'max', 'min'],\n },\n 'date-time': {\n source: '@panneau/fields/datetime',\n name: 'DateTimeField',\n valueType: 'string',\n props: ['controlClassName', 'hourCycle', 'timeZone', 'withSeconds'],\n },\n datetime: {\n source: '@panneau/fields/datetime',\n name: 'DateTimeField',\n valueType: 'string',\n props: ['controlClassName', 'hourCycle', 'timeZone', 'withSeconds'],\n },\n select,\n radios: { ...select, adds: { widget: 'radios' } },\n checkboxes: { ...select, adds: { multiple: true, widget: 'checkboxes' } },\n toggles: { ...select, adds: { multiple: true, widget: 'checkboxes' } },\n toggle: {\n source: '@panneau/fields/boolean',\n name: 'BooleanField',\n valueType: 'boolean',\n props: ['widget', 'controlClassName'],\n adds: { widget: 'switch' },\n },\n checkbox: {\n source: '@panneau/fields/boolean',\n name: 'BooleanField',\n valueType: 'boolean',\n props: ['widget', 'controlClassName'],\n },\n embed: {\n source: '@panneau/fields/embed',\n name: 'EmbedField',\n props: ['embedSource', 'placeholder'],\n },\n localized: {\n source: '@panneau/fields/localized',\n name: 'LocalizedField',\n props: ['children', 'localeClassName', 'locales'],\n },\n fields: {\n source: '@panneau/fields/group',\n name: 'GroupField',\n props: ['fields', 'fieldsClassName', 'path'],\n note: '`fields` are fields of the definition of Panneau 5 (`Field[]` of `@panneau/protocol`)',\n },\n items: {\n source: '@panneau/fields/repeater',\n name: 'RepeaterField',\n props: ['fields', 'itemClassName', 'max', 'min', 'path', 'types'],\n note: 'its items are made of fields of the definition of Panneau 5, or of block `types`',\n },\n item: relation,\n 'resource-item': relation,\n upload: media,\n media,\n video: { ...media, adds: { accept: ['video/*'] } },\n audio: { ...media, adds: { accept: ['audio/*'] } },\n document: media,\n image,\n 'image-upload': image,\n 'video-upload': { ...media, adds: { accept: ['video/*'] } },\n 'audio-upload': { ...media, adds: { accept: ['audio/*'] } },\n 'document-upload': media,\n};\n\n/** v4 fields with no v5 component, and what replaces them. */\nexport const FIELDS_WITHOUT_TARGET: Readonly<Record<string, string>> = {\n html: 'the `richtext` field of `@panneau/editor` replaces it',\n password: 'Panneau 5 has no password field',\n autocomplete: 'Panneau 5 has no autocomplete field: a `select` or a `relation` replaces it',\n display: 'Panneau 5 has no display field: read-only fields (`readOnly`) replace it',\n 'input-group':\n 'Panneau 5 has no input group: the `prefix` and `suffix` of text fields replace it',\n import: 'Panneau 5 has no import field: the `import` action replaces it',\n};\n\n/** The v5 component of a v4 field id (`date_time`, `DateTime`, `date-time`). */\nexport function getFieldTarget(id: string): FieldTarget | null {\n return FIELD_TARGETS[kebabCase(id)] ?? null;\n}\n\n/** v4 namespaces of the `components` prop of the app, and the kinds of v5 plugins. */\nexport const NAMESPACES: Readonly<\n Record<string, { kind: string | null; note?: string; constant: string }>\n> = {\n fields: { kind: 'fields', constant: 'FIELDS_NAMESPACE' },\n displays: {\n kind: 'displays',\n constant: 'DISPLAYS_NAMESPACE',\n note: 'displays of Panneau 5 get `value`, `item`, `field` and `column` (`DisplayProps` of `@panneau/lists`)',\n },\n actions: {\n kind: 'actions',\n constant: 'ACTIONS_NAMESPACE',\n note: 'actions of Panneau 5 are handlers of `client` actions of the definition, not buttons: see decision 0017',\n },\n pages: {\n kind: 'pages',\n constant: 'PAGES_NAMESPACE',\n note: 'pages of Panneau 5 render inside the shell of the app: drop `MainLayout` and `PageHeader`',\n },\n previews: {\n kind: 'previews',\n constant: 'PREVIEWS_NAMESPACE',\n note: 'previews of Panneau 5 get `PreviewProps` of `@panneau/core`',\n },\n lists: {\n kind: 'listLayouts',\n constant: 'LISTS_NAMESPACE',\n note: 'list layouts of Panneau 5 render the list state of `@panneau/lists`',\n },\n forms: { kind: null, constant: 'FORMS_NAMESPACE' },\n filters: { kind: null, constant: 'FILTERS_NAMESPACE' },\n modals: { kind: null, constant: 'MODALS_NAMESPACE' },\n buttons: { kind: null, constant: 'BUTTONS_NAMESPACE' },\n app: { kind: null, constant: 'APP_NAMESPACE' },\n};\n\n/** The namespace of a constant of `@panneau/core/contexts` (`FIELDS_NAMESPACE`). */\nexport function getNamespaceOfConstant(constant: string): string | null {\n return (\n Object.entries(NAMESPACES).find(([, namespace]) => namespace.constant === constant)?.[0] ??\n null\n );\n}\n\n/**\n * Packages of v4 that have a package of the same name in v5. Their main entry point is v5 for\n * every name but those listed here, which only v4 exported (`default` is the default export).\n */\nexport const SHARED_PACKAGES: Readonly<Record<string, readonly string[]>> = {\n '@panneau/actions': ['default'],\n '@panneau/app': [\n 'default',\n 'MainLayout',\n 'GuestLayout',\n 'PageHeader',\n 'ResourceFilters',\n 'ResourceItemsList',\n 'ResourceForm',\n ],\n '@panneau/auth': [\n 'default',\n 'AuthProvider',\n 'useAuth',\n 'useUser',\n 'useSetUser',\n 'useLogout',\n 'useLoggedIn',\n 'useAuthCheck',\n 'useAuthLogin',\n 'useAuthLogout',\n 'useAuthRegister',\n 'useAuthRequestPassword',\n 'useAuthResetPassword',\n ],\n '@panneau/core': [\n 'default',\n 'ComponentsManager',\n 'DefinitionsManager',\n 'EventsManager',\n 'FieldsManager',\n 'FontsParser',\n 'FormsManager',\n 'MediasParser',\n 'Tracking',\n // Types of v4. `Form` and `FormStatus` are left out: v5 exports types of the same names.\n 'Action',\n 'ActionDefinition',\n 'ActionValue',\n 'AudioMedia',\n 'Breadcrumb',\n 'BreakpointsSize',\n 'Button',\n 'ButtonElement',\n 'ButtonSize',\n 'ButtonTheme',\n 'ButtonType',\n 'Column',\n 'ComponentsMap',\n 'ControlSize',\n 'Definition',\n 'DialogSize',\n 'DropdownAlign',\n 'Feedback',\n 'Field',\n 'FieldDefinition',\n 'FieldOption',\n 'FieldSettings',\n 'Filter',\n 'Font',\n 'FormDefinition',\n 'FormError',\n 'ImageMedia',\n 'Item',\n 'Label',\n 'Media',\n 'MediaFile',\n 'MediaType',\n 'MenuItem',\n 'Message',\n 'MessageValue',\n 'MessageValues',\n 'Modal',\n 'PageDefinition',\n 'Pagination',\n 'PanneauAuth',\n 'PanneauComponents',\n 'PanneauDefinition',\n 'PanneauIntl',\n 'PanneauIntlValues',\n 'PanneauMenuItem',\n 'PanneauMenus',\n 'PanneauPages',\n 'PanneauTheme',\n 'Preview',\n 'Resource',\n 'ResourceForm',\n 'ResourceForms',\n 'ResourceIndex',\n 'ResourceIntl',\n 'ResourceIntlValues',\n 'ResourceItem',\n 'ResourcePages',\n 'ResourceType',\n 'RouteDefinition',\n 'Routes',\n 'SelectOption',\n 'StatusCode',\n 'TableColumn',\n 'Toggle',\n 'TrackingVariables',\n 'TriggerUpdate',\n 'Uppy',\n 'User',\n 'VideoMedia',\n ],\n '@panneau/data': [\n 'default',\n 'Api',\n 'BaseApi',\n 'DataProvider',\n 'ApiProvider',\n 'useApi',\n 'QueryProvider',\n 'useQueryContext',\n 'useItem',\n 'useItems',\n 'UseItemsResponse',\n 'useResourceDestroy',\n 'useResourceItem',\n 'useResourceItems',\n 'useResourceStore',\n 'useResourceUpdate',\n 'useResourceClone',\n 'useResourceRestore',\n ],\n '@panneau/fields': ['default'],\n '@panneau/forms': ['default'],\n '@panneau/intl': [\n 'default',\n 'IntlManager',\n 'IntlProvider',\n 'ResourceMessage',\n 'useResourceValues',\n ],\n '@panneau/lists': ['default'],\n};\n\n/** Packages that only exist in v4. Their imports are rewritten or reported. */\nexport function isV4Package(name: string): boolean {\n return (\n /^@panneau\\/(action|display|element|field|filter|form|list|modal)-/.test(name) ||\n [\n '@panneau/ckeditor',\n '@panneau/displays',\n '@panneau/filters',\n '@panneau/form',\n '@panneau/medias',\n '@panneau/modals',\n '@panneau/panneau',\n '@panneau/themes',\n '@panneau/uppy',\n ].includes(name)\n );\n}\n\n/** What replaces v4 exports, by module and name, for the messages of the report. */\nexport const REPLACEMENTS: Readonly<Record<string, Readonly<Record<string, string>>>> = {\n '@panneau/core/contexts': {\n usePanneauResource:\n '`useResource(id)` of `@panneau/core` gives `{ resource, form, list }`: the fields of the resource are `resource.fields`, fields of the protocol',\n usePanneauResources:\n '`useDefinition()` of `@panneau/data/query` gives the definition, with its `resources`',\n useResource:\n 'a field of Panneau 5 gets its values from its props: `useResource(id)` of `@panneau/core` resolves a resource of the definition',\n useUrlGenerator:\n 'Panneau 5 has no named routes: link to `{basePath}/resources/{resource}/{id}` (decision 0019), or run a resource action',\n usePanneau:\n '`usePanneau()` of `@panneau/core` gives the definition and the plugins: custom keys of the definition move to `settings` of the resources or fields',\n useFormSetValue:\n '`useFormContext().setValue(path, value)` of `@panneau/forms` sets the value of another field',\n useForm:\n 'a field of Panneau 5 reads its form through `useFormContext()` of `@panneau/forms`',\n useLocales: '`useFieldsContext().locales` of `@panneau/fields`',\n useListComponent:\n 'list layouts come from plugins (`listLayouts`); `ListView` of `@panneau/lists` renders one',\n useModalComponent: '`Dialog` of `@panneau/ui`',\n useDisplayComponent:\n 'displays come from plugins (`displays`); `@panneau/lists` exports the built-in ones',\n ResourceProvider: 'Panneau 5 has no resource context: pass the resource id as a prop',\n },\n '@panneau/data': {\n useResourceItems:\n '`useResourceList(resource, query)` of `@panneau/data/query`: its `data.data` are the items, and the query is a list query of the protocol (`page`, `perPage`, `filter`)',\n useResourceItem:\n '`useResourceItem(resource, id)` of `@panneau/data/query`: its `data` is the item',\n useItems: '`useResourceList(resource, query)` of `@panneau/data/query`',\n useItem: '`useResourceItem(resource, id)` of `@panneau/data/query`',\n },\n '@panneau/app': {\n MainLayout: 'pages of Panneau 5 render inside the shell of the app: drop the layout',\n PageHeader:\n 'pages of Panneau 5 render inside the shell of the app, which shows their title',\n ResourceItemsList:\n '`ListView` of `@panneau/lists`, with `useResourceList()` of `@panneau/data/query`',\n ResourceForm: '`FormView` of `@panneau/forms`',\n },\n '@panneau/medias': {\n MediasBrowserProvider:\n 'the media field and picker of `@panneau/media` (`mediaPlugin`) browse the media libraries through the adapter',\n },\n '@panneau/intl': {\n default: 'messages come with the packages and with plugins (`locales`)',\n useResourceValues: 'labels of resources come from the definition, already translated',\n },\n '@panneau/element-button': {\n default:\n '`Button` of `@panneau/ui` (`variant` and `tone` instead of `theme`, Lucide icons)',\n },\n '@panneau/element-buttons': { default: '`Inline` and `Button` of `@panneau/ui`' },\n '@panneau/element-modal': { default: '`Dialog` of `@panneau/ui`' },\n '@panneau/modal-dialog': { default: '`Dialog` of `@panneau/ui`' },\n '@panneau/element-card': { default: '`Card` of `@panneau/ui`' },\n '@panneau/element-alert': { default: '`Alert` of `@panneau/ui`' },\n '@panneau/element-loading': {\n default:\n '`Skeleton` of `@panneau/ui` while content loads, `Spinner` for an operation in progress',\n },\n '@panneau/element-icon': { default: '`Icon` of `@panneau/ui`, with Lucide icons' },\n '@panneau/element-label': { default: 'labels are given to fields and primitives as `label`' },\n '@panneau/element-select': {\n default: '`Select` of `@panneau/ui`, or `SelectField` of `@panneau/fields/select`',\n },\n '@panneau/element-radios': { default: '`RadioGroup` of `@panneau/ui`' },\n '@panneau/element-range': { default: '`Slider` of `@panneau/ui`' },\n '@panneau/element-table': { default: '`ListView` of `@panneau/lists`' },\n '@panneau/form': { default: '`Form` of `@panneau/forms`, with fields of the protocol' },\n};\n"],"mappings":";;;AAuBA,IAAa,cAAiC;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;;AAGA,IAAa,gBAAkD,EAAE,UAAU,cAAc;AAEzF,IAAM,aAAa;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AACA,IAAM,eAAe;CAAE,SAAS;CAAU,QAAQ;AAAS;AAC3D,IAAM,eAAe;CAAC;CAAW;CAAe;CAAY;CAAU;AAAkB;AACxF,IAAM,cAAc;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AACA,IAAM,aAAa;AAEnB,IAAM,OAAoB;CACtB,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW;AACf;AACA,IAAM,MAAmB;CACrB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;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;CACA,iBAAiB;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;CACA,mBAAmB,CAAC,SAAS;CAC7B,kBAAkB,CAAC,SAAS;CAC5B,iBAAiB;EACb;EACA;EACA;EACA;EACA;CACJ;CACA,kBAAkB,CAAC,SAAS;AAChC;;AAGA,SAAgB,YAAY,MAAuB;CAC/C,OACI,oEAAoE,KAAK,IAAI,KAC7E;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC,CAAC,SAAS,IAAI;AAEvB;;AAGA,IAAa,eAA2E;CACpF,0BAA0B;EACtB,oBACI;EACJ,qBACI;EACJ,aACI;EACJ,iBACI;EACJ,YACI;EACJ,iBACI;EACJ,SACI;EACJ,YAAY;EACZ,kBACI;EACJ,mBAAmB;EACnB,qBACI;EACJ,kBAAkB;CACtB;CACA,iBAAiB;EACb,kBACI;EACJ,iBACI;EACJ,UAAU;EACV,SAAS;CACb;CACA,gBAAgB;EACZ,YAAY;EACZ,YACI;EACJ,mBACI;EACJ,cAAc;CAClB;CACA,mBAAmB,EACf,uBACI,gHACR;CACA,iBAAiB;EACb,SAAS;EACT,mBAAmB;CACvB;CACA,2BAA2B,EACvB,SACI,oFACR;CACA,4BAA4B,EAAE,SAAS,yCAAyC;CAChF,0BAA0B,EAAE,SAAS,4BAA4B;CACjE,yBAAyB,EAAE,SAAS,4BAA4B;CAChE,yBAAyB,EAAE,SAAS,0BAA0B;CAC9D,0BAA0B,EAAE,SAAS,2BAA2B;CAChE,4BAA4B,EACxB,SACI,0FACR;CACA,yBAAyB,EAAE,SAAS,6CAA6C;CACjF,0BAA0B,EAAE,SAAS,uDAAuD;CAC5F,2BAA2B,EACvB,SAAS,0EACb;CACA,2BAA2B,EAAE,SAAS,gCAAgC;CACtE,0BAA0B,EAAE,SAAS,4BAA4B;CACjE,0BAA0B,EAAE,SAAS,iCAAiC;CACtE,iBAAiB,EAAE,SAAS,0DAA0D;AAC1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/codemods",
3
- "version": "5.0.0-alpha.12",
3
+ "version": "5.0.0-alpha.14",
4
4
  "description": "Codemods that move Panneau 4 projects to Panneau 5: the app entry, imports and custom field components, with a report of what they can't rewrite.",
5
5
  "type": "module",
6
6
  "license": "MIT",