@geoinsight/react-components 0.5.1 → 0.5.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.
@@ -152,7 +152,7 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
152
152
  }
153
153
 
154
154
  .accordion-button__button--dark.button {
155
- background-color: var(--color-neutral-200);
155
+ background-color: var(--color-neutral-400);
156
156
  }
157
157
 
158
158
  .accordion-button__button--light.button {
@@ -160,7 +160,7 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
160
160
  }
161
161
 
162
162
  .accordion-button__link--dark.button {
163
- background-color: var(--color-neutral-100) !important;
163
+ background-color: var(--color-neutral-200) !important;
164
164
  }
165
165
 
166
166
  .accordion-button__link--light.button {
package/dist/cjs/index.js CHANGED
@@ -9,6 +9,14 @@ var reactHookForm = require('react-hook-form');
9
9
  var io5 = require('react-icons/io5');
10
10
  var tb = require('react-icons/tb');
11
11
 
12
+ let uniqueId = (function () {
13
+ let num = 0;
14
+ return function (prefix) {
15
+ prefix = String(prefix) || '';
16
+ num += 1;
17
+ return prefix + num;
18
+ };
19
+ }());
12
20
  function recursiveChildren(children, i = 0) {
13
21
  return react.Children.map(children, (child, index) => {
14
22
  if (!react.isValidElement(child)) {
@@ -19,7 +27,7 @@ function recursiveChildren(children, i = 0) {
19
27
  ...child.props,
20
28
  children: recursiveChildren(child.props.children, i++),
21
29
  ...(child?.type?.name === "AccordionItem" && {
22
- label: `${child?.type?.name}-${index}-${i}`,
30
+ label: uniqueId("id_") // `${(child?.type as any)?.name}-${index}-${i}`,
23
31
  }),
24
32
  });
25
33
  }
@@ -58,7 +66,7 @@ function recursiveToggle(children, toggleArray = {}, i = 0, props) {
58
66
 
59
67
  const AccordionContext = react.createContext(undefined);
60
68
  function AccordionProvider({ children, expanded = "all" }) {
61
- const newChildren = recursiveChildren(children, 0);
69
+ const newChildren = react.useMemo(() => recursiveChildren(children, 0), []);
62
70
  const [toggle, _setToggle] = react.useState(recursiveToggle(newChildren, {}, 0, { expanded }));
63
71
  const setToggle = (prev) => {
64
72
  _setToggle(prev);
@@ -84,7 +92,7 @@ function Accordion({ children, expanded = "all",
84
92
  function AccordionItem({ children, label, isExpanded = false, }) {
85
93
  const { toggle } = useAccordion();
86
94
  return (jsxRuntime.jsx("div", { className: "accordion-item", style: {
87
- paddingLeft: toggle && label && toggle[label].paddingLeft,
95
+ paddingLeft: toggle && label && toggle[label]?.paddingLeft,
88
96
  }, children: react.Children.map(children, (child) => react.cloneElement(child, {
89
97
  toggle: toggle,
90
98
  // setToggle: setToggle,
@@ -209,8 +217,8 @@ function Form({ children, onSubmit, submitButton = {
209
217
  function Input({ className = "", classNameGroup = "", error = {
210
218
  is: false,
211
219
  message: "",
212
- }, inputRef, styleGroup, placeholder = "Insert value", isRequired, ...rest }) {
213
- return (jsxRuntime.jsxs("div", { className: clsx("input-group", classNameGroup), style: styleGroup, children: [jsxRuntime.jsx("input", { ref: inputRef, className: clsx("input", error.is ? "input--error" : "", className), placeholder: placeholder, ...rest }), error && error.is && jsxRuntime.jsx("span", { className: "error", children: error.message })] }));
220
+ }, inputRef, styleGroup, placeholder = "Insert value", isRequired, label, labelClass, ...rest }) {
221
+ return (jsxRuntime.jsxs("div", { className: clsx("input-group", classNameGroup), style: styleGroup, children: [label && jsxRuntime.jsx("label", { className: labelClass, children: label }), jsxRuntime.jsx("input", { ref: inputRef, className: clsx("input", error.is ? "input--error" : "", className), placeholder: placeholder, ...rest }), error && error.is && jsxRuntime.jsx("span", { className: "error", children: error.message })] }));
214
222
  }
215
223
 
216
224
  function Loading({ img, children }) {
@@ -221,7 +229,7 @@ function Modal({ modalref, children, title, subtitle, footer, hasCloseButton = t
221
229
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "modal-overlay" }), jsxRuntime.jsxs("div", { ref: modalref, className: "modal", children: [hasCloseButton && (jsxRuntime.jsx(Button, { mode: "secondary", className: "modal__close", size: "small", onClick: handleClose, children: jsxRuntime.jsx(io5.IoClose, {}) })), jsxRuntime.jsxs("div", { className: "modal__content", children: [title && (jsxRuntime.jsxs("div", { className: "modal__header", children: [jsxRuntime.jsx("h3", { children: title }), jsxRuntime.jsx("h6", { children: subtitle })] })), jsxRuntime.jsx("div", { className: "modal__children", children: children }), footer && jsxRuntime.jsx("div", { className: "modal__footer", children: footer })] })] })] }));
222
230
  }
223
231
 
224
- function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", ...rest }) {
232
+ function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", label, labelClass, ...rest }) {
225
233
  const ref = react.useRef();
226
234
  const [isShow, setIsShow] = react.useState(false);
227
235
  const handleClickToggle = () => {
@@ -235,7 +243,7 @@ function TextArea({ className = "", disabled = true, hasToggleButton = true, hid
235
243
  setIsShow((prev) => !prev);
236
244
  }
237
245
  };
238
- return (jsxRuntime.jsxs("div", { className: clsx("textarea", className), style: style, children: [jsxRuntime.jsx("textarea", { ref: ref, className: clsx("textarea__input", textareaClassName), style: {
246
+ return (jsxRuntime.jsxs("div", { className: clsx("textarea", className), style: style, children: [label && jsxRuntime.jsx("label", { className: labelClass, children: label }), jsxRuntime.jsx("textarea", { ref: ref, className: clsx("textarea__input", textareaClassName), style: {
239
247
  height: hasToggleButton ? hideHeight : showHeight,
240
248
  }, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsxRuntime.jsx("button", { type: "button", className: clsx("textarea__button", isShow && "textarea__button--show"), onClick: handleClickToggle, disabled: disabled, children: jsxRuntime.jsx(tb.TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
241
249
  }
@@ -152,7 +152,7 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
152
152
  }
153
153
 
154
154
  .accordion-button__button--dark.button {
155
- background-color: var(--color-neutral-200);
155
+ background-color: var(--color-neutral-400);
156
156
  }
157
157
 
158
158
  .accordion-button__button--light.button {
@@ -160,7 +160,7 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
160
160
  }
161
161
 
162
162
  .accordion-button__link--dark.button {
163
- background-color: var(--color-neutral-100) !important;
163
+ background-color: var(--color-neutral-200) !important;
164
164
  }
165
165
 
166
166
  .accordion-button__link--light.button {
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { Children, isValidElement, cloneElement, createContext, useState, useContext, useEffect, useRef, useReducer } from 'react';
2
+ import { Children, isValidElement, cloneElement, createContext, useMemo, useState, useContext, useEffect, useRef, useReducer } from 'react';
3
3
  import clsx from 'clsx';
4
4
  import { TfiAngleDown, TfiAngleUp } from 'react-icons/tfi';
5
5
  import { BsCheckCircleFill, BsXCircleFill } from 'react-icons/bs';
@@ -7,6 +7,14 @@ import { useForm, Controller } from 'react-hook-form';
7
7
  import { IoClose } from 'react-icons/io5';
8
8
  import { TbArrowsDiagonal2 } from 'react-icons/tb';
9
9
 
10
+ let uniqueId = (function () {
11
+ let num = 0;
12
+ return function (prefix) {
13
+ prefix = String(prefix) || '';
14
+ num += 1;
15
+ return prefix + num;
16
+ };
17
+ }());
10
18
  function recursiveChildren(children, i = 0) {
11
19
  return Children.map(children, (child, index) => {
12
20
  if (!isValidElement(child)) {
@@ -17,7 +25,7 @@ function recursiveChildren(children, i = 0) {
17
25
  ...child.props,
18
26
  children: recursiveChildren(child.props.children, i++),
19
27
  ...(child?.type?.name === "AccordionItem" && {
20
- label: `${child?.type?.name}-${index}-${i}`,
28
+ label: uniqueId("id_") // `${(child?.type as any)?.name}-${index}-${i}`,
21
29
  }),
22
30
  });
23
31
  }
@@ -56,7 +64,7 @@ function recursiveToggle(children, toggleArray = {}, i = 0, props) {
56
64
 
57
65
  const AccordionContext = createContext(undefined);
58
66
  function AccordionProvider({ children, expanded = "all" }) {
59
- const newChildren = recursiveChildren(children, 0);
67
+ const newChildren = useMemo(() => recursiveChildren(children, 0), []);
60
68
  const [toggle, _setToggle] = useState(recursiveToggle(newChildren, {}, 0, { expanded }));
61
69
  const setToggle = (prev) => {
62
70
  _setToggle(prev);
@@ -82,7 +90,7 @@ function Accordion({ children, expanded = "all",
82
90
  function AccordionItem({ children, label, isExpanded = false, }) {
83
91
  const { toggle } = useAccordion();
84
92
  return (jsx("div", { className: "accordion-item", style: {
85
- paddingLeft: toggle && label && toggle[label].paddingLeft,
93
+ paddingLeft: toggle && label && toggle[label]?.paddingLeft,
86
94
  }, children: Children.map(children, (child) => cloneElement(child, {
87
95
  toggle: toggle,
88
96
  // setToggle: setToggle,
@@ -207,8 +215,8 @@ function Form({ children, onSubmit, submitButton = {
207
215
  function Input({ className = "", classNameGroup = "", error = {
208
216
  is: false,
209
217
  message: "",
210
- }, inputRef, styleGroup, placeholder = "Insert value", isRequired, ...rest }) {
211
- return (jsxs("div", { className: clsx("input-group", classNameGroup), style: styleGroup, children: [jsx("input", { ref: inputRef, className: clsx("input", error.is ? "input--error" : "", className), placeholder: placeholder, ...rest }), error && error.is && jsx("span", { className: "error", children: error.message })] }));
218
+ }, inputRef, styleGroup, placeholder = "Insert value", isRequired, label, labelClass, ...rest }) {
219
+ return (jsxs("div", { className: clsx("input-group", classNameGroup), style: styleGroup, children: [label && jsx("label", { className: labelClass, children: label }), jsx("input", { ref: inputRef, className: clsx("input", error.is ? "input--error" : "", className), placeholder: placeholder, ...rest }), error && error.is && jsx("span", { className: "error", children: error.message })] }));
212
220
  }
213
221
 
214
222
  function Loading({ img, children }) {
@@ -219,7 +227,7 @@ function Modal({ modalref, children, title, subtitle, footer, hasCloseButton = t
219
227
  return (jsxs(Fragment, { children: [jsx("div", { className: "modal-overlay" }), jsxs("div", { ref: modalref, className: "modal", children: [hasCloseButton && (jsx(Button, { mode: "secondary", className: "modal__close", size: "small", onClick: handleClose, children: jsx(IoClose, {}) })), jsxs("div", { className: "modal__content", children: [title && (jsxs("div", { className: "modal__header", children: [jsx("h3", { children: title }), jsx("h6", { children: subtitle })] })), jsx("div", { className: "modal__children", children: children }), footer && jsx("div", { className: "modal__footer", children: footer })] })] })] }));
220
228
  }
221
229
 
222
- function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", ...rest }) {
230
+ function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", label, labelClass, ...rest }) {
223
231
  const ref = useRef();
224
232
  const [isShow, setIsShow] = useState(false);
225
233
  const handleClickToggle = () => {
@@ -233,7 +241,7 @@ function TextArea({ className = "", disabled = true, hasToggleButton = true, hid
233
241
  setIsShow((prev) => !prev);
234
242
  }
235
243
  };
236
- return (jsxs("div", { className: clsx("textarea", className), style: style, children: [jsx("textarea", { ref: ref, className: clsx("textarea__input", textareaClassName), style: {
244
+ return (jsxs("div", { className: clsx("textarea", className), style: style, children: [label && jsx("label", { className: labelClass, children: label }), jsx("textarea", { ref: ref, className: clsx("textarea__input", textareaClassName), style: {
237
245
  height: hasToggleButton ? hideHeight : showHeight,
238
246
  }, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsx("button", { type: "button", className: clsx("textarea__button", isShow && "textarea__button--show"), onClick: handleClickToggle, disabled: disabled, children: jsx(TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
239
247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoinsight/react-components",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "This library is the main UI component library for geoinsight",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",