@geoinsight/react-components 0.5.2 → 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,
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoinsight/react-components",
3
- "version": "0.5.2",
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",