nucleus-core-ts 0.9.885 → 0.9.886

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/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.9.885
1
+ 0.9.886
@@ -1,3 +1,3 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { CaptchaProps } from '../types';
3
- export declare function Captcha({ generateAction, config, onChallengeLoad, onAnswerChange, disabled, autoGenerate, className, label, errorMessage, themeOverride, }: CaptchaProps): ReactElement;
3
+ export declare function Captcha({ generateAction, config, onChallengeLoad, onAnswerChange, disabled, autoGenerate, className, label, labels: labelOverrides, errorMessage, themeOverride, }: CaptchaProps): ReactElement;
@@ -4,6 +4,7 @@ import { useGSAP } from '@gsap/react';
4
4
  import gsap from 'gsap';
5
5
  import { useEffect, useEffectEvent, useRef, useState } from 'react';
6
6
  import { cn } from '../../../utils/cn';
7
+ import { DEFAULT_CAPTCHA_LABELS } from '../labels';
7
8
  import { captchaTheme } from '../theme';
8
9
  gsap.registerPlugin(useGSAP);
9
10
  function mergeTheme(base, override) {
@@ -62,7 +63,14 @@ const RefreshIcon = ({ className, iconRef })=>/*#__PURE__*/ _jsxs("svg", {
62
63
  })
63
64
  ]
64
65
  });
65
- export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChange, disabled = false, autoGenerate = true, className, label = 'Security Check', errorMessage, themeOverride }) {
66
+ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChange, disabled = false, autoGenerate = true, className, label, labels: labelOverrides, errorMessage, themeOverride }) {
67
+ // `label` came first and some installs pass it; it still wins for the
68
+ // heading so nothing that already works changes.
69
+ const labels = {
70
+ ...DEFAULT_CAPTCHA_LABELS,
71
+ ...labelOverrides
72
+ };
73
+ const heading = label ?? labels.heading;
66
74
  const theme = themeOverride ? mergeTheme(captchaTheme, themeOverride) : captchaTheme;
67
75
  const containerRef = useRef(null);
68
76
  const challengeRef = useRef(null);
@@ -89,9 +97,8 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
89
97
  },
90
98
  onAfterHandle: (response)=>{
91
99
  const { data } = response;
92
- console.log('[DEBUG]:', response);
93
100
  if (!data || data.rateLimited) {
94
- setRateLimitError(response.message ?? 'Too many requests. Please try again later.');
101
+ setRateLimitError(response.message ?? labels.tooManyRequests);
95
102
  setChallengeData(null);
96
103
  return;
97
104
  }
@@ -111,7 +118,7 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
111
118
  },
112
119
  onErrorHandle: (_error, code)=>{
113
120
  if (code === 429) {
114
- setRateLimitError('Too many requests. Please try again later.');
121
+ setRateLimitError(labels.tooManyRequests);
115
122
  }
116
123
  setChallengeData(null);
117
124
  }
@@ -186,17 +193,17 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
186
193
  return `${mins}:${secs.toString().padStart(2, '0')}`;
187
194
  };
188
195
  const getPlaceholder = ()=>{
189
- if (!challenge) return 'Enter answer';
196
+ if (!challenge) return labels.enterAnswer;
190
197
  switch(challenge.type){
191
198
  case 'math':
192
- return 'Enter the result';
199
+ return labels.enterResult;
193
200
  case 'image':
194
201
  case 'text':
195
- return 'Enter the text shown';
202
+ return labels.enterTextShown;
196
203
  case 'puzzle':
197
- return 'Enter piece order (e.g., 0,1,2,3)';
204
+ return labels.enterPieceOrder;
198
205
  default:
199
- return 'Enter answer';
206
+ return labels.enterAnswer;
200
207
  }
201
208
  };
