@idds/react 1.3.5 → 1.4.3
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.cjs.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +210 -112
- package/dist/index.umd.js +2 -2
- package/dist/types/components/Accordion.d.ts.map +1 -1
- package/dist/types/components/DatePicker.d.ts.map +1 -1
- package/dist/types/components/Drawer.d.ts.map +1 -1
- package/dist/types/components/FieldInputTable.d.ts.map +1 -1
- package/dist/types/components/MonthPicker.d.ts.map +1 -1
- package/dist/types/components/MultipleChoiceGrid.d.ts.map +1 -1
- package/dist/types/components/SelectDropdown.d.ts +3 -1
- package/dist/types/components/SelectDropdown.d.ts.map +1 -1
- package/dist/types/components/TextArea.d.ts.map +1 -1
- package/dist/types/components/TextField.d.ts.map +1 -1
- package/dist/types/components/YearPicker.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { createContext, useRef, useState, useCallback, useMemo, useContext, useEffect, forwardRef, createElement, Fragment as Fragment$1,
|
|
2
|
+
import React, { createContext, useRef, useState, useCallback, useMemo, useContext, useId, useEffect, forwardRef, createElement, Fragment as Fragment$1, useImperativeHandle } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
const iddsColorTokens = {
|
|
5
5
|
// Neutral Colors
|
|
@@ -645,9 +645,8 @@ function Accordion(props) {
|
|
|
645
645
|
} = props;
|
|
646
646
|
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
647
647
|
const accordionGroup = useAccordionGroup();
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
);
|
|
648
|
+
const generatedId = useId().replace(/:/g, "-");
|
|
649
|
+
const itemIdRef = useRef(`accordion-${generatedId}`);
|
|
651
650
|
const [itemIndex, setItemIndex] = useState(-1);
|
|
652
651
|
const defaultOpenRef = useRef(defaultOpen);
|
|
653
652
|
defaultOpenRef.current = defaultOpen;
|
|
@@ -2096,6 +2095,7 @@ function TextField({
|
|
|
2096
2095
|
"input",
|
|
2097
2096
|
{
|
|
2098
2097
|
...rest,
|
|
2098
|
+
id: (rest == null ? void 0 : rest.id) || (rest == null ? void 0 : rest.name) ? String((rest == null ? void 0 : rest.id) || (rest == null ? void 0 : rest.name)) : String(label).toLowerCase(),
|
|
2099
2099
|
type: rest.type ?? "text",
|
|
2100
2100
|
className: clsx("ina-text-field__input", className),
|
|
2101
2101
|
value: inner,
|
|
@@ -2839,13 +2839,13 @@ function FileUpload({
|
|
|
2839
2839
|
uploadedFile.status === "uploading" && /* @__PURE__ */ jsx("div", { className: "ina-file-upload__file-icon-wrapper ina-file-upload__file-icon-wrapper--uploading", children: /* @__PURE__ */ jsx(
|
|
2840
2840
|
IconLoader2,
|
|
2841
2841
|
{
|
|
2842
|
-
size:
|
|
2842
|
+
size: 20,
|
|
2843
2843
|
className: "ina-file-upload__file-icon--spinning"
|
|
2844
2844
|
}
|
|
2845
2845
|
) }),
|
|
2846
|
-
uploadedFile.status === "success" && /* @__PURE__ */ jsx("div", { className: "ina-file-upload__file-icon-wrapper ina-file-upload__file-icon-wrapper--success", children: /* @__PURE__ */ jsx(IconCircleCheck, { size:
|
|
2847
|
-
uploadedFile.status === "error" && /* @__PURE__ */ jsx("div", { className: "ina-file-upload__file-icon-wrapper ina-file-upload__file-icon-wrapper--error", children: /* @__PURE__ */ jsx(IconCircleX, { size:
|
|
2848
|
-
uploadedFile.status === "idle" && /* @__PURE__ */ jsx("div", { className: "ina-file-upload__file-icon-wrapper ina-file-upload__file-icon-wrapper--success", children: /* @__PURE__ */ jsx(IconCircleCheck, { size:
|
|
2846
|
+
uploadedFile.status === "success" && /* @__PURE__ */ jsx("div", { className: "ina-file-upload__file-icon-wrapper ina-file-upload__file-icon-wrapper--success", children: /* @__PURE__ */ jsx(IconCircleCheck, { size: 20, stroke: "2" }) }),
|
|
2847
|
+
uploadedFile.status === "error" && /* @__PURE__ */ jsx("div", { className: "ina-file-upload__file-icon-wrapper ina-file-upload__file-icon-wrapper--error", children: /* @__PURE__ */ jsx(IconCircleX, { size: 20, stroke: "2" }) }),
|
|
2848
|
+
uploadedFile.status === "idle" && /* @__PURE__ */ jsx("div", { className: "ina-file-upload__file-icon-wrapper ina-file-upload__file-icon-wrapper--success", children: /* @__PURE__ */ jsx(IconCircleCheck, { size: 20, stroke: "2" }) })
|
|
2849
2849
|
] }),
|
|
2850
2850
|
/* @__PURE__ */ jsxs("div", { className: "ina-file-upload__file-info", children: [
|
|
2851
2851
|
/* @__PURE__ */ jsx("div", { className: "ina-file-upload__file-name", children: sanitizeFileName(uploadedFile.file.name) }),
|
|
@@ -2863,7 +2863,7 @@ function FileUpload({
|
|
|
2863
2863
|
updateFileStatus(originalIndex, "idle");
|
|
2864
2864
|
},
|
|
2865
2865
|
title: "Coba lagi",
|
|
2866
|
-
children: /* @__PURE__ */ jsx(IconRotateClockwise, { size:
|
|
2866
|
+
children: /* @__PURE__ */ jsx(IconRotateClockwise, { size: 20 })
|
|
2867
2867
|
}
|
|
2868
2868
|
),
|
|
2869
2869
|
/* @__PURE__ */ jsx(
|
|
@@ -2873,7 +2873,7 @@ function FileUpload({
|
|
|
2873
2873
|
className: "ina-file-upload__file-remove",
|
|
2874
2874
|
onClick: () => removeFile(originalIndex),
|
|
2875
2875
|
title: "Hapus file",
|
|
2876
|
-
children: /* @__PURE__ */ jsx(IconTrash, { size:
|
|
2876
|
+
children: /* @__PURE__ */ jsx(IconTrash, { size: 20 })
|
|
2877
2877
|
}
|
|
2878
2878
|
)
|
|
2879
2879
|
] }),
|
|
@@ -2884,7 +2884,7 @@ function FileUpload({
|
|
|
2884
2884
|
className: "ina-file-upload__file-remove",
|
|
2885
2885
|
onClick: () => removeFile(originalIndex),
|
|
2886
2886
|
title: "Batalkan upload",
|
|
2887
|
-
children: /* @__PURE__ */ jsx(IconX, { size:
|
|
2887
|
+
children: /* @__PURE__ */ jsx(IconX, { size: 20 })
|
|
2888
2888
|
}
|
|
2889
2889
|
),
|
|
2890
2890
|
uploadedFile.status === "success" && /* @__PURE__ */ jsx(
|
|
@@ -2894,7 +2894,7 @@ function FileUpload({
|
|
|
2894
2894
|
className: "ina-file-upload__file-remove",
|
|
2895
2895
|
onClick: () => removeFile(originalIndex),
|
|
2896
2896
|
title: "Hapus file",
|
|
2897
|
-
children: /* @__PURE__ */ jsx(IconTrash, { size:
|
|
2897
|
+
children: /* @__PURE__ */ jsx(IconTrash, { size: 20 })
|
|
2898
2898
|
}
|
|
2899
2899
|
),
|
|
2900
2900
|
uploadedFile.status === "idle" && /* @__PURE__ */ jsx(
|
|
@@ -2904,7 +2904,7 @@ function FileUpload({
|
|
|
2904
2904
|
className: "ina-file-upload__file-remove",
|
|
2905
2905
|
onClick: () => removeFile(originalIndex),
|
|
2906
2906
|
title: "Hapus file",
|
|
2907
|
-
children: /* @__PURE__ */ jsx(IconTrash, { size:
|
|
2907
|
+
children: /* @__PURE__ */ jsx(IconTrash, { size: 20 })
|
|
2908
2908
|
}
|
|
2909
2909
|
)
|
|
2910
2910
|
] })
|
|
@@ -3261,7 +3261,7 @@ function SingleFileUpload({
|
|
|
3261
3261
|
handleRemove();
|
|
3262
3262
|
},
|
|
3263
3263
|
"aria-label": "Remove file",
|
|
3264
|
-
children: /* @__PURE__ */ jsx(IconTrash, { size:
|
|
3264
|
+
children: /* @__PURE__ */ jsx(IconTrash, { size: 18 })
|
|
3265
3265
|
}
|
|
3266
3266
|
)
|
|
3267
3267
|
] })
|
|
@@ -3294,10 +3294,18 @@ function FieldInputTable({
|
|
|
3294
3294
|
const containerClasses = clsx("ina-field-input-table", className);
|
|
3295
3295
|
return /* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
|
|
3296
3296
|
/* @__PURE__ */ jsxs("div", { className: "ina-field-input-table__wrapper", children: [
|
|
3297
|
-
/* @__PURE__ */ jsx(
|
|
3297
|
+
/* @__PURE__ */ jsx(
|
|
3298
|
+
"label",
|
|
3299
|
+
{
|
|
3300
|
+
className: "ina-field-input-table__label",
|
|
3301
|
+
htmlFor: "field-input-table-input",
|
|
3302
|
+
children: placeholder
|
|
3303
|
+
}
|
|
3304
|
+
),
|
|
3298
3305
|
/* @__PURE__ */ jsx(
|
|
3299
3306
|
"input",
|
|
3300
3307
|
{
|
|
3308
|
+
id: "field-input-table-input",
|
|
3301
3309
|
type: "text",
|
|
3302
3310
|
className: "ina-field-input-table__input",
|
|
3303
3311
|
value,
|
|
@@ -4154,13 +4162,15 @@ function SelectDropdown({
|
|
|
4154
4162
|
onSearchChange,
|
|
4155
4163
|
disabled = false,
|
|
4156
4164
|
showPreviewValue = true,
|
|
4157
|
-
searchable = true
|
|
4165
|
+
searchable = true,
|
|
4166
|
+
onSelectedRawChange
|
|
4158
4167
|
}) {
|
|
4159
4168
|
const [isOpen, setIsOpen] = useState(false);
|
|
4160
4169
|
const [internalSearchTerm, setInternalSearchTerm] = useState("");
|
|
4161
4170
|
const containerRef = useRef(null);
|
|
4162
4171
|
const scrollContainerRef = useRef(null);
|
|
4163
4172
|
const searchTimeoutRef = useRef(null);
|
|
4173
|
+
const selectedLabelsCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
4164
4174
|
const isSearchControlled = searchValue !== void 0;
|
|
4165
4175
|
const searchTerm = isSearchControlled ? searchValue : internalSearchTerm;
|
|
4166
4176
|
useEffect(() => {
|
|
@@ -4218,16 +4228,88 @@ function SelectDropdown({
|
|
|
4218
4228
|
const isArraySelected = multiple && Array.isArray(selected);
|
|
4219
4229
|
const selectedArray = isArraySelected ? selected : [];
|
|
4220
4230
|
const singleSelected = !multiple ? selected : null;
|
|
4231
|
+
const getLabelForValue = (value) => {
|
|
4232
|
+
if (selectedLabelsCacheRef.current.has(value)) {
|
|
4233
|
+
return selectedLabelsCacheRef.current.get(value) || null;
|
|
4234
|
+
}
|
|
4235
|
+
const found = options.find((o) => o.value === value);
|
|
4236
|
+
if (found) {
|
|
4237
|
+
selectedLabelsCacheRef.current.set(value, found.label);
|
|
4238
|
+
return found.label;
|
|
4239
|
+
}
|
|
4240
|
+
return null;
|
|
4241
|
+
};
|
|
4242
|
+
const getOptionForValue = (value) => {
|
|
4243
|
+
const label = getLabelForValue(value);
|
|
4244
|
+
if (label !== null) {
|
|
4245
|
+
return { label, value };
|
|
4246
|
+
}
|
|
4247
|
+
const found = options.find((o) => o.value === value);
|
|
4248
|
+
return found || null;
|
|
4249
|
+
};
|
|
4250
|
+
useEffect(() => {
|
|
4251
|
+
if (onSelectedRawChange) {
|
|
4252
|
+
let selectedRaw = null;
|
|
4253
|
+
if (multiple) {
|
|
4254
|
+
if (selectedArray.length > 0) {
|
|
4255
|
+
const rawOptions = selectedArray.map((val) => getOptionForValue(val)).filter((opt) => opt !== null);
|
|
4256
|
+
selectedRaw = rawOptions.length > 0 ? rawOptions : null;
|
|
4257
|
+
}
|
|
4258
|
+
} else {
|
|
4259
|
+
if (singleSelected !== null && singleSelected !== void 0 && singleSelected !== "") {
|
|
4260
|
+
selectedRaw = getOptionForValue(singleSelected);
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4263
|
+
onSelectedRawChange(selectedRaw);
|
|
4264
|
+
}
|
|
4265
|
+
}, [selected, multiple, options]);
|
|
4266
|
+
useEffect(() => {
|
|
4267
|
+
const cache = selectedLabelsCacheRef.current;
|
|
4268
|
+
options.forEach((option) => {
|
|
4269
|
+
if (cache.has(option.value)) {
|
|
4270
|
+
cache.set(option.value, option.label);
|
|
4271
|
+
}
|
|
4272
|
+
});
|
|
4273
|
+
}, [options]);
|
|
4274
|
+
useEffect(() => {
|
|
4275
|
+
const cache = selectedLabelsCacheRef.current;
|
|
4276
|
+
if (multiple && Array.isArray(selected)) {
|
|
4277
|
+
selected.forEach((value) => {
|
|
4278
|
+
if (!cache.has(value)) {
|
|
4279
|
+
const found = options.find((o) => o.value === value);
|
|
4280
|
+
if (found) {
|
|
4281
|
+
cache.set(value, found.label);
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
});
|
|
4285
|
+
cache.forEach((_, value) => {
|
|
4286
|
+
if (!selected.includes(value)) {
|
|
4287
|
+
cache.delete(value);
|
|
4288
|
+
}
|
|
4289
|
+
});
|
|
4290
|
+
} else if (selected !== null && selected !== void 0 && selected !== "") {
|
|
4291
|
+
if (!cache.has(selected)) {
|
|
4292
|
+
const found = options.find((o) => o.value === selected);
|
|
4293
|
+
if (found) {
|
|
4294
|
+
cache.set(selected, found.label);
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4297
|
+
} else {
|
|
4298
|
+
cache.clear();
|
|
4299
|
+
}
|
|
4300
|
+
}, [selected, multiple, options]);
|
|
4221
4301
|
let triggerLabel;
|
|
4222
4302
|
if (multiple) {
|
|
4223
4303
|
if (!selectedArray.length) triggerLabel = placeholder;
|
|
4224
4304
|
else if (selectedArray.length > 3)
|
|
4225
4305
|
triggerLabel = `${selectedArray.length} data terpilih`;
|
|
4226
|
-
else
|
|
4227
|
-
|
|
4306
|
+
else {
|
|
4307
|
+
const labels = selectedArray.map((val) => getLabelForValue(val)).filter((label) => label !== null);
|
|
4308
|
+
triggerLabel = labels.length > 0 ? labels.join(", ") : placeholder;
|
|
4309
|
+
}
|
|
4228
4310
|
} else {
|
|
4229
|
-
const
|
|
4230
|
-
triggerLabel =
|
|
4311
|
+
const label = getLabelForValue(singleSelected);
|
|
4312
|
+
triggerLabel = label || placeholder;
|
|
4231
4313
|
}
|
|
4232
4314
|
const filteredOptions = onSearch ? options : !searchable ? options : options.filter(
|
|
4233
4315
|
(o) => o.label.toLowerCase().includes(searchTerm.toLowerCase())
|
|
@@ -4241,6 +4323,7 @@ function SelectDropdown({
|
|
|
4241
4323
|
}
|
|
4242
4324
|
};
|
|
4243
4325
|
const handleRemoveSelected = (value) => {
|
|
4326
|
+
selectedLabelsCacheRef.current.delete(value);
|
|
4244
4327
|
if (onRemoveSelected) {
|
|
4245
4328
|
onRemoveSelected(value);
|
|
4246
4329
|
} else {
|
|
@@ -4260,13 +4343,14 @@ function SelectDropdown({
|
|
|
4260
4343
|
if (multiple && selectedArray.length > 0) {
|
|
4261
4344
|
return /* @__PURE__ */ jsxs("div", { className: "ina-select-dropdown__preview-content", children: [
|
|
4262
4345
|
selectedArray.slice(0, 3).map((value, index) => {
|
|
4263
|
-
const
|
|
4346
|
+
const label = getLabelForValue(value);
|
|
4347
|
+
const displayLabel = label || value;
|
|
4264
4348
|
return /* @__PURE__ */ jsxs(
|
|
4265
4349
|
"div",
|
|
4266
4350
|
{
|
|
4267
4351
|
className: "ina-select-dropdown__preview-item ina-select-dropdown__preview-item--multiple",
|
|
4268
4352
|
children: [
|
|
4269
|
-
/* @__PURE__ */ jsx("span", { className: "ina-select-dropdown__preview-item-text", children:
|
|
4353
|
+
/* @__PURE__ */ jsx("span", { className: "ina-select-dropdown__preview-item-text", children: displayLabel }),
|
|
4270
4354
|
!disabled && /* @__PURE__ */ jsx(
|
|
4271
4355
|
"button",
|
|
4272
4356
|
{
|
|
@@ -4276,7 +4360,7 @@ function SelectDropdown({
|
|
|
4276
4360
|
handleRemoveSelected(value);
|
|
4277
4361
|
},
|
|
4278
4362
|
className: "ina-select-dropdown__preview-remove ina-select-dropdown__preview-remove--multiple",
|
|
4279
|
-
"aria-label": `Remove ${
|
|
4363
|
+
"aria-label": `Remove ${displayLabel}`,
|
|
4280
4364
|
disabled,
|
|
4281
4365
|
children: /* @__PURE__ */ jsx(IconX, { size: 12 })
|
|
4282
4366
|
}
|
|
@@ -4294,9 +4378,10 @@ function SelectDropdown({
|
|
|
4294
4378
|
] });
|
|
4295
4379
|
}
|
|
4296
4380
|
if (!multiple && singleSelected !== null && singleSelected !== void 0 && singleSelected !== "") {
|
|
4297
|
-
const
|
|
4381
|
+
const label = getLabelForValue(singleSelected);
|
|
4382
|
+
const displayLabel = label || singleSelected;
|
|
4298
4383
|
return /* @__PURE__ */ jsx("div", { className: "ina-select-dropdown__preview-content", children: /* @__PURE__ */ jsxs("div", { className: "ina-select-dropdown__preview-item ina-select-dropdown__preview-item--single", children: [
|
|
4299
|
-
/* @__PURE__ */ jsx("span", { className: "ina-select-dropdown__preview-item-text", children:
|
|
4384
|
+
/* @__PURE__ */ jsx("span", { className: "ina-select-dropdown__preview-item-text", children: displayLabel }),
|
|
4300
4385
|
!disabled && /* @__PURE__ */ jsx(
|
|
4301
4386
|
"button",
|
|
4302
4387
|
{
|
|
@@ -4306,7 +4391,7 @@ function SelectDropdown({
|
|
|
4306
4391
|
handleRemoveSelected(singleSelected);
|
|
4307
4392
|
},
|
|
4308
4393
|
className: "ina-select-dropdown__preview-remove ina-select-dropdown__preview-remove--single",
|
|
4309
|
-
"aria-label": `Remove ${
|
|
4394
|
+
"aria-label": `Remove ${displayLabel}`,
|
|
4310
4395
|
disabled,
|
|
4311
4396
|
children: /* @__PURE__ */ jsx(IconX, { size: 12 })
|
|
4312
4397
|
}
|
|
@@ -4440,11 +4525,27 @@ function SelectDropdown({
|
|
|
4440
4525
|
if (disabled) return;
|
|
4441
4526
|
if (multiple) {
|
|
4442
4527
|
const prev = Array.isArray(selected) ? [...selected] : [];
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4528
|
+
const newSelected = prev.includes(option.value) ? prev.filter((v) => v !== option.value) : [...prev, option.value];
|
|
4529
|
+
if (prev.includes(option.value)) {
|
|
4530
|
+
selectedLabelsCacheRef.current.delete(option.value);
|
|
4531
|
+
} else {
|
|
4532
|
+
selectedLabelsCacheRef.current.set(
|
|
4533
|
+
option.value,
|
|
4534
|
+
option.label
|
|
4535
|
+
);
|
|
4536
|
+
}
|
|
4537
|
+
onSelect(newSelected);
|
|
4446
4538
|
} else {
|
|
4447
|
-
|
|
4539
|
+
if (isSelected) {
|
|
4540
|
+
selectedLabelsCacheRef.current.delete(option.value);
|
|
4541
|
+
onSelect(null, option);
|
|
4542
|
+
} else {
|
|
4543
|
+
selectedLabelsCacheRef.current.set(
|
|
4544
|
+
option.value,
|
|
4545
|
+
option.label
|
|
4546
|
+
);
|
|
4547
|
+
onSelect(option.value, option);
|
|
4548
|
+
}
|
|
4448
4549
|
setIsOpen(false);
|
|
4449
4550
|
if (isSearchControlled) {
|
|
4450
4551
|
onSearchChange == null ? void 0 : onSearchChange("");
|
|
@@ -4520,7 +4621,8 @@ function Drawer({
|
|
|
4520
4621
|
if (!isOpen || !mounted) return null;
|
|
4521
4622
|
const containerClasses = clsx(
|
|
4522
4623
|
"ina-drawer",
|
|
4523
|
-
`ina-drawer--position-${position}
|
|
4624
|
+
`ina-drawer--position-${position}`,
|
|
4625
|
+
className
|
|
4524
4626
|
);
|
|
4525
4627
|
const panelClasses = clsx(
|
|
4526
4628
|
"ina-drawer__panel",
|
|
@@ -4579,7 +4681,7 @@ function Drawer({
|
|
|
4579
4681
|
"div",
|
|
4580
4682
|
{
|
|
4581
4683
|
onClick: (e) => e.stopPropagation(),
|
|
4582
|
-
className:
|
|
4684
|
+
className: panelClasses,
|
|
4583
4685
|
style: panelStyle,
|
|
4584
4686
|
children: [
|
|
4585
4687
|
position !== "top" && /* @__PURE__ */ jsxs("div", { className: headerClasses, children: [
|
|
@@ -5168,13 +5270,21 @@ function TextArea({
|
|
|
5168
5270
|
);
|
|
5169
5271
|
const bottomText = status !== "neutral" && statusMessage != null ? statusMessage : helperText;
|
|
5170
5272
|
return /* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
|
|
5171
|
-
label && /* @__PURE__ */ jsx(
|
|
5273
|
+
label && /* @__PURE__ */ jsx(
|
|
5274
|
+
"label",
|
|
5275
|
+
{
|
|
5276
|
+
className: "ina-text-area__label",
|
|
5277
|
+
htmlFor: (rest == null ? void 0 : rest.id) || (rest == null ? void 0 : rest.name) ? String((rest == null ? void 0 : rest.id) || (rest == null ? void 0 : rest.name)) : String(label).toLowerCase(),
|
|
5278
|
+
children: label
|
|
5279
|
+
}
|
|
5280
|
+
),
|
|
5172
5281
|
/* @__PURE__ */ jsxs("div", { className: wrapperClasses, children: [
|
|
5173
5282
|
prefixIcon && /* @__PURE__ */ jsx("div", { className: "ina-text-area__prefix-icon", children: prefixIcon }),
|
|
5174
5283
|
/* @__PURE__ */ jsx(
|
|
5175
5284
|
"textarea",
|
|
5176
5285
|
{
|
|
5177
5286
|
...rest,
|
|
5287
|
+
id: (rest == null ? void 0 : rest.id) || (rest == null ? void 0 : rest.name) ? String((rest == null ? void 0 : rest.id) || (rest == null ? void 0 : rest.name)) : String(label).toLowerCase(),
|
|
5178
5288
|
ref: taRef,
|
|
5179
5289
|
rows,
|
|
5180
5290
|
className: "ina-text-area__input",
|
|
@@ -8128,52 +8238,42 @@ function YearPicker({
|
|
|
8128
8238
|
useEffect(() => {
|
|
8129
8239
|
if (isOpen && triggerRef.current) {
|
|
8130
8240
|
const calculatePosition = () => {
|
|
8241
|
+
var _a;
|
|
8131
8242
|
if (!triggerRef.current || !panelRef.current) return;
|
|
8132
8243
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
8133
8244
|
const panelRect = panelRef.current.getBoundingClientRect();
|
|
8134
8245
|
const viewportWidth = window.innerWidth;
|
|
8135
8246
|
const viewportHeight = window.innerHeight;
|
|
8136
|
-
const
|
|
8247
|
+
const isMobile = viewportWidth <= 640;
|
|
8248
|
+
const defaultPanelWidth = isMobile ? 200 : 320;
|
|
8137
8249
|
const panelWidthValue = panelRect.width || defaultPanelWidth;
|
|
8138
8250
|
const availableSpaceRight = viewportWidth - triggerRect.right;
|
|
8139
|
-
const isMobile = viewportWidth <= 640;
|
|
8140
8251
|
let left = void 0;
|
|
8141
8252
|
let right = void 0;
|
|
8142
8253
|
let shouldUseRight = false;
|
|
8143
8254
|
if (isMobile) {
|
|
8144
|
-
const
|
|
8145
|
-
const
|
|
8146
|
-
const
|
|
8147
|
-
if (
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
} else if (triggerRect.left < threshold) {
|
|
8152
|
-
shouldUseRight = false;
|
|
8153
|
-
left = triggerRect.left;
|
|
8154
|
-
right = void 0;
|
|
8155
|
-
} else if (Math.abs(triggerCenter - viewportCenter) < panelWidthValue / 2) {
|
|
8156
|
-
const panelLeft = triggerRect.left - (panelWidthValue - triggerRect.width) / 2;
|
|
8157
|
-
if (panelLeft < 0) {
|
|
8158
|
-
left = 0;
|
|
8159
|
-
right = void 0;
|
|
8160
|
-
} else if (panelLeft + panelWidthValue > viewportWidth) {
|
|
8161
|
-
right = 0;
|
|
8162
|
-
left = void 0;
|
|
8163
|
-
} else {
|
|
8164
|
-
left = panelLeft;
|
|
8165
|
-
right = void 0;
|
|
8255
|
+
const panelCenterX = viewportWidth / 2;
|
|
8256
|
+
const panelLeftFromViewport = panelCenterX - panelWidthValue / 2;
|
|
8257
|
+
const containerRect = (_a = containerRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
8258
|
+
if (containerRect) {
|
|
8259
|
+
let calculatedLeft = panelLeftFromViewport - containerRect.left;
|
|
8260
|
+
if (calculatedLeft < 0) {
|
|
8261
|
+
calculatedLeft = 0;
|
|
8166
8262
|
}
|
|
8263
|
+
const panelRightInViewport = containerRect.left + calculatedLeft + panelWidthValue;
|
|
8264
|
+
if (panelRightInViewport > viewportWidth) {
|
|
8265
|
+
calculatedLeft = viewportWidth - panelWidthValue - containerRect.left;
|
|
8266
|
+
if (calculatedLeft < 0) {
|
|
8267
|
+
calculatedLeft = 0;
|
|
8268
|
+
}
|
|
8269
|
+
}
|
|
8270
|
+
left = calculatedLeft;
|
|
8271
|
+
right = void 0;
|
|
8167
8272
|
shouldUseRight = false;
|
|
8168
8273
|
} else {
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
left = void 0;
|
|
8173
|
-
} else {
|
|
8174
|
-
left = triggerRect.left;
|
|
8175
|
-
right = void 0;
|
|
8176
|
-
}
|
|
8274
|
+
left = Math.max(0, panelLeftFromViewport);
|
|
8275
|
+
right = void 0;
|
|
8276
|
+
shouldUseRight = false;
|
|
8177
8277
|
}
|
|
8178
8278
|
} else {
|
|
8179
8279
|
shouldUseRight = panelWidthValue > availableSpaceRight;
|
|
@@ -8483,6 +8583,7 @@ function MonthPicker({
|
|
|
8483
8583
|
useEffect(() => {
|
|
8484
8584
|
if (isOpen && triggerRef.current) {
|
|
8485
8585
|
const calculatePosition = () => {
|
|
8586
|
+
var _a;
|
|
8486
8587
|
if (!triggerRef.current || !panelRef.current) return;
|
|
8487
8588
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
8488
8589
|
const panelRect = panelRef.current.getBoundingClientRect();
|
|
@@ -8496,39 +8597,28 @@ function MonthPicker({
|
|
|
8496
8597
|
let right = void 0;
|
|
8497
8598
|
let shouldUseRight = false;
|
|
8498
8599
|
if (isMobile) {
|
|
8499
|
-
const
|
|
8500
|
-
const
|
|
8501
|
-
const
|
|
8502
|
-
if (
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
} else if (triggerRect.left < threshold) {
|
|
8507
|
-
shouldUseRight = false;
|
|
8508
|
-
left = triggerRect.left;
|
|
8509
|
-
right = void 0;
|
|
8510
|
-
} else if (Math.abs(triggerCenter - viewportCenter) < panelWidthValue / 2) {
|
|
8511
|
-
const panelLeft = triggerRect.left - (panelWidthValue - triggerRect.width) / 2;
|
|
8512
|
-
if (panelLeft < 0) {
|
|
8513
|
-
left = 0;
|
|
8514
|
-
right = void 0;
|
|
8515
|
-
} else if (panelLeft + panelWidthValue > viewportWidth) {
|
|
8516
|
-
right = 0;
|
|
8517
|
-
left = void 0;
|
|
8518
|
-
} else {
|
|
8519
|
-
left = panelLeft;
|
|
8520
|
-
right = void 0;
|
|
8600
|
+
const panelCenterX = viewportWidth / 2;
|
|
8601
|
+
const panelLeftFromViewport = panelCenterX - panelWidthValue / 2;
|
|
8602
|
+
const containerRect = (_a = containerRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
8603
|
+
if (containerRect) {
|
|
8604
|
+
let calculatedLeft = panelLeftFromViewport - containerRect.left;
|
|
8605
|
+
if (calculatedLeft < 0) {
|
|
8606
|
+
calculatedLeft = 0;
|
|
8521
8607
|
}
|
|
8608
|
+
const panelRightInViewport = containerRect.left + calculatedLeft + panelWidthValue;
|
|
8609
|
+
if (panelRightInViewport > viewportWidth) {
|
|
8610
|
+
calculatedLeft = viewportWidth - panelWidthValue - containerRect.left;
|
|
8611
|
+
if (calculatedLeft < 0) {
|
|
8612
|
+
calculatedLeft = 0;
|
|
8613
|
+
}
|
|
8614
|
+
}
|
|
8615
|
+
left = calculatedLeft;
|
|
8616
|
+
right = void 0;
|
|
8522
8617
|
shouldUseRight = false;
|
|
8523
8618
|
} else {
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
left = void 0;
|
|
8528
|
-
} else {
|
|
8529
|
-
left = triggerRect.left;
|
|
8530
|
-
right = void 0;
|
|
8531
|
-
}
|
|
8619
|
+
left = Math.max(0, panelLeftFromViewport);
|
|
8620
|
+
right = void 0;
|
|
8621
|
+
shouldUseRight = false;
|
|
8532
8622
|
}
|
|
8533
8623
|
} else {
|
|
8534
8624
|
shouldUseRight = panelWidthValue > availableSpaceRight;
|
|
@@ -8793,7 +8883,7 @@ function DatePicker({
|
|
|
8793
8883
|
popperPlacement = "bottom-start",
|
|
8794
8884
|
dateFormat = "dd/MM/yyyy",
|
|
8795
8885
|
className = "",
|
|
8796
|
-
triggerWidth = "
|
|
8886
|
+
triggerWidth = "",
|
|
8797
8887
|
panelMaxHeight,
|
|
8798
8888
|
panelClassName = "",
|
|
8799
8889
|
triggerClassname = "",
|
|
@@ -9793,22 +9883,30 @@ function MultipleChoiceGrid({
|
|
|
9793
9883
|
"div",
|
|
9794
9884
|
{
|
|
9795
9885
|
className: "ina-multiple-choice-grid__cell",
|
|
9796
|
-
children: /* @__PURE__ */ jsxs(
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9886
|
+
children: /* @__PURE__ */ jsxs(
|
|
9887
|
+
"label",
|
|
9888
|
+
{
|
|
9889
|
+
className: "ina-multiple-choice-grid__radio-label",
|
|
9890
|
+
htmlFor: `${name}-${row.id}-${column.id}`,
|
|
9891
|
+
children: [
|
|
9892
|
+
/* @__PURE__ */ jsx(
|
|
9893
|
+
"input",
|
|
9894
|
+
{
|
|
9895
|
+
id: `${name}-${row.id}-${column.id}`,
|
|
9896
|
+
type: "radio",
|
|
9897
|
+
name: `${name}-${row.id}`,
|
|
9898
|
+
value: column.id,
|
|
9899
|
+
checked: isSelected(row.id, column.id),
|
|
9900
|
+
onChange: handleRadioChange,
|
|
9901
|
+
disabled,
|
|
9902
|
+
className: "ina-multiple-choice-grid__radio-input",
|
|
9903
|
+
"aria-label": `${row.label} ${column.label}`
|
|
9904
|
+
}
|
|
9905
|
+
),
|
|
9906
|
+
/* @__PURE__ */ jsx("span", { className: "ina-multiple-choice-grid__radio-custom" })
|
|
9907
|
+
]
|
|
9908
|
+
}
|
|
9909
|
+
)
|
|
9812
9910
|
},
|
|
9813
9911
|
`${row.id}-${column.id}`
|
|
9814
9912
|
))
|