@panneau/form-auth 4.0.74 → 4.0.78

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { Field, Label } from '@panneau/core';
2
+ import { Field, Label, ControlSize, FormDefinition } from '@panneau/core';
3
3
 
4
4
  interface ChangePasswordProps {
5
5
  action?: string;
@@ -36,8 +36,8 @@ declare function ForgotPassword({ action, fields, emailLabel, submitButtonLabel,
36
36
  interface LoginProps {
37
37
  action?: string;
38
38
  postForm?: ((action: string, data: unknown) => Promise<unknown>) | null;
39
- fields?: Field[] | null;
40
- size?: string;
39
+ fields: Field[] | null;
40
+ size?: ControlSize;
41
41
  emailLabel?: Label | null;
42
42
  passwordLabel?: Label | null;
43
43
  submitButtonLabel?: Label | null;
@@ -45,7 +45,7 @@ interface LoginProps {
45
45
  forgotPasswordLink?: string;
46
46
  forgotPasswordLabel?: Label | null;
47
47
  }
48
- declare function Login({ action, postForm, fields, size, emailLabel, passwordLabel, submitButtonLabel, withForgotPassword, forgotPasswordLink, forgotPasswordLabel, ...props }: LoginProps): react.JSX.Element;
48
+ declare function Login({ action, postForm, size, submitButtonLabel, withForgotPassword, forgotPasswordLink, forgotPasswordLabel, ...props }: LoginProps): react.JSX.Element;
49
49
 
50
50
  interface RegisterProps {
51
51
  action?: string;
@@ -106,4 +106,6 @@ interface TwoFactorEnableProps {
106
106
  }
107
107
  declare function TwoFactorEnable({ action, fields, explainationLabel, submitButtonLabel, size, withSkipLink, skipLink, skipLabel, ...props }: TwoFactorEnableProps): react.JSX.Element;
108
108
 
109
- export { ChangePassword, ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactorChallenge, TwoFactorDisable, TwoFactorEnable };
109
+ declare const definitions: FormDefinition[];
110
+
111
+ export { ChangePassword, ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactorChallenge, TwoFactorDisable, TwoFactorEnable, definitions as definition };
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { FormattedMessage } from 'react-intl';
3
3
  import Form from '@panneau/form';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import Link from '@panneau/element-link';
6
+ import { useFormDefinition } from '@panneau/core/contexts';
6
7
  import { postJSON, getCSRFHeaders } from '@folklore/fetch';
7
8
 
8
9
  function ChangePassword(t0) {
@@ -315,139 +316,112 @@ function ForgotPassword(t0) {
315
316
  }
316
317
 
317
318
  function Login(t0) {
318
- const $ = c(30);
319
+ const $ = c(25);
319
320
  let props;
320
321
  let t1;
321
- let t10;
322
322
  let t2;
323
323
  let t3;
324
324
  let t4;
325
325
  let t5;
326
326
  let t6;
327
327
  let t7;
328
- let t8;
329
- let t9;
330
328
  if ($[0] !== t0) {
331
329
  ({
332
330
  action: t1,
333
331
  postForm: t2,
334
- fields: t3,
335
- size: t4,
336
- emailLabel: t5,
337
- passwordLabel: t6,
338
- submitButtonLabel: t7,
339
- withForgotPassword: t8,
340
- forgotPasswordLink: t9,
341
- forgotPasswordLabel: t10,
332
+ size: t3,
333
+ submitButtonLabel: t4,
334
+ withForgotPassword: t5,
335
+ forgotPasswordLink: t6,
336
+ forgotPasswordLabel: t7,
342
337
  ...props
343
338
  } = t0);
344
339
  $[0] = t0;
345
340
  $[1] = props;
346
341
  $[2] = t1;
347
- $[3] = t10;
348
- $[4] = t2;
349
- $[5] = t3;
350
- $[6] = t4;
351
- $[7] = t5;
352
- $[8] = t6;
353
- $[9] = t7;
354
- $[10] = t8;
355
- $[11] = t9;
342
+ $[3] = t2;
343
+ $[4] = t3;
344
+ $[5] = t4;
345
+ $[6] = t5;
346
+ $[7] = t6;
347
+ $[8] = t7;
356
348
  } else {
357
349
  props = $[1];
358
350
  t1 = $[2];
359
- t10 = $[3];
360
- t2 = $[4];
361
- t3 = $[5];
362
- t4 = $[6];
363
- t5 = $[7];
364
- t6 = $[8];
365
- t7 = $[9];
366
- t8 = $[10];
367
- t9 = $[11];
351
+ t2 = $[3];
352
+ t3 = $[4];
353
+ t4 = $[5];
354
+ t5 = $[6];
355
+ t6 = $[7];
356
+ t7 = $[8];
368
357
  }
369
358
  const action = t1 === undefined ? "/login" : t1;
370
359
  const postForm = t2 === undefined ? null : t2;
371
- const fields = t3 === undefined ? null : t3;
372
- const size = t4 === undefined ? "lg" : t4;
373
- const emailLabel = t5 === undefined ? null : t5;
374
- const passwordLabel = t6 === undefined ? null : t6;
375
- const submitButtonLabel = t7 === undefined ? null : t7;
376
- const withForgotPassword = t8 === undefined ? false : t8;
377
- const forgotPasswordLink = t9 === undefined ? "/forgot-password" : t9;
378
- const forgotPasswordLabel = t10 === undefined ? null : t10;
379
- let t11;
380
- if ($[12] !== emailLabel || $[13] !== fields || $[14] !== passwordLabel || $[15] !== size) {
381
- t11 = fields || [{
382
- name: "email",
383
- type: "email",
384
- size,
385
- label: emailLabel || /*#__PURE__*/jsx(FormattedMessage, {
386
- id: "LI0Gz4"
387
- })
388
- }, {
389
- name: "password",
390
- type: "password",
391
- size,
392
- label: passwordLabel || /*#__PURE__*/jsx(FormattedMessage, {
393
- id: "4yfet+"
394
- })
395
- }];
396
- $[12] = emailLabel;
397
- $[13] = fields;
398
- $[14] = passwordLabel;
399
- $[15] = size;
400
- $[16] = t11;
401
- } else {
402
- t11 = $[16];
403
- }
404
- let t12;
405
- if ($[17] !== submitButtonLabel) {
406
- t12 = submitButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
360
+ const size = t3 === undefined ? "lg" : t3;
361
+ const submitButtonLabel = t4 === undefined ? null : t4;
362
+ const withForgotPassword = t5 === undefined ? false : t5;
363
+ const forgotPasswordLink = t6 === undefined ? "/forgot-password" : t6;
364
+ const forgotPasswordLabel = t7 === undefined ? null : t7;
365
+ const {
366
+ fields
367
+ } = useFormDefinition("login") || {};
368
+ let t8;
369
+ if ($[9] !== submitButtonLabel) {
370
+ t8 = submitButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
407
371
  id: "g6qbbX"
408
372
  });
409
- $[17] = submitButtonLabel;
410
- $[18] = t12;
373
+ $[9] = submitButtonLabel;
374
+ $[10] = t8;
411
375
  } else {
412
- t12 = $[18];
376
+ t8 = $[10];
413
377
  }
414
- let t13;
415
- if ($[19] !== forgotPasswordLabel || $[20] !== forgotPasswordLink || $[21] !== withForgotPassword) {
416
- t13 = withForgotPassword ? /*#__PURE__*/jsx(Link, {
378
+ let t9;
379
+ if ($[11] !== forgotPasswordLabel || $[12] !== forgotPasswordLink || $[13] !== withForgotPassword) {
380
+ t9 = withForgotPassword ? /*#__PURE__*/jsx(Link, {
417
381
  href: forgotPasswordLink,
418
382
  className: "py-2 px-4",
419
383
  children: forgotPasswordLabel || /*#__PURE__*/jsx(FormattedMessage, {
420
384
  id: "ZBNqY2"
421
385
  })
422
386
  }) : null;
423
- $[19] = forgotPasswordLabel;
424
- $[20] = forgotPasswordLink;
425
- $[21] = withForgotPassword;
426
- $[22] = t13;
387
+ $[11] = forgotPasswordLabel;
388
+ $[12] = forgotPasswordLink;
389
+ $[13] = withForgotPassword;
390
+ $[14] = t9;
427
391
  } else {
428
- t13 = $[22];
392
+ t9 = $[14];
429
393
  }
430
- let t14;
431
- if ($[23] !== action || $[24] !== postForm || $[25] !== props || $[26] !== t11 || $[27] !== t12 || $[28] !== t13) {
432
- t14 = /*#__PURE__*/jsx(Form, {
394
+ let t10;
395
+ if ($[15] !== fields) {
396
+ t10 = fields || [];
397
+ $[15] = fields;
398
+ $[16] = t10;
399
+ } else {
400
+ t10 = $[16];
401
+ }
402
+ let t11;
403
+ if ($[17] !== action || $[18] !== postForm || $[19] !== props || $[20] !== size || $[21] !== t10 || $[22] !== t8 || $[23] !== t9) {
404
+ t11 = /*#__PURE__*/jsx(Form, {
433
405
  action: action,
434
406
  postForm: postForm,
435
- fields: t11,
436
- submitButtonLabel: t12,
437
- actions: t13,
407
+ submitButtonLabel: t8,
408
+ actions: t9,
409
+ size: size,
410
+ fields: t10,
438
411
  ...props
439
412
  });
440
- $[23] = action;
441
- $[24] = postForm;
442
- $[25] = props;
443
- $[26] = t11;
444
- $[27] = t12;
445
- $[28] = t13;
446
- $[29] = t14;
413
+ $[17] = action;
414
+ $[18] = postForm;
415
+ $[19] = props;
416
+ $[20] = size;
417
+ $[21] = t10;
418
+ $[22] = t8;
419
+ $[23] = t9;
420
+ $[24] = t11;
447
421
  } else {
448
- t14 = $[29];
422
+ t11 = $[24];
449
423
  }
450
- return t14;
424
+ return t11;
451
425
  }
452
426
 
453
427
  function Register(t0) {
@@ -1041,4 +1015,25 @@ function TwoFactorEnable(t0) {
1041
1015
  return t13;
1042
1016
  }
1043
1017
 
1044
- export { ChangePassword, ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactorChallenge, TwoFactorDisable, TwoFactorEnable };
1018
+ const definitions = [{
1019
+ id: 'login',
1020
+ component: 'login',
1021
+ fields: [{
1022
+ name: 'email',
1023
+ type: 'email',
1024
+ label: /*#__PURE__*/jsx(FormattedMessage, {
1025
+ id: "LI0Gz4"
1026
+ })
1027
+ }, {
1028
+ name: 'password',
1029
+ type: 'password',
1030
+ label: /*#__PURE__*/jsx(FormattedMessage, {
1031
+ id: "4yfet+"
1032
+ })
1033
+ }],
1034
+ submitButtonLabel: /*#__PURE__*/jsx(FormattedMessage, {
1035
+ id: "g6qbbX"
1036
+ })
1037
+ }];
1038
+
1039
+ export { ChangePassword, ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactorChallenge, TwoFactorDisable, TwoFactorEnable, definitions as definition };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/form-auth",
3
- "version": "4.0.74",
3
+ "version": "4.0.78",
4
4
  "description": "Basic forgot password form",
5
5
  "keywords": [
6
6
  "javascript"
@@ -48,9 +48,9 @@
48
48
  "dependencies": {
49
49
  "@babel/runtime": "^7.28.6",
50
50
  "@folklore/fetch": "^0.1.21",
51
- "@panneau/core": "^4.0.74",
52
- "@panneau/element-link": "^4.0.74",
53
- "@panneau/form": "^4.0.74",
51
+ "@panneau/core": "^4.0.78",
52
+ "@panneau/element-link": "^4.0.78",
53
+ "@panneau/form": "^4.0.78",
54
54
  "classnames": "^2.5.1",
55
55
  "lodash": "^4.17.21",
56
56
  "react-intl": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^10.0.0"
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "122cadcf8ea5faacc035e7fe911fbdfb9fb87d26"
69
+ "gitHead": "669f20a39ca9545acbe0f2279c6d1af23e43ae6e"
70
70
  }