202
209
  if (config?.enabled === false) {
@@ -210,7 +217,7 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
210
217
  children: [
211
218
  /*#__PURE__*/ _jsx("span", {
212
219
  className: theme.label.base,
213
- children: label
220
+ children: heading
214
221
  }),
215
222
  /*#__PURE__*/ _jsx("div", {
216
223
  ref: challengeRef,
@@ -234,7 +241,7 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
234
241
  className: theme.challenge.image.wrapper,
235
242
  children: /*#__PURE__*/ _jsx("img", {
236
243
  src: challenge.imageData,
237
- alt: "Captcha",
244
+ alt: labels.imageAlt,
238
245
  className: theme.challenge.image.img,
239
246
  draggable: false
240
247
  })
@@ -242,14 +249,9 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
242
249
  challenge.type === 'puzzle' && challenge.puzzleData && /*#__PURE__*/ _jsxs("div", {
243
250
  className: theme.challenge.puzzle.wrapper,
244
251
  children: [
245
- /*#__PURE__*/ _jsxs("p", {
252
+ /*#__PURE__*/ _jsx("p", {
246
253
  className: theme.challenge.puzzle.instruction,
247
- children: [
248
- "Click the pieces in the correct order (0 to",
249
- ' ',
250
- challenge.puzzleData.pieces.length - 1,
251
- ")"
252
- ]
254
+ children: labels.puzzleInstruction.replace('{last}', String(challenge.puzzleData.pieces.length - 1))
253
255
  }),
254
256
  /*#__PURE__*/ _jsx("div", {
255
257
  className: theme.challenge.puzzle.grid,
@@ -272,7 +274,7 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
272
274
  type: "button",
273
275
  onClick: handleClearPuzzleOrder,
274
276
  className: theme.challenge.puzzle.clearButton,
275
- children: "Clear"
277
+ children: labels.clearOrder
276
278
  })
277
279
  ]
278
280
  })
@@ -283,7 +285,7 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
283
285
  className: theme.loading.wrapper,
284
286
  children: /*#__PURE__*/ _jsx("p", {
285
287
  className: "text-sm text-zinc-500",
286
- children: "Click refresh to load captcha"
288
+ children: labels.clickRefresh
287
289
  })
288
290
  })
289
291
  }),
@@ -293,7 +295,7 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
293
295
  /*#__PURE__*/ _jsx("label", {
294
296
  htmlFor: "captcha-answer",
295
297
  className: "sr-only",
296
- children: label
298
+ children: heading
297
299
  }),
298
300
  /*#__PURE__*/ _jsx("input", {
299
301
  id: "captcha-answer",
@@ -320,13 +322,13 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
320
322
  iconRef: iconRef
321
323
  }),
322
324
  /*#__PURE__*/ _jsx("span", {
323
- children: "New challenge"
325
+ children: labels.newChallenge
324
326
  })
325
327
  ]
326
328
  }),
327
329
  timeRemaining !== null && /*#__PURE__*/ _jsx("span", {
328
330
  className: isExpired ? theme.actions.timerExpired : theme.actions.timer,
329
- children: isExpired ? 'Expired' : `Expires in ${formatTime(timeRemaining)}`
331
+ children: isExpired ? labels.expired : labels.expiresIn.replace('{time}', formatTime(timeRemaining))
330
332
  })
331
333
  ]
332
334
  }),
@@ -334,7 +336,7 @@ export function Captcha({ generateAction, config, onChallengeLoad, onAnswerChang
334
336
  className: theme.error.container,
335
337
  children: /*#__PURE__*/ _jsx("p", {
336
338
  className: theme.error.text,
337
- children: rateLimitError ? rateLimitError : isExpired ? 'Captcha expired. Please refresh.' : errorMessage
339
+ children: rateLimitError ? rateLimitError : isExpired ? labels.expiredMessage : errorMessage
338
340
  })
339
341
  })
340
342
  ]
@@ -1,3 +1,4 @@
1
1
  export { Captcha } from './components/Captcha';
2
+ export { type CaptchaLabels, DEFAULT_CAPTCHA_LABELS } from './labels';
2
3
  export { captchaTheme } from './theme';
3
4
  export type { CaptchaAction, CaptchaChallenge, CaptchaChallengeData, CaptchaConfig, CaptchaDifficulty, CaptchaProps, CaptchaState, CaptchaThemeOverride, CaptchaType, } from './types';
