@opexa/portal-components 0.0.1029 → 0.0.1031

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.
@@ -23,5 +23,6 @@ export interface SignUpDefaultProps {
23
23
  isRegulated?: boolean;
24
24
  variant?: string;
25
25
  showEmailAddressField?: boolean;
26
+ branchItemToValue?: 'code' | 'name';
26
27
  }
27
28
  export declare function SignUpDefault(props: SignUpDefaultProps): import("react/jsx-runtime").JSX.Element;
@@ -38,9 +38,14 @@ import DateOfBirthField from '../../DateOfBirthField.js';
38
38
  import { useSignUpDefaultPropsContext } from './SignUpDefaultContext.js';
39
39
  export function SignUpDefaultForm() {
40
40
  const signUpProps = useSignUpDefaultPropsContext();
41
+ const itemToValue = (item) => {
42
+ if (signUpProps.branchItemToValue === 'name')
43
+ return item.name;
44
+ return item.code;
45
+ };
41
46
  const branchCollection = createListCollection({
42
47
  items: signUpProps.branches ?? [],
43
- itemToValue: (item) => item.code,
48
+ itemToValue,
44
49
  itemToString: (item) => {
45
50
  const name = (item.name ?? '').trim();
46
51
  return name ? `${item.code} - ${name}` : item.code;
@@ -65,6 +70,7 @@ export function SignUpDefaultForm() {
65
70
  const [branchTipOpen, setBranchTipOpen] = useState(false);
66
71
  const firstNameBaseSchema = z
67
72
  .string()
73
+ .min(1, 'First name is required')
68
74
  .regex(/^[a-z ]+$/gi, 'First name must contain only letters')
69
75
  .transform((val) => val.trim())
70
76
  .refine((val) => val.length >= 2, {
@@ -75,6 +81,7 @@ export function SignUpDefaultForm() {
75
81
  });
76
82
  const lastNameBaseSchema = z
77
83
  .string()
84
+ .min(1, 'Last name is required')
78
85
  .regex(/^[a-z ]+$/gi, 'Last name must contain only letters')
79
86
  .transform((val) => val.trim())
80
87
  .refine((val) => val.length >= 2, {
@@ -84,15 +91,19 @@ export function SignUpDefaultForm() {
84
91
  message: 'Last name must not be more than 50 characters',
85
92
  });
86
93
  const birthdateBaseSchema = z
87
- .date({
88
- invalid_type_error: 'Date of birth is required',
89
- required_error: 'Date of birth is required',
90
- })
94
+ .custom()
91
95
  .superRefine((val, ctx) => {
96
+ if (!(val instanceof Date)) {
97
+ ctx.addIssue({
98
+ code: z.ZodIssueCode.custom,
99
+ message: 'Date of birth is required',
100
+ });
101
+ return;
102
+ }
92
103
  const now = new Date();
93
104
  const age = differenceInYears(now, val);
94
105
  if (age < 21) {
95
- return ctx.addIssue({
106
+ ctx.addIssue({
96
107
  code: z.ZodIssueCode.custom,
97
108
  message: 'You must be at least 21 years old',
98
109
  });
@@ -161,7 +172,7 @@ export function SignUpDefaultForm() {
161
172
  lastName: '',
162
173
  mobileNumber: '',
163
174
  branchCode: signUpProps?.branches?.length
164
- ? signUpProps.branches[0]?.code
175
+ ? itemToValue(signUpProps.branches[0])
165
176
  : '',
166
177
  termsAccepted: globalStore.responsibleGaming.accepted &&
167
178
  globalStore.termsAndConditions.accepted
@@ -234,9 +245,9 @@ export function SignUpDefaultForm() {
234
245
  }, collection: branchCollection, positioning: {
235
246
  sameWidth: true,
236
247
  placement: 'bottom',
237
- }, lazyMount: true, unmountOnExit: true, children: [_jsxs(Select.Label, { className: "flex items-center gap-1", children: ["Branch", ToolTip] }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: branchCollection.items.map((item) => {
248
+ }, lazyMount: true, unmountOnExit: true, children: [_jsxs(Select.Label, { className: "flex items-center gap-1", children: ["Branch", ToolTip] }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: branchCollection.items.map((item, index) => {
238
249
  const label = branchCollection.stringifyItem(item) ?? '';
239
- return (_jsx(Select.Item, { item: item, "aria-disabled": item.disabled, className: twMerge(item.disabled && 'text-border-disabled'), children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
250
+ return (_jsx(Select.Item, { item: item, "aria-disabled": item.disabled, className: twMerge(item.disabled && 'text-border-disabled'), children: _jsx("div", { title: label, className: "grow", children: label }) }, index));
240
251
  }) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.branchCode?.message })] }))] })), _jsx(Controller, { control: step1Form.control, name: "termsAccepted", render: (o) => (_jsxs(Field.Root, { className: "mt-2xl", invalid: o.fieldState.invalid, children: [_jsxs(Checkbox.Root, { variant: "outline", colorScheme: "neutral", checked: o.field.value, onCheckedChange: (details) => {
241
252
  if (details.checked === 'indeterminate')
242
253
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.1029",
3
+ "version": "0.0.1031",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",