@idds/react 1.3.2 → 1.4.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.
- package/dist/index.cjs.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +93 -87
- package/dist/index.umd.js +2 -2
- package/dist/types/components/Accordion.d.ts.map +1 -1
- package/dist/types/components/Checkbox.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/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;
|
|
@@ -1679,6 +1678,7 @@ function Checkbox({
|
|
|
1679
1678
|
const checkboxClasses = clsx(
|
|
1680
1679
|
"ina-checkbox",
|
|
1681
1680
|
{ "ina-checkbox--disabled": disabled },
|
|
1681
|
+
{ "ina-checkbox--with-subtext": subtext },
|
|
1682
1682
|
className
|
|
1683
1683
|
);
|
|
1684
1684
|
return /* @__PURE__ */ jsxs("label", { htmlFor: id, className: checkboxClasses, children: [
|
|
@@ -2095,6 +2095,7 @@ function TextField({
|
|
|
2095
2095
|
"input",
|
|
2096
2096
|
{
|
|
2097
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(),
|
|
2098
2099
|
type: rest.type ?? "text",
|
|
2099
2100
|
className: clsx("ina-text-field__input", className),
|
|
2100
2101
|
value: inner,
|
|
@@ -3293,10 +3294,18 @@ function FieldInputTable({
|
|
|
3293
3294
|
const containerClasses = clsx("ina-field-input-table", className);
|
|
3294
3295
|
return /* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
|
|
3295
3296
|
/* @__PURE__ */ jsxs("div", { className: "ina-field-input-table__wrapper", children: [
|
|
3296
|
-
/* @__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
|
+
),
|
|
3297
3305
|
/* @__PURE__ */ jsx(
|
|
3298
3306
|
"input",
|
|
3299
3307
|
{
|
|
3308
|
+
id: "field-input-table-input",
|
|
3300
3309
|
type: "text",
|
|
3301
3310
|
className: "ina-field-input-table__input",
|
|
3302
3311
|
value,
|
|
@@ -4519,7 +4528,8 @@ function Drawer({
|
|
|
4519
4528
|
if (!isOpen || !mounted) return null;
|
|
4520
4529
|
const containerClasses = clsx(
|
|
4521
4530
|
"ina-drawer",
|
|
4522
|
-
`ina-drawer--position-${position}
|
|
4531
|
+
`ina-drawer--position-${position}`,
|
|
4532
|
+
className
|
|
4523
4533
|
);
|
|
4524
4534
|
const panelClasses = clsx(
|
|
4525
4535
|
"ina-drawer__panel",
|
|
@@ -4578,7 +4588,7 @@ function Drawer({
|
|
|
4578
4588
|
"div",
|
|
4579
4589
|
{
|
|
4580
4590
|
onClick: (e) => e.stopPropagation(),
|
|
4581
|
-
className:
|
|
4591
|
+
className: panelClasses,
|
|
4582
4592
|
style: panelStyle,
|
|
4583
4593
|
children: [
|
|
4584
4594
|
position !== "top" && /* @__PURE__ */ jsxs("div", { className: headerClasses, children: [
|
|
@@ -5167,13 +5177,21 @@ function TextArea({
|
|
|
5167
5177
|
);
|
|
5168
5178
|
const bottomText = status !== "neutral" && statusMessage != null ? statusMessage : helperText;
|
|
5169
5179
|
return /* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
|
|
5170
|
-
label && /* @__PURE__ */ jsx(
|
|
5180
|
+
label && /* @__PURE__ */ jsx(
|
|
5181
|
+
"label",
|
|
5182
|
+
{
|
|
5183
|
+
className: "ina-text-area__label",
|
|
5184
|
+
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(),
|
|
5185
|
+
children: label
|
|
5186
|
+
}
|
|
5187
|
+
),
|
|
5171
5188
|
/* @__PURE__ */ jsxs("div", { className: wrapperClasses, children: [
|
|
5172
5189
|
prefixIcon && /* @__PURE__ */ jsx("div", { className: "ina-text-area__prefix-icon", children: prefixIcon }),
|
|
5173
5190
|
/* @__PURE__ */ jsx(
|
|
5174
5191
|
"textarea",
|
|
5175
5192
|
{
|
|
5176
5193
|
...rest,
|
|
5194
|
+
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(),
|
|
5177
5195
|
ref: taRef,
|
|
5178
5196
|
rows,
|
|
5179
5197
|
className: "ina-text-area__input",
|
|
@@ -8127,52 +8145,42 @@ function YearPicker({
|
|
|
8127
8145
|
useEffect(() => {
|
|
8128
8146
|
if (isOpen && triggerRef.current) {
|
|
8129
8147
|
const calculatePosition = () => {
|
|
8148
|
+
var _a;
|
|
8130
8149
|
if (!triggerRef.current || !panelRef.current) return;
|
|
8131
8150
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
8132
8151
|
const panelRect = panelRef.current.getBoundingClientRect();
|
|
8133
8152
|
const viewportWidth = window.innerWidth;
|
|
8134
8153
|
const viewportHeight = window.innerHeight;
|
|
8135
|
-
const
|
|
8154
|
+
const isMobile = viewportWidth <= 640;
|
|
8155
|
+
const defaultPanelWidth = isMobile ? 200 : 320;
|
|
8136
8156
|
const panelWidthValue = panelRect.width || defaultPanelWidth;
|
|
8137
8157
|
const availableSpaceRight = viewportWidth - triggerRect.right;
|
|
8138
|
-
const isMobile = viewportWidth <= 640;
|
|
8139
8158
|
let left = void 0;
|
|
8140
8159
|
let right = void 0;
|
|
8141
8160
|
let shouldUseRight = false;
|
|
8142
8161
|
if (isMobile) {
|
|
8143
|
-
const
|
|
8144
|
-
const
|
|
8145
|
-
const
|
|
8146
|
-
if (
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
left = 0;
|
|
8158
|
-
right = void 0;
|
|
8159
|
-
} else if (panelLeft + panelWidthValue > viewportWidth) {
|
|
8160
|
-
right = 0;
|
|
8161
|
-
left = void 0;
|
|
8162
|
-
} else {
|
|
8163
|
-
left = panelLeft;
|
|
8164
|
-
right = void 0;
|
|
8162
|
+
const panelCenterX = viewportWidth / 2;
|
|
8163
|
+
const panelLeftFromViewport = panelCenterX - panelWidthValue / 2;
|
|
8164
|
+
const containerRect = (_a = containerRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
8165
|
+
if (containerRect) {
|
|
8166
|
+
let calculatedLeft = panelLeftFromViewport - containerRect.left;
|
|
8167
|
+
if (calculatedLeft < 0) {
|
|
8168
|
+
calculatedLeft = 0;
|
|
8169
|
+
}
|
|
8170
|
+
const panelRightInViewport = containerRect.left + calculatedLeft + panelWidthValue;
|
|
8171
|
+
if (panelRightInViewport > viewportWidth) {
|
|
8172
|
+
calculatedLeft = viewportWidth - panelWidthValue - containerRect.left;
|
|
8173
|
+
if (calculatedLeft < 0) {
|
|
8174
|
+
calculatedLeft = 0;
|
|
8175
|
+
}
|
|
8165
8176
|
}
|
|
8177
|
+
left = calculatedLeft;
|
|
8178
|
+
right = void 0;
|
|
8166
8179
|
shouldUseRight = false;
|
|
8167
8180
|
} else {
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
left = void 0;
|
|
8172
|
-
} else {
|
|
8173
|
-
left = triggerRect.left;
|
|
8174
|
-
right = void 0;
|
|
8175
|
-
}
|
|
8181
|
+
left = Math.max(0, panelLeftFromViewport);
|
|
8182
|
+
right = void 0;
|
|
8183
|
+
shouldUseRight = false;
|
|
8176
8184
|
}
|
|
8177
8185
|
} else {
|
|
8178
8186
|
shouldUseRight = panelWidthValue > availableSpaceRight;
|
|
@@ -8482,6 +8490,7 @@ function MonthPicker({
|
|
|
8482
8490
|
useEffect(() => {
|
|
8483
8491
|
if (isOpen && triggerRef.current) {
|
|
8484
8492
|
const calculatePosition = () => {
|
|
8493
|
+
var _a;
|
|
8485
8494
|
if (!triggerRef.current || !panelRef.current) return;
|
|
8486
8495
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
8487
8496
|
const panelRect = panelRef.current.getBoundingClientRect();
|
|
@@ -8495,39 +8504,28 @@ function MonthPicker({
|
|
|
8495
8504
|
let right = void 0;
|
|
8496
8505
|
let shouldUseRight = false;
|
|
8497
8506
|
if (isMobile) {
|
|
8498
|
-
const
|
|
8499
|
-
const
|
|
8500
|
-
const
|
|
8501
|
-
if (
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
left = 0;
|
|
8513
|
-
right = void 0;
|
|
8514
|
-
} else if (panelLeft + panelWidthValue > viewportWidth) {
|
|
8515
|
-
right = 0;
|
|
8516
|
-
left = void 0;
|
|
8517
|
-
} else {
|
|
8518
|
-
left = panelLeft;
|
|
8519
|
-
right = void 0;
|
|
8507
|
+
const panelCenterX = viewportWidth / 2;
|
|
8508
|
+
const panelLeftFromViewport = panelCenterX - panelWidthValue / 2;
|
|
8509
|
+
const containerRect = (_a = containerRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
8510
|
+
if (containerRect) {
|
|
8511
|
+
let calculatedLeft = panelLeftFromViewport - containerRect.left;
|
|
8512
|
+
if (calculatedLeft < 0) {
|
|
8513
|
+
calculatedLeft = 0;
|
|
8514
|
+
}
|
|
8515
|
+
const panelRightInViewport = containerRect.left + calculatedLeft + panelWidthValue;
|
|
8516
|
+
if (panelRightInViewport > viewportWidth) {
|
|
8517
|
+
calculatedLeft = viewportWidth - panelWidthValue - containerRect.left;
|
|
8518
|
+
if (calculatedLeft < 0) {
|
|
8519
|
+
calculatedLeft = 0;
|
|
8520
|
+
}
|
|
8520
8521
|
}
|
|
8522
|
+
left = calculatedLeft;
|
|
8523
|
+
right = void 0;
|
|
8521
8524
|
shouldUseRight = false;
|
|
8522
8525
|
} else {
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
left = void 0;
|
|
8527
|
-
} else {
|
|
8528
|
-
left = triggerRect.left;
|
|
8529
|
-
right = void 0;
|
|
8530
|
-
}
|
|
8526
|
+
left = Math.max(0, panelLeftFromViewport);
|
|
8527
|
+
right = void 0;
|
|
8528
|
+
shouldUseRight = false;
|
|
8531
8529
|
}
|
|
8532
8530
|
} else {
|
|
8533
8531
|
shouldUseRight = panelWidthValue > availableSpaceRight;
|
|
@@ -8792,7 +8790,7 @@ function DatePicker({
|
|
|
8792
8790
|
popperPlacement = "bottom-start",
|
|
8793
8791
|
dateFormat = "dd/MM/yyyy",
|
|
8794
8792
|
className = "",
|
|
8795
|
-
triggerWidth = "
|
|
8793
|
+
triggerWidth = "",
|
|
8796
8794
|
panelMaxHeight,
|
|
8797
8795
|
panelClassName = "",
|
|
8798
8796
|
triggerClassname = "",
|
|
@@ -9792,22 +9790,30 @@ function MultipleChoiceGrid({
|
|
|
9792
9790
|
"div",
|
|
9793
9791
|
{
|
|
9794
9792
|
className: "ina-multiple-choice-grid__cell",
|
|
9795
|
-
children: /* @__PURE__ */ jsxs(
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9793
|
+
children: /* @__PURE__ */ jsxs(
|
|
9794
|
+
"label",
|
|
9795
|
+
{
|
|
9796
|
+
className: "ina-multiple-choice-grid__radio-label",
|
|
9797
|
+
htmlFor: `${name}-${row.id}-${column.id}`,
|
|
9798
|
+
children: [
|
|
9799
|
+
/* @__PURE__ */ jsx(
|
|
9800
|
+
"input",
|
|
9801
|
+
{
|
|
9802
|
+
id: `${name}-${row.id}-${column.id}`,
|
|
9803
|
+
type: "radio",
|
|
9804
|
+
name: `${name}-${row.id}`,
|
|
9805
|
+
value: column.id,
|
|
9806
|
+
checked: isSelected(row.id, column.id),
|
|
9807
|
+
onChange: handleRadioChange,
|
|
9808
|
+
disabled,
|
|
9809
|
+
className: "ina-multiple-choice-grid__radio-input",
|
|
9810
|
+
"aria-label": `${row.label} ${column.label}`
|
|
9811
|
+
}
|
|
9812
|
+
),
|
|
9813
|
+
/* @__PURE__ */ jsx("span", { className: "ina-multiple-choice-grid__radio-custom" })
|
|
9814
|
+
]
|
|
9815
|
+
}
|
|
9816
|
+
)
|
|
9811
9817
|
},
|
|
9812
9818
|
`${row.id}-${column.id}`
|
|
9813
9819
|
))
|