@@ -1,2 +1,3 @@
1
1
  export { Captcha } from './components/Captcha';
2
+ export { DEFAULT_CAPTCHA_LABELS } from './labels';
2
3
  export { captchaTheme } from './theme';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Every word the security check says.
3
+ *
4
+ * This is the most-read component in the kit and the one nobody thought to
5
+ * translate: it sits on the sign-in form, so on an installation of 879 people
6
+ * it is shown several hundred times a morning. A portal could pass `label` and
7
+ * change the heading — and the box under the heading still said "Enter the
8
+ * result", "New challenge", "Expires in 1:30" and, when somebody was slow,
9
+ * "Captcha expired. Please refresh." Four sentences of English on the first
10
+ * screen of a portal that is otherwise entirely in its own language.
11
+ *
12
+ * The placeholders are per challenge type because the instruction is different
13
+ * for each: a sum wants its result, an image wants the letters in it, and the
14
+ * puzzle wants an order. `expiresIn` takes the formatted clock as `{time}` so a
15
+ * translation can put it where its own grammar wants it.
16
+ *
17
+ * Defaults stay English, so an installation that passes nothing is unchanged.
18
+ */
19
+ export type CaptchaLabels = {
20
+ /** The heading over the box, and the input's screen-reader label. */
21
+ heading: string;
22
+ /** Before a challenge has been asked for. */
23
+ clickRefresh: string;
24
+ /** The answer box, by challenge type. */
25
+ enterAnswer: string;
26
+ enterResult: string;
27
+ enterTextShown: string;
28
+ enterPieceOrder: string;
29
+ /** The picture challenge's alternative text. */
30
+ imageAlt: string;
31
+ /** The puzzle: its instruction takes the highest piece number as `{last}`. */
32
+ puzzleInstruction: string;
33
+ clearOrder: string;
34
+ /** Asking for a different challenge. */
35
+ newChallenge: string;
36
+ /** The countdown. `expiresIn` takes the clock as `{time}`. */
37
+ expiresIn: string;
38
+ expired: string;
39
+ /** What the box says once the clock has run out. */
40
+ expiredMessage: string;
41
+ /** Asked for too many challenges too quickly. */
42
+ tooManyRequests: string;
43
+ };
44
+ export declare const DEFAULT_CAPTCHA_LABELS: CaptchaLabels;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Every word the security check says.
3
+ *
4
+ * This is the most-read component in the kit and the one nobody thought to
5
+ * translate: it sits on the sign-in form, so on an installation of 879 people
6
+ * it is shown several hundred times a morning. A portal could pass `label` and
7
+ * change the heading — and the box under the heading still said "Enter the
8
+ * result", "New challenge", "Expires in 1:30" and, when somebody was slow,
9
+ * "Captcha expired. Please refresh." Four sentences of English on the first
10
+ * screen of a portal that is otherwise entirely in its own language.
11
+ *
12
+ * The placeholders are per challenge type because the instruction is different
13
+ * for each: a sum wants its result, an image wants the letters in it, and the
14
+ * puzzle wants an order. `expiresIn` takes the formatted clock as `{time}` so a
15
+ * translation can put it where its own grammar wants it.
16
+ *
17
+ * Defaults stay English, so an installation that passes nothing is unchanged.
18
+ */ export const DEFAULT_CAPTCHA_LABELS = {
19
+ heading: 'Security Check',
20
+ clickRefresh: 'Click refresh to load captcha',
21
+ enterAnswer: 'Enter answer',
22
+ enterResult: 'Enter the result',
23
+ enterTextShown: 'Enter the text shown',
24
+ enterPieceOrder: 'Enter piece order (e.g., 0,1,2,3)',
25
+ imageAlt: 'Captcha',
26
+ puzzleInstruction: 'Click the pieces in the correct order (0 to {last})',
27
+ clearOrder: 'Clear',
28
+ newChallenge: 'New challenge',
29
+ expiresIn: 'Expires in {time}',
30
+ expired: 'Expired',
31
+ expiredMessage: 'Captcha expired. Please refresh.',
32
+ tooManyRequests: 'Too many requests. Please try again later.'
33
+ };
@@ -1,3 +1,4 @@
1
+ import type { CaptchaLabels } from './labels';
1
2
  export type CaptchaType = 'math' | 'image' | 'puzzle' | 'text';
