@visns-studio/visns-components 6.6.3 → 6.15.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.
Files changed (100) hide show
  1. package/README.md +1658 -18
  2. package/package.json +10 -4
  3. package/src/components/DataGrid.jsx +619 -158
  4. package/src/components/Fetch.jsx +80 -3
  5. package/src/components/Form.jsx +9 -0
  6. package/src/components/Navigation.jsx +109 -50
  7. package/src/components/Notification.jsx +279 -9
  8. package/src/components/TableFilter.jsx +14 -1
  9. package/src/components/auth/AuthBrandPanel.jsx +43 -0
  10. package/src/components/auth/AuthLoading.jsx +78 -0
  11. package/src/components/auth/AuthShell.jsx +59 -0
  12. package/src/components/auth/ClientAuth.jsx +161 -0
  13. package/src/components/auth/ClientAuthFrame.jsx +59 -0
  14. package/src/components/auth/ClientLogin.jsx +266 -55
  15. package/src/components/auth/ClientOTPVerify.jsx +587 -115
  16. package/src/components/auth/ImpersonateGate.jsx +254 -0
  17. package/src/components/auth/Login.jsx +134 -41
  18. package/src/components/auth/LogoutScreen.jsx +112 -0
  19. package/src/components/auth/Reset.jsx +134 -77
  20. package/src/components/auth/TwoFactorAuth.jsx +475 -297
  21. package/src/components/auth/Verify.jsx +237 -126
  22. package/src/components/auth/authEndpoints.js +105 -0
  23. package/src/components/auth/authFont.js +23 -0
  24. package/src/components/auth/authHelpers.js +465 -0
  25. package/src/components/auth/clientAuthProtocols.js +240 -0
  26. package/src/components/auth/useOptionalRouter.js +49 -0
  27. package/src/components/callQueue/CallQueuePop.jsx +1502 -0
  28. package/src/components/callQueue/CallQueueSettings.jsx +508 -0
  29. package/src/components/callQueue/callQueueHelpers.js +280 -0
  30. package/src/components/callQueue/callQueueSettingsHelpers.js +75 -0
  31. package/src/components/columns/AutoGrowCell.jsx +141 -0
  32. package/src/components/columns/ColumnRenderers.jsx +53 -7
  33. package/src/components/generic/GenericAuth.jsx +163 -96
  34. package/src/components/generic/GenericDetail.jsx +215 -90
  35. package/src/components/generic/GenericIndex.jsx +20 -47
  36. package/src/components/generic/GenericMain.jsx +5 -0
  37. package/src/components/generic/GroupedReportRenderer.jsx +1 -5
  38. package/src/components/generic/StandardModal.jsx +17 -5
  39. package/src/components/generic/reportSemanticSteps/SemanticEntityStep.jsx +1 -6
  40. package/src/components/generic/reportSemanticSteps/SemanticFieldsStep.jsx +4 -11
  41. package/src/components/generic/reportSemanticSteps/SemanticFiltersStep.jsx +9 -27
  42. package/src/components/generic/reportSemanticSteps/SemanticGroupingStep.jsx +5 -13
  43. package/src/components/generic/reportSemanticSteps/SemanticParameterPrompt.jsx +5 -13
  44. package/src/components/generic/reportSemanticSteps/SemanticPreviewStep.jsx +14 -31
  45. package/src/components/generic/reportSemanticSteps/SemanticRelationsStep.jsx +3 -9
  46. package/src/components/generic/reportSemanticSteps/SemanticValueInput.jsx +2 -15
  47. package/src/components/navActive.js +60 -0
  48. package/src/components/notify/desktopNotifications.js +256 -0
  49. package/src/components/sketch/SketchField.jsx +12 -2
  50. package/src/components/sms/SmsComposeModal.jsx +495 -0
  51. package/src/components/sms/SmsInbox.jsx +596 -0
  52. package/src/components/sms/SmsInboxBadge.jsx +468 -0
  53. package/src/components/sms/SmsLineSettings.jsx +854 -0
  54. package/src/components/sms/SmsThreadPanel.jsx +1184 -0
  55. package/src/components/sms/smsEndpoints.js +56 -0
  56. package/src/components/sms/smsHelpers.js +1075 -0
  57. package/src/components/sms/smsLiveState.js +132 -0
  58. package/src/components/sms/useSmsLive.js +307 -0
  59. package/src/components/styles/CallQueuePop.module.scss +646 -0
  60. package/src/components/styles/CallQueueSettings.module.scss +460 -0
  61. package/src/components/styles/ClientAuth.module.scss +229 -0
  62. package/src/components/styles/DataGrid.module.scss +10 -0
  63. package/src/components/styles/GenericDetail.module.scss +153 -26
  64. package/src/components/styles/GenericIndex.module.scss +13 -0
  65. package/src/components/styles/GenericMain.module.scss +19 -2
  66. package/src/components/styles/ImpersonateGate.module.scss +85 -0
  67. package/src/components/styles/Login.module.scss +13 -122
  68. package/src/components/styles/LogoutScreen.module.scss +89 -0
  69. package/src/components/styles/Navigation.module.scss +509 -223
  70. package/src/components/styles/Notification.module.scss +103 -0
  71. package/src/components/styles/Reset.module.scss +52 -186
  72. package/src/components/styles/Sms.module.scss +2382 -0
  73. package/src/components/styles/TableFilter.module.scss +118 -98
  74. package/src/components/styles/TwoFactorAuth.module.scss +115 -176
  75. package/src/components/styles/Vault.module.scss +1983 -0
  76. package/src/components/styles/Verify.module.scss +57 -180
  77. package/src/components/styles/_authBrandPanel.scss +163 -0
  78. package/src/components/styles/_authShell.scss +369 -0
  79. package/src/components/styles/global-datagrid.css +29 -0
  80. package/src/components/utils/buildEnv.js +67 -0
  81. package/src/components/utils/displayValue.js +94 -0
  82. package/src/components/utils/useDensity.js +345 -9
  83. package/src/components/vault/OtpChip.jsx +208 -0
  84. package/src/components/vault/PasswordGenerator.jsx +145 -0
  85. package/src/components/vault/QrScanner.jsx +326 -0
  86. package/src/components/vault/VaultAccessLog.jsx +225 -0
  87. package/src/components/vault/VaultConfirmPanel.jsx +113 -0
  88. package/src/components/vault/VaultEntryForm.jsx +740 -0
  89. package/src/components/vault/VaultManager.jsx +1000 -0
  90. package/src/components/vault/VaultQuickSearch.jsx +681 -0
  91. package/src/components/vault/qrDecode.js +257 -0
  92. package/src/components/vault/useDebouncedValue.js +22 -0
  93. package/src/components/vault/useVaultReveal.js +160 -0
  94. package/src/components/vault/vaultClipboard.js +33 -0
  95. package/src/components/vault/vaultEndpoints.js +40 -0
  96. package/src/components/vault/vaultFit.js +116 -0
  97. package/src/components/vault/vaultHelpers.js +547 -0
  98. package/src/components/vault/vaultNavigation.jsx +58 -0
  99. package/src/components/vault/vaultOtp.js +105 -0
  100. package/src/index.js +233 -1