2
3
  export type CaptchaDifficulty = 'easy' | 'medium' | 'hard';
3
4
  export interface CaptchaChallengeData {
@@ -110,7 +111,10 @@ export interface CaptchaProps {
110
111
  disabled?: boolean;
111
112
  autoGenerate?: boolean;
112
113
  className?: string;
114
+ /** The heading only. Kept because installs already pass it; `labels` covers the rest. */
113
115
  label?: string;
116
+ /** Every other word the box says — see `../labels`. */
117
+ labels?: Partial<CaptchaLabels>;
114
118
  errorMessage?: string;
115
119
  themeOverride?: CaptchaThemeOverride;
116
120
  }
@@ -4,8 +4,8 @@ export { LoginChecker, RoleChecker, useAuthGuardStore, usePermission } from './c
4
4
  export type { AuthorizationPageProps, AuthorizationPageTheme, ClaimListProps, RoleClaimEditorProps, RoleListProps, } from './components/AuthorizationPage';
5
5
  export { AuthorizationPage, authorizationPageTheme, ClaimList, extendAuthorizationPageTheme, RoleClaimEditor, RoleList, useAuthorizationStore, } from './components/AuthorizationPage';
6
6
  export { Button } from './components/Button';
7
- export type { CaptchaAction, CaptchaChallenge, CaptchaConfig, CaptchaDifficulty, CaptchaProps, CaptchaState, CaptchaThemeOverride, CaptchaType, } from './components/Captcha';
8
- export { Captcha, captchaTheme } from './components/Captcha';
7
+ export type { CaptchaAction, CaptchaChallenge, CaptchaConfig, CaptchaDifficulty, CaptchaLabels, CaptchaProps, CaptchaState, CaptchaThemeOverride, CaptchaType, } from './components/Captcha';
8
+ export { Captcha, captchaTheme, DEFAULT_CAPTCHA_LABELS } from './components/Captcha';
9
9
  export type { ChangePasswordAction, ChangePasswordFormProps, ChangePasswordHeaderProps, ChangePasswordPageConfig, ChangePasswordStep, } from './components/ChangePasswordPage';
10
10
  export { ChangePasswordPage, useChangePasswordStore, } from './components/ChangePasswordPage';
11
11
  export type { ChatDirectoryUser, ChatPanelActions, ChatPanelLabels, ChatPanelProps, ChatPanelState, ChatPanelTheme, TypingIndicator as ChatTypingIndicator, UseChatReturn, } from './components/ChatPanel';
package/dist/fe/index.js CHANGED
@@ -4,7 +4,7 @@ export { AbstractAnimatedBackground } from './components/AbstractAnimatedBackgro
4
4
  export { LoginChecker, RoleChecker, useAuthGuardStore, usePermission } from './components/AuthGuard';
5
5
  export { AuthorizationPage, authorizationPageTheme, ClaimList, extendAuthorizationPageTheme, RoleClaimEditor, RoleList, useAuthorizationStore } from './components/AuthorizationPage';
6
6
  export { Button } from './components/Button';
7
- export { Captcha, captchaTheme } from './components/Captcha';
7
+ export { Captcha, captchaTheme, DEFAULT_CAPTCHA_LABELS } from './components/Captcha';
8
8
  export { ChangePasswordPage, useChangePasswordStore } from './components/ChangePasswordPage';
9
9
  // Chat
10
10
  export { ChatPanel, chatPanelTheme, DEFAULT_CHAT_LABELS, extendChatPanelTheme, NewConversationModal, useChat, useChatStore } from './components/ChatPanel';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.9.885",
3
+ "version": "0.9.886",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",