@@ -1,109 +1,166 @@
1
1
  import '../styles/global.css';
2
+ import './authFont';
2
3
 
3
4
  import React, { useState } from 'react';
4
- import Reveal from '../utils/Reveal';
5
+ import { Link } from 'react-router-dom';
5
6
  import { toast } from 'react-toastify';
6
- import parse from 'html-react-parser';
7
- import { User } from 'lucide-react';
7
+ import { ArrowLeft, MailCheck } from 'lucide-react';
8
8
 
9
9
  import CustomFetch from '../Fetch';
10
+ import AuthShell from './AuthShell';
11
+ import { resolveAuthEndpoints } from './authEndpoints';
12
+ import { normaliseAuthError } from './authHelpers';
10
13
 
11
14
  import styles from '../styles/Reset.module.scss';
12
15
 
13
- const Reset = ({ logo }) => {
16
+ /**
17
+ * Forgot password — the first half of the reset journey.
18
+ *
19
+ * Redesigned in 6.7.0 onto the same two-pane frame as the login screen it is
20
+ * reached from; the pre-6.1 centred card it used to render had its own greys,
21
+ * its own button and its own idea of what a form field looks like.
22
+ *
23
+ * The request itself is unchanged: POST {passwordForgot} with `{email}`, and a
24
+ * `{error: ''}` body means the mail is on its way.
25
+ */
26
+
27
+ const DEFAULT_COPY = {
28
+ title: 'Forgot your password?',
29
+ subtitle:
30
+ 'Enter the email address on your account and we will send you a link to set a new password.',
31
+ fieldLabel: 'Email',
32
+ submit: 'Send Reset Link',
33
+ submitting: 'Sending…',
34
+ /** Replaces the form once the request is in. */
35
+ sent: 'If that address is on an account, a reset link is on its way. Follow the instructions in the email to set a new password.',
36
+ back: 'Back to Login',
37
+ /** Client-side validation. */
38
+ required: 'Please type in your email address.',
39
+ failed: 'Could not request a password reset, please try again.',
40
+ };
41
+
42
+ const Reset = ({
43
+ logo,
44
+ loginBg,
45
+ config = {},
46
+ /** Merged over the 6.6.3 literals — see authEndpoints.js. */
47
+ endpoints,
48
+ /** Merged over DEFAULT_COPY above. */
49
+ copy: copyOverrides,
50
+ loginPath = '/login',
51
+ }) => {
52
+ const urls = resolveAuthEndpoints(endpoints);
53
+ const copy = { ...DEFAULT_COPY, ...(copyOverrides || {}) };
54
+ const branding = config.branding || {};
55
+
14
56
  const [email, setEmail] = useState('');
15
57
  const [emailClass, setEmailClass] = useState('');
58
+ const [isLoading, setIsLoading] = useState(false);
59
+ const [isSent, setIsSent] = useState(false);
16
60
 
17
61
  const handleSubmit = (e) => {
18
62
  e.preventDefault();
19
63
 
20
- if (email === '') {
21
- const error = 'Please type in your email address.';
64
+ // The button is disabled too; this also covers Enter in the field.
65
+ if (isLoading) {
66
+ return;
67
+ }
68
+
69
+ if (email.trim() === '') {
22
70
  setEmailClass('inputError');
23
- toast.error(<div>{parse(error)}</div>);
71
+ toast.error(copy.required);
72
+
24
73
  return;
25
74
  }
26
75
 
76
+ setIsLoading(true);
77
+
27
78
  CustomFetch(
28
- '/password/forgot',
79
+ urls.passwordForgot,
29
80
  'POST',
30
81
  { email: email },
31
- function (result) {
32
- if (result.error === '') {
33
- setEmail('');
34
- toast.success(
35
- 'You have successfully requested to reset your password, an email will be sent shortly. Please follow the instruction on the email.'
36
- );
37
- } else {
38
- toast.error(result.error);
82
+ (result) => {
83
+ setIsLoading(false);
84
+
85
+ const failure =
86
+ (result && typeof result === 'object' && result.error) ||
87
+ '';
88
+
89
+ if (failure) {
90
+ setEmailClass('inputError');
91
+ toast.error(normaliseAuthError(failure, copy.failed));
92
+
93
+ return;
39
94
  }
95
+
96
+ setEmail('');
97
+ // The form is replaced rather than re-offered: a second submit
98
+ // while the first mail is still in flight only produces a
99
+ // second link, and invalidates the first.
100
+ setIsSent(true);
101
+ toast.success(copy.sent);
102
+ },
103
+ (error) => {
104
+ setIsLoading(false);
105
+ setEmailClass('inputError');
106
+ toast.error(normaliseAuthError(error, copy.failed));
40
107
  }
41
108
  );
42
109
  };
43
110
 
44
111
  return (
45
- <div className={styles.lcontainer}>
46
- <div className={styles.lwrap}>
47
- <div className={styles.logincontainer}>
48
- <form onSubmit={handleSubmit}>
49
- <Reveal effect="fadeInUp">
50
- <div className={styles.login}>
51
- <img
52
- src={logo}
53
- alt="CRM"
54
- className={styles.loginlogo}
55
- />
56
- <h2
57
- style={{
58
- textAlign: 'center',
59
- marginBottom: '1.5rem',
60
- color: '#111827',
61
- fontWeight: '600',
62
- fontSize: '1.5rem',
63
- }}
64
- >
65
- Forgot your password?
66
- </h2>
67
- <div
68
- className={`${styles.formItem} ${styles.fwItem}`}
69
- >
70
- <label className={styles.fi__label}>
71
- <input
72
- type="email"
73
- name="email"
74
- value={email}
75
- onChange={(e) => {
76
- setEmail(e.target.value);
77
- setEmailClass('');
78
- }}
79
- tabIndex="1"
80
- className={emailClass}
81
- />
82
- <span className={styles.fi__span}>
83
- Email
84
- </span>
85
- <small>
86
- <User strokeWidth={2} size={18} />
87
- </small>
88
- </label>
89
- </div>
90
- <div
91
- className={`${styles.formItem} ${styles.fwItem} ${styles.lastItem}`}
92
- >
93
- <button
94
- className={styles.btn}
95
- type="submit"
96
- tabIndex="2"
97
- >
98
- Send Reset Link
99
- </button>
100
- </div>
101
- </div>
102
- </Reveal>
103
- </form>
112
+ <AuthShell
113
+ styles={styles}
114
+ logo={logo}
115
+ loginBg={loginBg}
116
+ branding={branding}
117
+ title={copy.title}
118
+ subtitle={isSent ? null : copy.subtitle}
119
+ footer={branding.footer}
120
+ >
121
+ {isSent ? (
122
+ <div className={styles.sent}>
123
+ <MailCheck size={18} strokeWidth={2} />
124
+ <p>{copy.sent}</p>
104
125
  </div>
105
- </div>
106
- </div>
126
+ ) : (
127
+ <form onSubmit={handleSubmit} className={styles.form}>
128
+ <div className={styles.field}>
129
+ <input
130
+ id="reset-email"
131
+ type="email"
132
+ name="email"
133
+ value={email}
134
+ onChange={(e) => {
135
+ setEmail(e.target.value);
136
+ setEmailClass('');
137
+ }}
138
+ tabIndex="1"
139
+ className={emailClass}
140
+ autoComplete="username"
141
+ placeholder=" "
142
+ autoFocus
143
+ disabled={isLoading}
144
+ />
145
+ <label htmlFor="reset-email">{copy.fieldLabel}</label>
146
+ </div>
147
+
148
+ <button
149
+ className={styles.submit}
150
+ type="submit"
151
+ disabled={isLoading}
152
+ tabIndex="2"
153
+ >
154
+ {isLoading ? copy.submitting : copy.submit}
155
+ </button>
156
+ </form>
157
+ )}
158
+
159
+ <Link to={loginPath} className={styles.back}>
160
+ <ArrowLeft size={15} strokeWidth={2} />
161
+ {copy.back}
162
+ </Link>
163
+ </AuthShell>
107
164
  );
108
165
  };
109
166