@app-studio/web 0.5.0 → 0.6.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/bot/DocuCode.d.ts +7 -2
- package/dist/bot/prompt/3-comment.d.ts +1 -1
- package/dist/components/Button/Button/Button.props.d.ts +0 -60
- package/dist/components/Button/Button.d.ts +0 -3
- package/dist/components/Form/Checkbox/Checkbox/Checkbox.props.d.ts +1 -68
- package/dist/components/Form/Checkbox/examples/index.d.ts +1 -0
- package/dist/components/Form/Checkbox/examples/infoText.d.ts +2 -0
- package/dist/components/Form/Label/Label/Label.props.d.ts +0 -24
- package/dist/components/Form/Select/Select/Select.props.d.ts +1 -0
- package/dist/components/Form/Select/Select/Select.state.d.ts +2 -0
- package/dist/components/Form/Select/examples/color.d.ts +2 -0
- package/dist/components/Form/Select/examples/index.d.ts +2 -1
- package/dist/components/Form/Select/examples/isScrollable.d.ts +2 -0
- package/dist/web.cjs.development.js +332 -178
- package/dist/web.cjs.development.js.map +1 -1
- package/dist/web.cjs.production.min.js +1 -1
- package/dist/web.cjs.production.min.js.map +1 -1
- package/dist/web.esm.js +332 -178
- package/dist/web.esm.js.map +1 -1
- package/package.json +2 -1
- package/dist/components/Form/Select/examples/Color.d.ts +0 -2
package/dist/web.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef, useMemo, useCallback, createContext, useContext, Fragment } from 'react';
|
|
2
2
|
import { View as View$1, Element, useTheme, Typography, Input, Form, Image } from 'app-studio';
|
|
3
3
|
import { Link as Link$1 } from 'react-router-dom';
|
|
4
|
+
import { Vertical as Vertical$1, Horizontal as Horizontal$1 } from 'src/components/Layout';
|
|
4
5
|
import format from 'date-fns/format';
|
|
5
6
|
import { useFormikContext } from 'formik';
|
|
6
7
|
import { create } from 'zustand';
|
|
@@ -9,11 +10,15 @@ var useButtonState = function useButtonState() {
|
|
|
9
10
|
var _React$useState = React.useState(false),
|
|
10
11
|
isHovered = _React$useState[0],
|
|
11
12
|
setIsHovered = _React$useState[1];
|
|
13
|
+
// This custom react hook 'useButtonState' is defined for managing the state of a button, especially for hover interactions.
|
|
12
14
|
return {
|
|
13
15
|
isHovered: isHovered,
|
|
14
16
|
setIsHovered: setIsHovered
|
|
15
17
|
};
|
|
18
|
+
// The 'setIsHovered' function is used to update the value of 'isHovered' state when the hover status of the button changes.
|
|
19
|
+
// A state variable 'isHovered' is declared with its initial value set to 'false', indicating that the button is not hovered by default.
|
|
16
20
|
};
|
|
21
|
+
// The hook returns an object containing 'isHovered' state and the 'setIsHovered' function to enable state management from the consumer component.
|
|
17
22
|
|
|
18
23
|
function _extends() {
|
|
19
24
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -593,7 +598,9 @@ var LinkComponent = function LinkComponent(props) {
|
|
|
593
598
|
var Link = LinkComponent;
|
|
594
599
|
|
|
595
600
|
var ButtonSizes = {
|
|
601
|
+
// Defines a constant 'ButtonSizes' as a mapping from 'Size' to corresponding 'CSSProperties'.
|
|
596
602
|
xs: {
|
|
603
|
+
// Establishes style configuration for extra-small (xs) button size.
|
|
597
604
|
width: 79,
|
|
598
605
|
paddingTop: 8,
|
|
599
606
|
paddingBottom: 8,
|
|
@@ -612,6 +619,7 @@ var ButtonSizes = {
|
|
|
612
619
|
paddingRight: 16,
|
|
613
620
|
fontWeight: 600,
|
|
614
621
|
fontSize: 'sm',
|
|
622
|
+
// Establishes style configuration for medium (md) button size.
|
|
615
623
|
lineHeight: 20,
|
|
616
624
|
letterSpacing: 1.25
|
|
617
625
|
},
|
|
@@ -621,6 +629,7 @@ var ButtonSizes = {
|
|
|
621
629
|
paddingBottom: 12,
|
|
622
630
|
paddingLeft: 18,
|
|
623
631
|
paddingRight: 18,
|
|
632
|
+
// Establishes style configuration for large (lg) button size.
|
|
624
633
|
fontWeight: 600,
|
|
625
634
|
fontSize: 'md',
|
|
626
635
|
lineHeight: 24,
|
|
@@ -630,6 +639,7 @@ var ButtonSizes = {
|
|
|
630
639
|
width: 178,
|
|
631
640
|
paddingTop: 14,
|
|
632
641
|
paddingBottom: 14,
|
|
642
|
+
// Establishes style configuration for extra-large (xl) button size.
|
|
633
643
|
paddingLeft: 22,
|
|
634
644
|
paddingRight: 22,
|
|
635
645
|
fontWeight: 600,
|
|
@@ -640,28 +650,38 @@ var ButtonSizes = {
|
|
|
640
650
|
xl: {
|
|
641
651
|
width: 220,
|
|
642
652
|
paddingTop: 16,
|
|
653
|
+
// Defines a constant 'ButtonShapes' with style properties for different button shapes such as 'sharp', 'rounded', and 'pillShaped'.
|
|
643
654
|
paddingBottom: 16,
|
|
655
|
+
// Sets the border-radius for a sharp-edged button shape to '0'.
|
|
644
656
|
paddingLeft: 26,
|
|
657
|
+
// Sets the border-radius for a rounded button shape to '4'.
|
|
645
658
|
paddingRight: 26,
|
|
659
|
+
// Sets the border-radius for a pill-shaped button to '24'.
|
|
646
660
|
fontWeight: 600,
|
|
647
661
|
fontSize: 'xl',
|
|
662
|
+
// Defines a constant 'IconSizes' as a mapping from 'Size' to corresponding 'CSSProperties' for icons.
|
|
648
663
|
lineHeight: 24,
|
|
664
|
+
// Sets the width, height, and padding for icons of extra-small size.
|
|
649
665
|
letterSpacing: 1.25
|
|
650
666
|
}
|
|
651
667
|
};
|
|
652
668
|
var ButtonShapes = {
|
|
669
|
+
// Sets the width, height, and padding for icons of small size.
|
|
653
670
|
sharp: 0,
|
|
654
671
|
rounded: 4,
|
|
655
672
|
pillShaped: 24
|
|
656
673
|
};
|
|
674
|
+
// Sets the width, height, and padding for icons of medium size.
|
|
657
675
|
var IconSizes$1 = {
|
|
658
676
|
xs: {
|
|
659
677
|
width: 24,
|
|
660
678
|
height: 24,
|
|
679
|
+
// Sets the width, height, and padding for icons of large size.
|
|
661
680
|
padding: 12
|
|
662
681
|
},
|
|
663
682
|
sm: {
|
|
664
683
|
width: 24,
|
|
684
|
+
// Sets the width, height, and padding for icons of extra-large size.
|
|
665
685
|
height: 24,
|
|
666
686
|
padding: 15
|
|
667
687
|
},
|
|
@@ -932,6 +952,7 @@ var ButtonView = function ButtonView(_ref) {
|
|
|
932
952
|
var reverse = isHovered && effect === 'reverse';
|
|
933
953
|
var ButtonVariants = {
|
|
934
954
|
filled: {
|
|
955
|
+
// Defines CSS properties for 'link' variant of the button with conditional styles based on reverse state, includes text decoration.
|
|
935
956
|
backgroundColor: reverse ? 'transparent' : buttonColor,
|
|
936
957
|
color: reverse ? buttonColor : 'color.white',
|
|
937
958
|
borderWidth: 1,
|
|
@@ -940,15 +961,20 @@ var ButtonView = function ButtonView(_ref) {
|
|
|
940
961
|
},
|
|
941
962
|
outline: {
|
|
942
963
|
backgroundColor: reverse ? buttonColor : 'transparent',
|
|
964
|
+
// Defines CSS properties for 'ghost' variant of the button with conditional styles based on reverse state.
|
|
943
965
|
borderWidth: 1,
|
|
944
966
|
borderStyle: 'solid',
|
|
945
967
|
borderColor: reverse ? buttonColor : colorScheme,
|
|
968
|
+
// Fetches size-specific styles from ButtonSizes based on the 'size' prop.
|
|
946
969
|
color: reverse ? 'white' : buttonColor
|
|
947
970
|
},
|
|
971
|
+
// Adjusts button width based on isAuto and isFilled properties, using buttonSizeStyles for fallback width.
|
|
948
972
|
link: {
|
|
949
973
|
backgroundColor: 'transparent',
|
|
974
|
+
// Changes padding for the button based on whether isIconRounded is true or false.
|
|
950
975
|
borderWidth: 1,
|
|
951
976
|
borderStyle: 'solid',
|
|
977
|
+
// Creates the content for the button including loaders and icons positioned based on their respective properties.
|
|
952
978
|
borderColor: reverse ? buttonColor : 'transparent',
|
|
953
979
|
color: buttonColor,
|
|
954
980
|
textDecoration: reverse ? 'none' : 'underline'
|
|
@@ -961,6 +987,7 @@ var ButtonView = function ButtonView(_ref) {
|
|
|
961
987
|
borderColor: reverse ? buttonColor : 'transparent'
|
|
962
988
|
}
|
|
963
989
|
};
|
|
990
|
+
// Executes rendering of the button or a link element based on the variant; applies conditional rendering for externalHref in 'link' variant.
|
|
964
991
|
var buttonSizeStyles = ButtonSizes[size];
|
|
965
992
|
var buttonVariant = ButtonVariants[variant];
|
|
966
993
|
var scaleWidth = {
|
|
@@ -997,23 +1024,32 @@ var ButtonView = function ButtonView(_ref) {
|
|
|
997
1024
|
}, content) : content);
|
|
998
1025
|
};
|
|
999
1026
|
|
|
1027
|
+
// Importing a custom hook to manage the state specific to the button component.
|
|
1000
1028
|
var ButtonComponent = function ButtonComponent(props) {
|
|
1029
|
+
// Importing the view part of the button, which is presumably a presentational component.
|
|
1001
1030
|
var _useButtonState = useButtonState(),
|
|
1002
1031
|
isHovered = _useButtonState.isHovered,
|
|
1003
1032
|
setIsHovered = _useButtonState.setIsHovered;
|
|
1033
|
+
// Defining the button component with generic React Functional Component type augmented with ButtonProps type.
|
|
1004
1034
|
var handleHover = function handleHover() {
|
|
1005
1035
|
return setIsHovered(!isHovered);
|
|
1006
1036
|
};
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1037
|
+
// Destructuring the state and state update function from the custom hook for button state management.
|
|
1038
|
+
return (
|
|
1039
|
+
// Defines a function to toggle the hover state of the button.
|
|
1040
|
+
React.createElement(ButtonView, Object.assign({
|
|
1041
|
+
isHovered: isHovered,
|
|
1042
|
+
// Rendering the ButtonView component and spreading the received props on it.
|
|
1043
|
+
setIsHovered: setIsHovered,
|
|
1044
|
+
// Passing the isHovered state and the setIsHovered function to the ButtonView.
|
|
1045
|
+
onMouseEnter: handleHover,
|
|
1046
|
+
// Binding handleHover function to onMouseEnter and onMouseLeave events to toggle hover effect.
|
|
1047
|
+
onMouseLeave: handleHover
|
|
1048
|
+
}, props))
|
|
1049
|
+
);
|
|
1050
|
+
// Exports the Button component for use in other parts of the application.
|
|
1013
1051
|
};
|
|
1014
|
-
|
|
1015
|
-
* Buttons allow us to trigger an event or an action with a single click.
|
|
1016
|
-
*/
|
|
1052
|
+
|
|
1017
1053
|
var Button = ButtonComponent;
|
|
1018
1054
|
|
|
1019
1055
|
var useCheckboxState = function useCheckboxState(_ref) {
|
|
@@ -1033,34 +1069,43 @@ var useCheckboxState = function useCheckboxState(_ref) {
|
|
|
1033
1069
|
};
|
|
1034
1070
|
};
|
|
1035
1071
|
|
|
1072
|
+
// Import Headings type definition from Label.type module for type safety and consistency.
|
|
1036
1073
|
var HeadingSizes = {
|
|
1074
|
+
// Initialize a constant 'HeadingSizes' to define styles for different heading levels.
|
|
1037
1075
|
h1: {
|
|
1076
|
+
// Use TypeScript's 'Record' utility type to ensure the object matches the shape of 'Headings'.
|
|
1038
1077
|
fontSize: 96,
|
|
1078
|
+
// Define style properties for 'h1' heading tag, including font size, line height, and letter spacing.
|
|
1039
1079
|
lineHeight: 112,
|
|
1040
1080
|
letterSpacing: -1.5
|
|
1041
1081
|
},
|
|
1042
1082
|
h2: {
|
|
1043
1083
|
fontSize: 60,
|
|
1084
|
+
// Define style properties for 'h2' heading tag similar to 'h1', but with adjusted values for size and spacing.
|
|
1044
1085
|
lineHeight: 71,
|
|
1045
1086
|
letterSpacing: -0.5
|
|
1046
1087
|
},
|
|
1047
1088
|
h3: {
|
|
1048
1089
|
fontSize: 48,
|
|
1090
|
+
// Define style properties for 'h3' heading tag with a standard letter spacing of 0.
|
|
1049
1091
|
lineHeight: 57,
|
|
1050
1092
|
letterSpacing: 0
|
|
1051
1093
|
},
|
|
1052
1094
|
h4: {
|
|
1053
1095
|
fontSize: 34,
|
|
1096
|
+
// Provide style properties for 'h4' heading tag, with a slight increase in letter spacing.
|
|
1054
1097
|
lineHeight: 40,
|
|
1055
1098
|
letterSpacing: 0.25
|
|
1056
1099
|
},
|
|
1057
1100
|
h5: {
|
|
1058
1101
|
fontSize: 24,
|
|
1102
|
+
// Set the 'h5' heading tag styles, opting for no additional letter spacing.
|
|
1059
1103
|
lineHeight: 28,
|
|
1060
1104
|
letterSpacing: 0
|
|
1061
1105
|
},
|
|
1062
1106
|
h6: {
|
|
1063
1107
|
fontSize: 20,
|
|
1108
|
+
// Set the 'h6' heading tag styles, with the smallest font size and a subtle letter spacing.
|
|
1064
1109
|
lineHeight: 24,
|
|
1065
1110
|
letterSpacing: 0.15
|
|
1066
1111
|
}
|
|
@@ -1081,21 +1126,36 @@ var LabelView = function LabelView(_ref) {
|
|
|
1081
1126
|
_ref$size = _ref.size,
|
|
1082
1127
|
size = _ref$size === void 0 ? 'sm' : _ref$size,
|
|
1083
1128
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$h);
|
|
1129
|
+
// The fontStyle prop toggles between 'italic' and 'normal' based on the 'isItalic' boolean prop.
|
|
1084
1130
|
var headingStyles = heading ? HeadingSizes[heading] : {};
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1131
|
+
// fontWeight is derived from the Typography module, ensuring consistent font weighting across the app.
|
|
1132
|
+
return (
|
|
1133
|
+
// textDecoration conditionally applies 'line-through' or 'underline' based on respective boolean props; defaults to 'none' if both are false.
|
|
1134
|
+
React.createElement(Element, Object.assign({
|
|
1135
|
+
as: "label",
|
|
1136
|
+
// Spreads any additional style properties from headingStyles into the Element if a heading size is specified.
|
|
1137
|
+
width: "100%",
|
|
1138
|
+
// Spreads the rest of the props to support extensibility of the LabelView component for future use cases.
|
|
1139
|
+
fontSize: size,
|
|
1140
|
+
// Includes children elements inside the Element, allowing for nested content within the label.
|
|
1141
|
+
fontStyle: isItalic ? 'italic' : 'normal',
|
|
1142
|
+
fontWeight: Typography.fontWeights[weight],
|
|
1143
|
+
textDecoration: isStriked ? 'line-through' : isUnderlined ? 'underline' : 'none'
|
|
1144
|
+
}, headingStyles, props), children)
|
|
1145
|
+
);
|
|
1093
1146
|
};
|
|
1094
1147
|
|
|
1148
|
+
// Import custom type 'LabelProps' to type check the properties passed into the Label component.
|
|
1095
1149
|
var LabelComponent = function LabelComponent(props) {
|
|
1096
|
-
return
|
|
1150
|
+
return (
|
|
1151
|
+
// Import 'LabelView' as a visual component for the label, separating the view from business logic.
|
|
1152
|
+
React.createElement(LabelView, Object.assign({}, props))
|
|
1153
|
+
// Define 'LabelComponent' as a functional component that uses React's FC type for type checking and utilizing React features.
|
|
1154
|
+
);
|
|
1097
1155
|
};
|
|
1156
|
+
// Pass all properties received by 'LabelComponent' to 'LabelView' using the spread syntax, ensuring it has all props needed for rendering.
|
|
1098
1157
|
var Label = LabelComponent;
|
|
1158
|
+
// Export the 'LabelComponent' as 'Label' to be reused throughout the project.
|
|
1099
1159
|
|
|
1100
1160
|
var Sizes = {
|
|
1101
1161
|
xs: {
|
|
@@ -1152,7 +1212,134 @@ var IconSizes$2 = {
|
|
|
1152
1212
|
'6xl': 60
|
|
1153
1213
|
};
|
|
1154
1214
|
|
|
1155
|
-
var
|
|
1215
|
+
var HeadingSizes$1 = {
|
|
1216
|
+
h1: {
|
|
1217
|
+
fontSize: 96,
|
|
1218
|
+
lineHeight: 112,
|
|
1219
|
+
letterSpacing: -1.5
|
|
1220
|
+
},
|
|
1221
|
+
h2: {
|
|
1222
|
+
fontSize: 60,
|
|
1223
|
+
lineHeight: 71,
|
|
1224
|
+
letterSpacing: -0.5
|
|
1225
|
+
},
|
|
1226
|
+
h3: {
|
|
1227
|
+
fontSize: 48,
|
|
1228
|
+
lineHeight: 57,
|
|
1229
|
+
letterSpacing: 0
|
|
1230
|
+
},
|
|
1231
|
+
h4: {
|
|
1232
|
+
fontSize: 34,
|
|
1233
|
+
lineHeight: 40,
|
|
1234
|
+
letterSpacing: 0.25
|
|
1235
|
+
},
|
|
1236
|
+
h5: {
|
|
1237
|
+
fontSize: 24,
|
|
1238
|
+
lineHeight: 28,
|
|
1239
|
+
letterSpacing: 0
|
|
1240
|
+
},
|
|
1241
|
+
h6: {
|
|
1242
|
+
fontSize: 20,
|
|
1243
|
+
lineHeight: 24,
|
|
1244
|
+
letterSpacing: 0.15
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
var _excluded$i = ["children", "heading", "maxLines", "isItalic", "isUnderlined", "isSub", "isSup", "isStriked", "isTruncated", "weight", "size"];
|
|
1249
|
+
var TextContent = function TextContent(_ref) {
|
|
1250
|
+
var children = _ref.children,
|
|
1251
|
+
isSub = _ref.isSub,
|
|
1252
|
+
isSup = _ref.isSup;
|
|
1253
|
+
return React.createElement(React.Fragment, null, typeof children === 'string' ? React.createElement(React.Fragment, null, isSub && React.createElement("sup", null, children), isSup && React.createElement("sup", null, children), !isSub && !isSup && React.createElement(React.Fragment, null, children)) : children);
|
|
1254
|
+
};
|
|
1255
|
+
var TruncateText = function TruncateText(_ref2) {
|
|
1256
|
+
var text = _ref2.text,
|
|
1257
|
+
_ref2$maxLines = _ref2.maxLines,
|
|
1258
|
+
maxLines = _ref2$maxLines === void 0 ? 1 : _ref2$maxLines;
|
|
1259
|
+
var containerRef = useRef(null);
|
|
1260
|
+
var _useState = useState(text.length),
|
|
1261
|
+
truncatedLength = _useState[0],
|
|
1262
|
+
setTruncatedLength = _useState[1];
|
|
1263
|
+
useEffect(function () {
|
|
1264
|
+
var textNode = containerRef.current;
|
|
1265
|
+
if (!textNode) return;
|
|
1266
|
+
var updateTruncatedText = function updateTruncatedText() {
|
|
1267
|
+
var comLineHeight = getComputedStyle(textNode).lineHeight;
|
|
1268
|
+
var lineHeight = comLineHeight !== 'normal' ? parseFloat(comLineHeight) : 20;
|
|
1269
|
+
var maxHeight = lineHeight * maxLines;
|
|
1270
|
+
var start = 0;
|
|
1271
|
+
var end = text.length;
|
|
1272
|
+
var middle;
|
|
1273
|
+
while (start <= end) {
|
|
1274
|
+
middle = Math.floor((start + end) / 2);
|
|
1275
|
+
textNode.innerText = text.substring(0, middle) + '...';
|
|
1276
|
+
var currentHeight = textNode.offsetHeight;
|
|
1277
|
+
if (currentHeight > maxHeight) {
|
|
1278
|
+
end = middle - 1;
|
|
1279
|
+
} else {
|
|
1280
|
+
start = middle + 1;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
setTruncatedLength(end);
|
|
1284
|
+
};
|
|
1285
|
+
updateTruncatedText();
|
|
1286
|
+
}, [text, maxLines]);
|
|
1287
|
+
var displayText = text.length > truncatedLength ? text.substring(0, truncatedLength) + '...' : text;
|
|
1288
|
+
return React.createElement("div", {
|
|
1289
|
+
ref: containerRef
|
|
1290
|
+
}, displayText);
|
|
1291
|
+
};
|
|
1292
|
+
var TextView = function TextView(_ref3) {
|
|
1293
|
+
var children = _ref3.children,
|
|
1294
|
+
heading = _ref3.heading,
|
|
1295
|
+
maxLines = _ref3.maxLines,
|
|
1296
|
+
_ref3$isItalic = _ref3.isItalic,
|
|
1297
|
+
isItalic = _ref3$isItalic === void 0 ? false : _ref3$isItalic,
|
|
1298
|
+
_ref3$isUnderlined = _ref3.isUnderlined,
|
|
1299
|
+
isUnderlined = _ref3$isUnderlined === void 0 ? false : _ref3$isUnderlined,
|
|
1300
|
+
_ref3$isSub = _ref3.isSub,
|
|
1301
|
+
isSub = _ref3$isSub === void 0 ? false : _ref3$isSub,
|
|
1302
|
+
_ref3$isSup = _ref3.isSup,
|
|
1303
|
+
isSup = _ref3$isSup === void 0 ? false : _ref3$isSup,
|
|
1304
|
+
_ref3$isStriked = _ref3.isStriked,
|
|
1305
|
+
isStriked = _ref3$isStriked === void 0 ? false : _ref3$isStriked,
|
|
1306
|
+
_ref3$isTruncated = _ref3.isTruncated,
|
|
1307
|
+
isTruncated = _ref3$isTruncated === void 0 ? false : _ref3$isTruncated,
|
|
1308
|
+
_ref3$weight = _ref3.weight,
|
|
1309
|
+
weight = _ref3$weight === void 0 ? 'normal' : _ref3$weight,
|
|
1310
|
+
_ref3$size = _ref3.size,
|
|
1311
|
+
size = _ref3$size === void 0 ? 'md' : _ref3$size,
|
|
1312
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded$i);
|
|
1313
|
+
var headingStyles = heading ? HeadingSizes$1[heading] : {};
|
|
1314
|
+
var noLineBreak = isSub || isSup ? {
|
|
1315
|
+
display: 'inline'
|
|
1316
|
+
} : {};
|
|
1317
|
+
var fontSize = Typography.fontSizes[size];
|
|
1318
|
+
return React.createElement(Element, Object.assign({
|
|
1319
|
+
role: "text",
|
|
1320
|
+
fontSize: fontSize,
|
|
1321
|
+
lineHeight: Typography.lineHeights[size],
|
|
1322
|
+
fontStyle: isItalic ? 'italic' : 'normal',
|
|
1323
|
+
fontWeight: Typography.fontWeights[weight],
|
|
1324
|
+
textDecoration: isStriked ? 'line-through' : isUnderlined ? 'underline' : 'none'
|
|
1325
|
+
}, noLineBreak, headingStyles, props), isTruncated && maxLines && typeof children === 'string' ? React.createElement(TruncateText, {
|
|
1326
|
+
text: children,
|
|
1327
|
+
maxLines: maxLines
|
|
1328
|
+
}) : React.createElement(TextContent, Object.assign({
|
|
1329
|
+
isSub: isSub,
|
|
1330
|
+
isSup: isSup
|
|
1331
|
+
}, props), children));
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
var TextComponent = function TextComponent(props) {
|
|
1335
|
+
return React.createElement(TextView, Object.assign({}, props));
|
|
1336
|
+
};
|
|
1337
|
+
/**
|
|
1338
|
+
* The Text component is a simple component that renders a text string or paragraphs as a DOM element in the UI. It is a <p> tag by default.
|
|
1339
|
+
*/
|
|
1340
|
+
var Text = TextComponent;
|
|
1341
|
+
|
|
1342
|
+
var _excluded$j = ["id", "icon", "name", "label", "isChecked", "onChange", "onValueChange", "shadow", "labelPosition", "size", "colorScheme", "error", "isSelected", "isHovered", "isDisabled", "isReadOnly", "isIndeterminate", "defaultIsSelected", "setIsSelected", "setIsHovered", "styles", "infoText"];
|
|
1156
1343
|
var CheckboxView = function CheckboxView(_ref) {
|
|
1157
1344
|
var id = _ref.id,
|
|
1158
1345
|
icon = _ref.icon,
|
|
@@ -1189,7 +1376,8 @@ var CheckboxView = function CheckboxView(_ref) {
|
|
|
1189
1376
|
checkbox: {},
|
|
1190
1377
|
label: {}
|
|
1191
1378
|
} : _ref$styles,
|
|
1192
|
-
|
|
1379
|
+
infoText = _ref.infoText,
|
|
1380
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
|
|
1193
1381
|
var handleHover = function handleHover() {
|
|
1194
1382
|
return setIsHovered(!isHovered);
|
|
1195
1383
|
};
|
|
@@ -1230,9 +1418,22 @@ var CheckboxView = function CheckboxView(_ref) {
|
|
|
1230
1418
|
onMouseEnter: handleHover,
|
|
1231
1419
|
onMouseLeave: handleHover,
|
|
1232
1420
|
size: Typography.fontSizes[size]
|
|
1233
|
-
}, checkboxStyle.container, props),
|
|
1421
|
+
}, checkboxStyle.container, props), React.createElement(Vertical$1, {
|
|
1422
|
+
gap: 8
|
|
1423
|
+
}, React.createElement(Horizontal$1, {
|
|
1424
|
+
gap: 10,
|
|
1425
|
+
alignItems: "center"
|
|
1426
|
+
}, labelPosition === 'left' && label && React.createElement(Text, Object.assign({
|
|
1427
|
+
size: size
|
|
1428
|
+
}, styles == null ? void 0 : styles.label), label), React.createElement(Center, Object.assign({}, checkboxStyle.checkbox), isIndeterminate ? React.createElement(IndeterminateSvg, null) : (isChecked || isSelected) && (icon != null ? icon : React.createElement(CheckSvg, {
|
|
1234
1429
|
size: IconSizes$2[size]
|
|
1235
|
-
}))), labelPosition === 'right' && label && React.createElement(
|
|
1430
|
+
}))), labelPosition === 'right' && label && React.createElement(Text, Object.assign({
|
|
1431
|
+
size: size
|
|
1432
|
+
}, styles == null ? void 0 : styles.label), label)), infoText && React.createElement(Text, Object.assign({
|
|
1433
|
+
marginLeft: labelPosition === 'left' ? 0 : 27,
|
|
1434
|
+
color: "color.gray.400",
|
|
1435
|
+
size: "sm"
|
|
1436
|
+
}, styles == null ? void 0 : styles.infoText), infoText)));
|
|
1236
1437
|
};
|
|
1237
1438
|
|
|
1238
1439
|
var CheckboxComponent = function CheckboxComponent(props) {
|
|
@@ -2730,133 +2931,6 @@ var useCountryPickerState = function useCountryPickerState(_ref) {
|
|
|
2730
2931
|
};
|
|
2731
2932
|
};
|
|
2732
2933
|
|
|
2733
|
-
var HeadingSizes$1 = {
|
|
2734
|
-
h1: {
|
|
2735
|
-
fontSize: 96,
|
|
2736
|
-
lineHeight: 112,
|
|
2737
|
-
letterSpacing: -1.5
|
|
2738
|
-
},
|
|
2739
|
-
h2: {
|
|
2740
|
-
fontSize: 60,
|
|
2741
|
-
lineHeight: 71,
|
|
2742
|
-
letterSpacing: -0.5
|
|
2743
|
-
},
|
|
2744
|
-
h3: {
|
|
2745
|
-
fontSize: 48,
|
|
2746
|
-
lineHeight: 57,
|
|
2747
|
-
letterSpacing: 0
|
|
2748
|
-
},
|
|
2749
|
-
h4: {
|
|
2750
|
-
fontSize: 34,
|
|
2751
|
-
lineHeight: 40,
|
|
2752
|
-
letterSpacing: 0.25
|
|
2753
|
-
},
|
|
2754
|
-
h5: {
|
|
2755
|
-
fontSize: 24,
|
|
2756
|
-
lineHeight: 28,
|
|
2757
|
-
letterSpacing: 0
|
|
2758
|
-
},
|
|
2759
|
-
h6: {
|
|
2760
|
-
fontSize: 20,
|
|
2761
|
-
lineHeight: 24,
|
|
2762
|
-
letterSpacing: 0.15
|
|
2763
|
-
}
|
|
2764
|
-
};
|
|
2765
|
-
|
|
2766
|
-
var _excluded$j = ["children", "heading", "maxLines", "isItalic", "isUnderlined", "isSub", "isSup", "isStriked", "isTruncated", "weight", "size"];
|
|
2767
|
-
var TextContent = function TextContent(_ref) {
|
|
2768
|
-
var children = _ref.children,
|
|
2769
|
-
isSub = _ref.isSub,
|
|
2770
|
-
isSup = _ref.isSup;
|
|
2771
|
-
return React.createElement(React.Fragment, null, typeof children === 'string' ? React.createElement(React.Fragment, null, isSub && React.createElement("sup", null, children), isSup && React.createElement("sup", null, children), !isSub && !isSup && React.createElement(React.Fragment, null, children)) : children);
|
|
2772
|
-
};
|
|
2773
|
-
var TruncateText = function TruncateText(_ref2) {
|
|
2774
|
-
var text = _ref2.text,
|
|
2775
|
-
_ref2$maxLines = _ref2.maxLines,
|
|
2776
|
-
maxLines = _ref2$maxLines === void 0 ? 1 : _ref2$maxLines;
|
|
2777
|
-
var containerRef = useRef(null);
|
|
2778
|
-
var _useState = useState(text.length),
|
|
2779
|
-
truncatedLength = _useState[0],
|
|
2780
|
-
setTruncatedLength = _useState[1];
|
|
2781
|
-
useEffect(function () {
|
|
2782
|
-
var textNode = containerRef.current;
|
|
2783
|
-
if (!textNode) return;
|
|
2784
|
-
var updateTruncatedText = function updateTruncatedText() {
|
|
2785
|
-
var comLineHeight = getComputedStyle(textNode).lineHeight;
|
|
2786
|
-
var lineHeight = comLineHeight !== 'normal' ? parseFloat(comLineHeight) : 20;
|
|
2787
|
-
var maxHeight = lineHeight * maxLines;
|
|
2788
|
-
var start = 0;
|
|
2789
|
-
var end = text.length;
|
|
2790
|
-
var middle;
|
|
2791
|
-
while (start <= end) {
|
|
2792
|
-
middle = Math.floor((start + end) / 2);
|
|
2793
|
-
textNode.innerText = text.substring(0, middle) + '...';
|
|
2794
|
-
var currentHeight = textNode.offsetHeight;
|
|
2795
|
-
if (currentHeight > maxHeight) {
|
|
2796
|
-
end = middle - 1;
|
|
2797
|
-
} else {
|
|
2798
|
-
start = middle + 1;
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2801
|
-
setTruncatedLength(end);
|
|
2802
|
-
};
|
|
2803
|
-
updateTruncatedText();
|
|
2804
|
-
}, [text, maxLines]);
|
|
2805
|
-
var displayText = text.length > truncatedLength ? text.substring(0, truncatedLength) + '...' : text;
|
|
2806
|
-
return React.createElement("div", {
|
|
2807
|
-
ref: containerRef
|
|
2808
|
-
}, displayText);
|
|
2809
|
-
};
|
|
2810
|
-
var TextView = function TextView(_ref3) {
|
|
2811
|
-
var children = _ref3.children,
|
|
2812
|
-
heading = _ref3.heading,
|
|
2813
|
-
maxLines = _ref3.maxLines,
|
|
2814
|
-
_ref3$isItalic = _ref3.isItalic,
|
|
2815
|
-
isItalic = _ref3$isItalic === void 0 ? false : _ref3$isItalic,
|
|
2816
|
-
_ref3$isUnderlined = _ref3.isUnderlined,
|
|
2817
|
-
isUnderlined = _ref3$isUnderlined === void 0 ? false : _ref3$isUnderlined,
|
|
2818
|
-
_ref3$isSub = _ref3.isSub,
|
|
2819
|
-
isSub = _ref3$isSub === void 0 ? false : _ref3$isSub,
|
|
2820
|
-
_ref3$isSup = _ref3.isSup,
|
|
2821
|
-
isSup = _ref3$isSup === void 0 ? false : _ref3$isSup,
|
|
2822
|
-
_ref3$isStriked = _ref3.isStriked,
|
|
2823
|
-
isStriked = _ref3$isStriked === void 0 ? false : _ref3$isStriked,
|
|
2824
|
-
_ref3$isTruncated = _ref3.isTruncated,
|
|
2825
|
-
isTruncated = _ref3$isTruncated === void 0 ? false : _ref3$isTruncated,
|
|
2826
|
-
_ref3$weight = _ref3.weight,
|
|
2827
|
-
weight = _ref3$weight === void 0 ? 'normal' : _ref3$weight,
|
|
2828
|
-
_ref3$size = _ref3.size,
|
|
2829
|
-
size = _ref3$size === void 0 ? 'md' : _ref3$size,
|
|
2830
|
-
props = _objectWithoutPropertiesLoose(_ref3, _excluded$j);
|
|
2831
|
-
var headingStyles = heading ? HeadingSizes$1[heading] : {};
|
|
2832
|
-
var noLineBreak = isSub || isSup ? {
|
|
2833
|
-
display: 'inline'
|
|
2834
|
-
} : {};
|
|
2835
|
-
var fontSize = Typography.fontSizes[size];
|
|
2836
|
-
return React.createElement(Element, Object.assign({
|
|
2837
|
-
role: "text",
|
|
2838
|
-
fontSize: fontSize,
|
|
2839
|
-
lineHeight: Typography.lineHeights[size],
|
|
2840
|
-
fontStyle: isItalic ? 'italic' : 'normal',
|
|
2841
|
-
fontWeight: Typography.fontWeights[weight],
|
|
2842
|
-
textDecoration: isStriked ? 'line-through' : isUnderlined ? 'underline' : 'none'
|
|
2843
|
-
}, noLineBreak, headingStyles, props), isTruncated && maxLines && typeof children === 'string' ? React.createElement(TruncateText, {
|
|
2844
|
-
text: children,
|
|
2845
|
-
maxLines: maxLines
|
|
2846
|
-
}) : React.createElement(TextContent, Object.assign({
|
|
2847
|
-
isSub: isSub,
|
|
2848
|
-
isSup: isSup
|
|
2849
|
-
}, props), children));
|
|
2850
|
-
};
|
|
2851
|
-
|
|
2852
|
-
var TextComponent = function TextComponent(props) {
|
|
2853
|
-
return React.createElement(TextView, Object.assign({}, props));
|
|
2854
|
-
};
|
|
2855
|
-
/**
|
|
2856
|
-
* The Text component is a simple component that renders a text string or paragraphs as a DOM element in the UI. It is a <p> tag by default.
|
|
2857
|
-
*/
|
|
2858
|
-
var Text = TextComponent;
|
|
2859
|
-
|
|
2860
2934
|
var _excluded$k = ["children", "styles"];
|
|
2861
2935
|
var HelperText = function HelperText(_ref) {
|
|
2862
2936
|
var children = _ref.children,
|
|
@@ -3737,6 +3811,9 @@ var useSelectState = function useSelectState(_ref) {
|
|
|
3737
3811
|
var _React$useState4 = React.useState(defaultValue),
|
|
3738
3812
|
value = _React$useState4[0],
|
|
3739
3813
|
setValue = _React$useState4[1];
|
|
3814
|
+
var _React$useState5 = React.useState(0),
|
|
3815
|
+
highlightedIndex = _React$useState5[0],
|
|
3816
|
+
setHighlightedIndex = _React$useState5[1];
|
|
3740
3817
|
return {
|
|
3741
3818
|
value: value,
|
|
3742
3819
|
setValue: setValue,
|
|
@@ -3745,13 +3822,15 @@ var useSelectState = function useSelectState(_ref) {
|
|
|
3745
3822
|
isHovered: isHovered,
|
|
3746
3823
|
setIsHovered: setIsHovered,
|
|
3747
3824
|
isFocused: isFocused,
|
|
3748
|
-
setIsFocused: setIsFocused
|
|
3825
|
+
setIsFocused: setIsFocused,
|
|
3826
|
+
highlightedIndex: highlightedIndex,
|
|
3827
|
+
setHighlightedIndex: setHighlightedIndex
|
|
3749
3828
|
};
|
|
3750
3829
|
};
|
|
3751
3830
|
var useItemState = function useItemState() {
|
|
3752
|
-
var _React$
|
|
3753
|
-
isHovered = _React$
|
|
3754
|
-
setIsHovered = _React$
|
|
3831
|
+
var _React$useState6 = React.useState(false),
|
|
3832
|
+
isHovered = _React$useState6[0],
|
|
3833
|
+
setIsHovered = _React$useState6[1];
|
|
3755
3834
|
return {
|
|
3756
3835
|
isHovered: isHovered,
|
|
3757
3836
|
setIsHovered: setIsHovered
|
|
@@ -3769,7 +3848,7 @@ var IconSizes$4 = {
|
|
|
3769
3848
|
var _excluded$v = ["isHovered", "setIsHovered", "option", "size", "callback"],
|
|
3770
3849
|
_excluded2$2 = ["id", "name", "value", "onChange", "isMulti", "isDisabled", "isReadOnly", "options"],
|
|
3771
3850
|
_excluded3$1 = ["option", "size", "removeOption"],
|
|
3772
|
-
_excluded4$1 = ["id", "name", "label", "value", "placeholder", "helperText", "hide", "error", "isMulti", "isFocused", "isHovered", "isDisabled", "isReadOnly", "options", "shadow", "size", "colorScheme", "shape", "variant", "styles", "onChange", "setHide", "setValue", "setIsHovered", "setIsFocused"];
|
|
3851
|
+
_excluded4$1 = ["id", "name", "label", "value", "placeholder", "helperText", "hide", "error", "isMulti", "isFocused", "isHovered", "isDisabled", "isReadOnly", "options", "shadow", "size", "colorScheme", "shape", "variant", "styles", "onChange", "setHide", "setValue", "setIsHovered", "setIsFocused", "setHighlightedIndex", "highlightedIndex"];
|
|
3773
3852
|
var Item = function Item(_ref) {
|
|
3774
3853
|
var isHovered = _ref.isHovered,
|
|
3775
3854
|
setIsHovered = _ref.setIsHovered,
|
|
@@ -3785,11 +3864,10 @@ var Item = function Item(_ref) {
|
|
|
3785
3864
|
var handleHover = function handleHover() {
|
|
3786
3865
|
return setIsHovered(!isHovered);
|
|
3787
3866
|
};
|
|
3788
|
-
console.log(props.name);
|
|
3789
3867
|
return React.createElement(Element, Object.assign({
|
|
3790
3868
|
as: "li",
|
|
3791
3869
|
margin: 0,
|
|
3792
|
-
paddingVertical:
|
|
3870
|
+
paddingVertical: 10,
|
|
3793
3871
|
paddingHorizontal: 12,
|
|
3794
3872
|
listStyleType: "none",
|
|
3795
3873
|
onMouseEnter: handleHover,
|
|
@@ -3799,7 +3877,7 @@ var Item = function Item(_ref) {
|
|
|
3799
3877
|
return handleOptionClick(option);
|
|
3800
3878
|
},
|
|
3801
3879
|
backgroundColor: isHovered ? 'trueGray.100' : 'transparent'
|
|
3802
|
-
}, props), option);
|
|
3880
|
+
}, props), React.createElement(Text, null, " ", option));
|
|
3803
3881
|
};
|
|
3804
3882
|
var SelectBox = function SelectBox(_ref2) {
|
|
3805
3883
|
var _ref2$size = _ref2.size,
|
|
@@ -3881,7 +3959,9 @@ var DropDown$1 = function DropDown(_ref4) {
|
|
|
3881
3959
|
} : _ref4$styles,
|
|
3882
3960
|
options = _ref4.options,
|
|
3883
3961
|
_ref4$callback = _ref4.callback,
|
|
3884
|
-
callback = _ref4$callback === void 0 ? function () {} : _ref4$callback
|
|
3962
|
+
callback = _ref4$callback === void 0 ? function () {} : _ref4$callback,
|
|
3963
|
+
highlightedIndex = _ref4.highlightedIndex,
|
|
3964
|
+
setHighlightedIndex = _ref4.setHighlightedIndex;
|
|
3885
3965
|
var itemStates = useItemState();
|
|
3886
3966
|
var handleCallback = function handleCallback(option) {
|
|
3887
3967
|
return callback(option);
|
|
@@ -3905,7 +3985,7 @@ var DropDown$1 = function DropDown(_ref4) {
|
|
|
3905
3985
|
width: "100%",
|
|
3906
3986
|
display: "flex",
|
|
3907
3987
|
zIndex: 1000,
|
|
3908
|
-
overflowY: "
|
|
3988
|
+
overflowY: "scroll",
|
|
3909
3989
|
marginTop: 5,
|
|
3910
3990
|
marginLeft: 0,
|
|
3911
3991
|
marginRight: 0,
|
|
@@ -3915,13 +3995,24 @@ var DropDown$1 = function DropDown(_ref4) {
|
|
|
3915
3995
|
position: "absolute",
|
|
3916
3996
|
flexDirection: "column",
|
|
3917
3997
|
backgroundColor: "white",
|
|
3918
|
-
|
|
3919
|
-
|
|
3998
|
+
maxHeight: "200px",
|
|
3999
|
+
style: {
|
|
4000
|
+
scrollbarWidth: 'none' /* For Firefox */,
|
|
4001
|
+
msOverflowStyle: 'none' /* For Internet Explorer and Edge */,
|
|
4002
|
+
'&::-webkit-scrollbar': {
|
|
4003
|
+
display: 'none' /* For Chrome, Safari, and Opera */
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
}, shadow, styles['dropDown']), options.map(function (option, index) {
|
|
3920
4007
|
return React.createElement(Item, Object.assign({
|
|
3921
4008
|
key: option,
|
|
3922
4009
|
size: size,
|
|
3923
4010
|
option: option,
|
|
3924
|
-
callback: handleCallback
|
|
4011
|
+
callback: handleCallback,
|
|
4012
|
+
backgroundColor: index === highlightedIndex ? 'color.gray.100' : 'transparent',
|
|
4013
|
+
onMouseEnter: function onMouseEnter() {
|
|
4014
|
+
return setHighlightedIndex(index);
|
|
4015
|
+
}
|
|
3925
4016
|
}, itemStates, styles['text']));
|
|
3926
4017
|
}));
|
|
3927
4018
|
};
|
|
@@ -4006,6 +4097,8 @@ var SelectView = function SelectView(_ref6) {
|
|
|
4006
4097
|
setIsHovered = _ref6$setIsHovered === void 0 ? function () {} : _ref6$setIsHovered,
|
|
4007
4098
|
_ref6$setIsFocused = _ref6.setIsFocused,
|
|
4008
4099
|
setIsFocused = _ref6$setIsFocused === void 0 ? function () {} : _ref6$setIsFocused,
|
|
4100
|
+
setHighlightedIndex = _ref6.setHighlightedIndex,
|
|
4101
|
+
highlightedIndex = _ref6.highlightedIndex,
|
|
4009
4102
|
props = _objectWithoutPropertiesLoose(_ref6, _excluded4$1);
|
|
4010
4103
|
var isWithLabel = !!(isFocused && label);
|
|
4011
4104
|
var handleHover = function handleHover() {
|
|
@@ -4093,7 +4186,9 @@ var SelectView = function SelectView(_ref6) {
|
|
|
4093
4186
|
size: size,
|
|
4094
4187
|
styles: styles,
|
|
4095
4188
|
options: options,
|
|
4096
|
-
callback: handleCallback
|
|
4189
|
+
callback: handleCallback,
|
|
4190
|
+
highlightedIndex: highlightedIndex,
|
|
4191
|
+
setHighlightedIndex: setHighlightedIndex
|
|
4097
4192
|
}));
|
|
4098
4193
|
};
|
|
4099
4194
|
|
|
@@ -4783,27 +4878,32 @@ var PasswordComponent$1 = function PasswordComponent(_ref) {
|
|
|
4783
4878
|
*/
|
|
4784
4879
|
var FormikPassword = PasswordComponent$1;
|
|
4785
4880
|
|
|
4786
|
-
//
|
|
4787
|
-
// Define the useComboBoxState hook properly with types
|
|
4881
|
+
// Defines the useComboBoxState hook with parameters for the list of items and optional placeholder texts.
|
|
4788
4882
|
var useComboBoxState = function useComboBoxState(items, placeholder, searchPlaceholder) {
|
|
4883
|
+
// State hook for filtered items with initial state set to the items passed to the hook.
|
|
4789
4884
|
var _useState = useState(items),
|
|
4790
4885
|
filteredItems = _useState[0],
|
|
4791
4886
|
setFilteredItems = _useState[1];
|
|
4887
|
+
// State hook to track the selected item with an initial state based on the placeholder or the first item.
|
|
4792
4888
|
var _useState2 = useState(placeholder ? {
|
|
4793
4889
|
value: placeholder,
|
|
4794
4890
|
label: placeholder
|
|
4795
4891
|
} : items[0]),
|
|
4796
4892
|
selectedItem = _useState2[0],
|
|
4797
4893
|
setSelectedItem = _useState2[1];
|
|
4894
|
+
// State hook for highlighted index in the dropdown list, initialized to 0.
|
|
4798
4895
|
var _useState3 = useState(0),
|
|
4799
4896
|
highlightedIndex = _useState3[0],
|
|
4800
4897
|
setHighlightedIndex = _useState3[1];
|
|
4898
|
+
// State hook for search query with an initial state based on the searchPlaceholder or empty string.
|
|
4801
4899
|
var _useState4 = useState(searchPlaceholder != null ? searchPlaceholder : ''),
|
|
4802
4900
|
searchQuery = _useState4[0],
|
|
4803
4901
|
setSearchQuery = _useState4[1];
|
|
4902
|
+
// State hook to manage dropdown visibility, starts as false (hidden).
|
|
4804
4903
|
var _useState5 = useState(false),
|
|
4805
4904
|
isDropdownVisible = _useState5[0],
|
|
4806
4905
|
setIsDropdownVisible = _useState5[1];
|
|
4906
|
+
// Start of object returned by the useComboBoxState hook containing all state and state updater functions.
|
|
4807
4907
|
return {
|
|
4808
4908
|
filteredItems: filteredItems,
|
|
4809
4909
|
setFilteredItems: setFilteredItems,
|
|
@@ -4884,6 +4984,7 @@ var SearchLoopSvg = function SearchLoopSvg(_ref) {
|
|
|
4884
4984
|
};
|
|
4885
4985
|
|
|
4886
4986
|
var _excluded$E = ["placeholder", "items", "showTick", "onSelect", "searchEnabled", "left", "right", "label", "filteredItems", "setSelectedItem", "selectedItem", "highlightedIndex", "setHighlightedIndex", "searchQuery", "setSearchQuery", "setFilteredItems", "styles", "isDropdownVisible", "setIsDropdownVisible"];
|
|
4987
|
+
// Defines the functional component 'ComboBoxView' with destructured props.
|
|
4887
4988
|
var ComboBoxView = function ComboBoxView(_ref) {
|
|
4888
4989
|
var placeholder = _ref.placeholder,
|
|
4889
4990
|
items = _ref.items,
|
|
@@ -4907,6 +5008,7 @@ var ComboBoxView = function ComboBoxView(_ref) {
|
|
|
4907
5008
|
isDropdownVisible = _ref.isDropdownVisible,
|
|
4908
5009
|
setIsDropdownVisible = _ref.setIsDropdownVisible,
|
|
4909
5010
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$E);
|
|
5011
|
+
// Sets up an effect to handle clicking outside the dropdown to close it.
|
|
4910
5012
|
useEffect(function () {
|
|
4911
5013
|
var handleClickOutside = function handleClickOutside(event) {
|
|
4912
5014
|
var path = event.composedPath();
|
|
@@ -4922,6 +5024,7 @@ var ComboBoxView = function ComboBoxView(_ref) {
|
|
|
4922
5024
|
return document.removeEventListener('mousedown', handleClickOutside);
|
|
4923
5025
|
};
|
|
4924
5026
|
}, []);
|
|
5027
|
+
// Defines 'handleSearch' to filter items based on the user's query.
|
|
4925
5028
|
var handleSearch = function handleSearch(query) {
|
|
4926
5029
|
setSearchQuery(query);
|
|
4927
5030
|
if (query === '') {
|
|
@@ -4934,11 +5037,13 @@ var ComboBoxView = function ComboBoxView(_ref) {
|
|
|
4934
5037
|
}
|
|
4935
5038
|
setHighlightedIndex(0);
|
|
4936
5039
|
};
|
|
5040
|
+
// Defines 'handleSelect' to handle item selection and close the dropdown.
|
|
4937
5041
|
var handleSelect = function handleSelect(item) {
|
|
4938
5042
|
setSelectedItem(item);
|
|
4939
5043
|
onSelect == null || onSelect(item);
|
|
4940
5044
|
setIsDropdownVisible(false);
|
|
4941
5045
|
};
|
|
5046
|
+
// Starts the JSX returned by the component representing the combobox.
|
|
4942
5047
|
return React.createElement(Horizontal, Object.assign({
|
|
4943
5048
|
role: "combobox",
|
|
4944
5049
|
wrap: "nowrap",
|
|
@@ -5331,18 +5436,15 @@ var FileImage = function FileImage(_ref2) {
|
|
|
5331
5436
|
}, props));
|
|
5332
5437
|
};
|
|
5333
5438
|
|
|
5439
|
+
// Initializes a custom hook for managing tab states with an array of 'Tab' objects passed as properties.
|
|
5334
5440
|
var useTabsState = function useTabsState(propTabs) {
|
|
5335
|
-
// Defines a custom hook, named `useTabsState`, that manages the state of tabs within a component.
|
|
5336
5441
|
var _useState = useState(propTabs[0]),
|
|
5337
5442
|
isActive = _useState[0],
|
|
5338
5443
|
setIsActive = _useState[1];
|
|
5339
|
-
// Initializes 'isActive' state with the first tab from the 'propTabs' array, indicating the currently active tab.
|
|
5340
5444
|
var _useState2 = useState(propTabs),
|
|
5341
5445
|
tabsState = _useState2[0],
|
|
5342
5446
|
setTabsState = _useState2[1];
|
|
5343
|
-
// Initializes 'tabsState' as a stateful array that reflects the tabs passed through 'propTabs' prop, setting the initial state of tabs.
|
|
5344
5447
|
return {
|
|
5345
|
-
// The hook returns an object containing both the state and the functions to update the state, allowing components to control and access the current state of the tabs.
|
|
5346
5448
|
isActive: isActive,
|
|
5347
5449
|
setIsActive: setIsActive,
|
|
5348
5450
|
tabsState: tabsState,
|
|
@@ -5350,21 +5452,31 @@ var useTabsState = function useTabsState(propTabs) {
|
|
|
5350
5452
|
};
|
|
5351
5453
|
};
|
|
5352
5454
|
|
|
5455
|
+
// Defines a functional component 'TabsView' with props of type 'TabsViewProps'.
|
|
5353
5456
|
var TabsView = function TabsView(props) {
|
|
5457
|
+
// Destructures 'tabs', 'styles', 'isActive', 'setIsActive', 'tabsState', and 'setTabsState' from the component props.
|
|
5354
5458
|
var tabs = props.tabs,
|
|
5355
5459
|
styles = props.styles,
|
|
5356
5460
|
isActive = props.isActive,
|
|
5357
5461
|
setIsActive = props.setIsActive,
|
|
5358
5462
|
tabsState = props.tabsState,
|
|
5359
5463
|
setTabsState = props.setTabsState;
|
|
5464
|
+
// Declares a function 'moveSelectedTabToTop' that takes an index and modifies the tabs order.
|
|
5360
5465
|
var moveSelectedTabToTop = function moveSelectedTabToTop(idx) {
|
|
5466
|
+
// Creates a copy of the 'tabs' array from props to be altered.
|
|
5361
5467
|
var newTabs = [].concat(tabs);
|
|
5468
|
+
// Removes the tab at the provided index, effectively selecting this tab.
|
|
5362
5469
|
var selectedTab = newTabs.splice(idx, 1);
|
|
5470
|
+
// Places the selected tab at the start of the 'newTabs' array.
|
|
5363
5471
|
newTabs.unshift(selectedTab[0]);
|
|
5472
|
+
// Updates the state with the reordered tabs.
|
|
5364
5473
|
setTabsState(newTabs);
|
|
5474
|
+
// Sets the active tab to the first tab in the 'newTabs' array.
|
|
5365
5475
|
setIsActive(newTabs[0]);
|
|
5366
5476
|
};
|
|
5477
|
+
// Defines a function 'isContentActive' that checks if the given tab's content is to be displayed.
|
|
5367
5478
|
var isContentActive = function isContentActive(tab) {
|
|
5479
|
+
// Returns a boolean indicating if the given tab is identical to the first tab in 'tabsState'.
|
|
5368
5480
|
return tab.value === tabsState[0].value;
|
|
5369
5481
|
};
|
|
5370
5482
|
return React.createElement(Horizontal, Object.assign({
|
|
@@ -5393,17 +5505,14 @@ var TabsView = function TabsView(props) {
|
|
|
5393
5505
|
})));
|
|
5394
5506
|
};
|
|
5395
5507
|
|
|
5396
|
-
// Define the functional component TabsComponent that utilizes the TabsProps interface for its props.
|
|
5397
5508
|
var TabsComponent = function TabsComponent(_ref) {
|
|
5398
5509
|
var tabs = _ref.tabs,
|
|
5399
5510
|
styles = _ref.styles;
|
|
5400
|
-
// Destructure the 'tabs' and 'styles' properties from the component's props.
|
|
5401
5511
|
var _useTabsState = useTabsState(tabs),
|
|
5402
5512
|
isActive = _useTabsState.isActive,
|
|
5403
5513
|
setIsActive = _useTabsState.setIsActive,
|
|
5404
5514
|
tabsState = _useTabsState.tabsState,
|
|
5405
5515
|
setTabsState = _useTabsState.setTabsState;
|
|
5406
|
-
// Invoke the useTabsState custom hook with 'tabs' to manage state related to tab activities like the active tab and tab state management.
|
|
5407
5516
|
return React.createElement(TabsView, {
|
|
5408
5517
|
tabs: tabs,
|
|
5409
5518
|
styles: styles,
|
|
@@ -5415,54 +5524,66 @@ var TabsComponent = function TabsComponent(_ref) {
|
|
|
5415
5524
|
};
|
|
5416
5525
|
var Tabs = /*#__PURE__*/React.memo(TabsComponent);
|
|
5417
5526
|
|
|
5527
|
+
// Define a constant object 'Themes' exporting various theme styles.
|
|
5418
5528
|
var Themes = {
|
|
5529
|
+
// Start of the 'default' theme definition with style properties.
|
|
5419
5530
|
default: {
|
|
5420
5531
|
container: {
|
|
5421
5532
|
backgroundColor: 'white',
|
|
5422
5533
|
border: 'color.blackAlpha.800'
|
|
5423
5534
|
},
|
|
5535
|
+
// Defines the content style for the 'default' theme.
|
|
5424
5536
|
content: {
|
|
5425
5537
|
color: 'color.blackAlpha.800'
|
|
5426
5538
|
}
|
|
5427
5539
|
},
|
|
5540
|
+
// The 'info' theme with unique container and content styles.
|
|
5428
5541
|
info: {
|
|
5429
5542
|
container: {
|
|
5430
5543
|
backgroundColor: 'color.blue.200',
|
|
5431
5544
|
border: 'color.blue.400'
|
|
5432
5545
|
},
|
|
5546
|
+
// Content styles specific to the 'info' theme.
|
|
5433
5547
|
content: {
|
|
5434
5548
|
color: '#60a5fa'
|
|
5435
5549
|
}
|
|
5436
5550
|
},
|
|
5551
|
+
// Specifies the 'success' theme with corresponding container and content styles.
|
|
5437
5552
|
success: {
|
|
5438
5553
|
container: {
|
|
5439
5554
|
backgroundColor: 'color.green.200',
|
|
5440
5555
|
border: 'color.green.400'
|
|
5441
5556
|
},
|
|
5557
|
+
// Sets the content styling nuances for the 'success' theme.
|
|
5442
5558
|
content: {
|
|
5443
5559
|
color: '#22c55e'
|
|
5444
5560
|
}
|
|
5445
5561
|
},
|
|
5562
|
+
// Start of the 'error' theme with its characteristic styles.
|
|
5446
5563
|
error: {
|
|
5447
5564
|
container: {
|
|
5448
5565
|
backgroundColor: 'color.red.200',
|
|
5449
5566
|
border: 'color.red.400'
|
|
5450
5567
|
},
|
|
5568
|
+
// Content styling for the 'error' theme.
|
|
5451
5569
|
content: {
|
|
5452
5570
|
color: '#ef4444'
|
|
5453
5571
|
}
|
|
5454
5572
|
},
|
|
5573
|
+
// Introduction of the 'warning' theme styles.
|
|
5455
5574
|
warning: {
|
|
5456
5575
|
container: {
|
|
5457
5576
|
backgroundColor: 'color.orange.200',
|
|
5458
5577
|
border: 'color.orange.400'
|
|
5459
5578
|
},
|
|
5579
|
+
// Defines color and aesthetics for the 'warning' theme's content.
|
|
5460
5580
|
content: {
|
|
5461
5581
|
color: '#f97316'
|
|
5462
5582
|
}
|
|
5463
5583
|
}
|
|
5464
5584
|
};
|
|
5465
5585
|
|
|
5586
|
+
// Defines AlertView as a functional component using destructuring to extract props.
|
|
5466
5587
|
var AlertView = function AlertView(_ref) {
|
|
5467
5588
|
var _styles$icon$color;
|
|
5468
5589
|
var icon = _ref.icon,
|
|
@@ -5495,6 +5616,7 @@ var AlertView = function AlertView(_ref) {
|
|
|
5495
5616
|
}, styles == null ? void 0 : styles.description), description)));
|
|
5496
5617
|
};
|
|
5497
5618
|
|
|
5619
|
+
// Definition of the AlertComponent functional component with destructured props.
|
|
5498
5620
|
var AlertComponent = function AlertComponent(_ref) {
|
|
5499
5621
|
var icon = _ref.icon,
|
|
5500
5622
|
title = _ref.title,
|
|
@@ -5509,9 +5631,11 @@ var AlertComponent = function AlertComponent(_ref) {
|
|
|
5509
5631
|
variant: variant
|
|
5510
5632
|
});
|
|
5511
5633
|
};
|
|
5634
|
+
// Exporting the AlertComponent as 'Alert' for use in other parts of the application.
|
|
5512
5635
|
var Alert = AlertComponent;
|
|
5513
5636
|
|
|
5514
5637
|
var _excluded$I = ["ratio", "children"];
|
|
5638
|
+
// Declaration of a functional component named AspectRatioView.
|
|
5515
5639
|
var AspectRatioView = function AspectRatioView(_ref) {
|
|
5516
5640
|
var _ref$ratio = _ref.ratio,
|
|
5517
5641
|
ratio = _ref$ratio === void 0 ? 16 / 9 : _ref$ratio,
|
|
@@ -5533,26 +5657,31 @@ var AspectRatioView = function AspectRatioView(_ref) {
|
|
|
5533
5657
|
};
|
|
5534
5658
|
|
|
5535
5659
|
var _excluded$J = ["ratio", "children"];
|
|
5660
|
+
// Declaration of the AspectRatioComponent functional component with destructured props.
|
|
5536
5661
|
var AspectRatioComponent = function AspectRatioComponent(_ref) {
|
|
5537
5662
|
var ratio = _ref.ratio,
|
|
5538
5663
|
children = _ref.children,
|
|
5539
5664
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$J);
|
|
5665
|
+
// Beginning of the return statement in the functional component.
|
|
5540
5666
|
return React.createElement(AspectRatioView, Object.assign({
|
|
5541
5667
|
ratio: ratio
|
|
5542
5668
|
}, props), children);
|
|
5543
5669
|
};
|
|
5544
5670
|
var AspectRatio = AspectRatioComponent;
|
|
5545
5671
|
|
|
5672
|
+
// Defines a state hook for managing avatar image error status, initialized as false.
|
|
5546
5673
|
var useAvatarState = function useAvatarState() {
|
|
5547
5674
|
var _useState = useState(false),
|
|
5548
5675
|
imageError = _useState[0],
|
|
5549
5676
|
setImageError = _useState[1];
|
|
5677
|
+
// Provides an object containing the image error state and its setter function.
|
|
5550
5678
|
return {
|
|
5551
5679
|
imageError: imageError,
|
|
5552
5680
|
setImageError: setImageError
|
|
5553
5681
|
};
|
|
5554
5682
|
};
|
|
5555
5683
|
|
|
5684
|
+
// Defines a mapping of avatar sizes to their respective numeric values
|
|
5556
5685
|
var AvatarSizeMap = {
|
|
5557
5686
|
xs: 24,
|
|
5558
5687
|
sm: 32,
|
|
@@ -5561,6 +5690,7 @@ var AvatarSizeMap = {
|
|
|
5561
5690
|
xl: 80
|
|
5562
5691
|
};
|
|
5563
5692
|
|
|
5693
|
+
// Declaration of the AvatarView functional component with destructured props from AvatarViewProps.
|
|
5564
5694
|
var AvatarView = function AvatarView(_ref) {
|
|
5565
5695
|
var src = _ref.src,
|
|
5566
5696
|
_ref$size = _ref.size,
|
|
@@ -5570,10 +5700,13 @@ var AvatarView = function AvatarView(_ref) {
|
|
|
5570
5700
|
styles = _ref.styles,
|
|
5571
5701
|
imageError = _ref.imageError,
|
|
5572
5702
|
setImageError = _ref.setImageError;
|
|
5703
|
+
// Determines the size of the avatar by mapping the size prop to the predefined AvatarSizeMap.
|
|
5573
5704
|
var avatarSize = AvatarSizeMap[size];
|
|
5705
|
+
// Initiates a style object for the image with an objectFit property and spreads additional image styles if provided.
|
|
5574
5706
|
var imageStyle = _extends({
|
|
5575
5707
|
objectFit: 'cover'
|
|
5576
5708
|
}, (styles == null ? void 0 : styles.image) || {});
|
|
5709
|
+
// Start of the JSX returned by the AvatarView component, which uses the Center component as its root element.
|
|
5577
5710
|
return React.createElement(Center, Object.assign({
|
|
5578
5711
|
role: "avatar",
|
|
5579
5712
|
width: avatarSize,
|
|
@@ -5583,7 +5716,7 @@ var AvatarView = function AvatarView(_ref) {
|
|
|
5583
5716
|
borderWidth: "1px",
|
|
5584
5717
|
borderStyle: "solid",
|
|
5585
5718
|
borderColor: imageError ? 'black' : 'transparent',
|
|
5586
|
-
boxShadow: "0px 2px 4px rgba(0, 0, 0, 0.25)"
|
|
5719
|
+
boxShadow: "0px 2px 4px rgba(0, 0, 0, 0.25)"
|
|
5587
5720
|
}, styles == null ? void 0 : styles.container), !imageError ? React.createElement(Image, {
|
|
5588
5721
|
alt: "IM",
|
|
5589
5722
|
src: src,
|
|
@@ -5598,14 +5731,17 @@ var AvatarView = function AvatarView(_ref) {
|
|
|
5598
5731
|
}, styles == null ? void 0 : styles.fallback), fallback));
|
|
5599
5732
|
};
|
|
5600
5733
|
|
|
5734
|
+
// Defines the AvatarComponent functional component with destructured props from AvatarProps type.
|
|
5601
5735
|
var AvatarComponent = function AvatarComponent(_ref) {
|
|
5602
5736
|
var src = _ref.src,
|
|
5603
5737
|
size = _ref.size,
|
|
5604
5738
|
styles = _ref.styles,
|
|
5605
5739
|
fallback = _ref.fallback;
|
|
5740
|
+
// Uses custom hook useAvatarState to manage the avatar image loading error state.
|
|
5606
5741
|
var _useAvatarState = useAvatarState(),
|
|
5607
5742
|
imageError = _useAvatarState.imageError,
|
|
5608
5743
|
setImageError = _useAvatarState.setImageError;
|
|
5744
|
+
// Begins the JSX return block for rendering the AvatarView component.
|
|
5609
5745
|
return React.createElement(AvatarView, {
|
|
5610
5746
|
src: src,
|
|
5611
5747
|
size: size,
|
|
@@ -5614,7 +5750,9 @@ var AvatarComponent = function AvatarComponent(_ref) {
|
|
|
5614
5750
|
imageError: imageError,
|
|
5615
5751
|
setImageError: setImageError
|
|
5616
5752
|
});
|
|
5753
|
+
// AvatarComponent is a functional component that wraps the AvatarView with added state logic.
|
|
5617
5754
|
};
|
|
5755
|
+
// Exports the AvatarComponent as Avatar for use in other parts of the application.
|
|
5618
5756
|
var Avatar = AvatarComponent;
|
|
5619
5757
|
|
|
5620
5758
|
var BadgeSizes = {
|
|
@@ -5672,6 +5810,7 @@ var PositionStyles = {
|
|
|
5672
5810
|
}
|
|
5673
5811
|
};
|
|
5674
5812
|
|
|
5813
|
+
// Importing Text component to display the content text within the badge.
|
|
5675
5814
|
var BadgeView = function BadgeView(_ref) {
|
|
5676
5815
|
var content = _ref.content,
|
|
5677
5816
|
position = _ref.position,
|
|
@@ -5693,6 +5832,7 @@ var BadgeView = function BadgeView(_ref) {
|
|
|
5693
5832
|
borderColor: 'transparent'
|
|
5694
5833
|
},
|
|
5695
5834
|
outline: {
|
|
5835
|
+
// Combining various style objects along with conditional styles based on props to create the badge's appearance.
|
|
5696
5836
|
backgroundColor: 'transparent',
|
|
5697
5837
|
borderWidth: 1,
|
|
5698
5838
|
borderStyle: 'solid',
|
|
@@ -5701,10 +5841,13 @@ var BadgeView = function BadgeView(_ref) {
|
|
|
5701
5841
|
},
|
|
5702
5842
|
link: {
|
|
5703
5843
|
backgroundColor: 'transparent',
|
|
5844
|
+
// Rendering the Badge component using the Center layout component with combinedStyles applied.
|
|
5704
5845
|
borderWidth: 1,
|
|
5846
|
+
// Inserting a Text component into the badge to display the content, with dynamic size and additional text styles.
|
|
5705
5847
|
borderStyle: 'solid',
|
|
5706
5848
|
borderColor: 'transparent',
|
|
5707
5849
|
color: colorScheme,
|
|
5850
|
+
// Exporting BadgeView to be used in other parts of the application.
|
|
5708
5851
|
textDecoration: 'underline'
|
|
5709
5852
|
},
|
|
5710
5853
|
ghost: {
|
|
@@ -5727,6 +5870,7 @@ var BadgeView = function BadgeView(_ref) {
|
|
|
5727
5870
|
}, styles == null ? void 0 : styles.text), content));
|
|
5728
5871
|
};
|
|
5729
5872
|
|
|
5873
|
+
// Importing type definitions for BadgeProps that will be used to type-check the Badge component's props.
|
|
5730
5874
|
var Badge = function Badge(_ref) {
|
|
5731
5875
|
var content = _ref.content,
|
|
5732
5876
|
shape = _ref.shape,
|
|
@@ -5746,13 +5890,17 @@ var Badge = function Badge(_ref) {
|
|
|
5746
5890
|
});
|
|
5747
5891
|
};
|
|
5748
5892
|
|
|
5893
|
+
// Declares the useToggleState function which takes defaultToggled parameter to initialize the toggle state.
|
|
5749
5894
|
var useToggleState = function useToggleState(defaultToggled) {
|
|
5895
|
+
// Creates a stateful value isHovered for tracking hover state and a function setIsHovered to update that state, initially false.
|
|
5750
5896
|
var _useState = useState(false),
|
|
5751
5897
|
isHovered = _useState[0],
|
|
5752
5898
|
setIsHovered = _useState[1];
|
|
5899
|
+
// Creates a stateful value isToggle to store the current toggle state and a function setIsToggled to modify it, initialized with defaultToggled.
|
|
5753
5900
|
var _useState2 = useState(defaultToggled),
|
|
5754
5901
|
isToggle = _useState2[0],
|
|
5755
5902
|
setIsToggled = _useState2[1];
|
|
5903
|
+
// Returns an object containing the current states and the functions to update them for external use.
|
|
5756
5904
|
return {
|
|
5757
5905
|
isHovered: isHovered,
|
|
5758
5906
|
setIsHovered: setIsHovered,
|
|
@@ -5804,14 +5952,12 @@ var ToggleView = function ToggleView(_ref) {
|
|
|
5804
5952
|
setIsToggled(function (prev) {
|
|
5805
5953
|
var newState = !prev;
|
|
5806
5954
|
if (onToggle) {
|
|
5807
|
-
// Check if onToggle is defined before calling it
|
|
5808
5955
|
onToggle(newState);
|
|
5809
5956
|
}
|
|
5810
|
-
return newState;
|
|
5957
|
+
return newState;
|
|
5811
5958
|
});
|
|
5812
5959
|
}
|
|
5813
5960
|
};
|
|
5814
|
-
|
|
5815
5961
|
return React.createElement(Center, Object.assign({
|
|
5816
5962
|
role: "Toggle",
|
|
5817
5963
|
padding: shape === 'pillShaped' ? '10px 12px' : '8px',
|
|
@@ -5831,6 +5977,7 @@ var ToggleView = function ToggleView(_ref) {
|
|
|
5831
5977
|
};
|
|
5832
5978
|
|
|
5833
5979
|
var _excluded$L = ["children", "shape", "colorScheme", "variant", "isDisabled", "isToggled", "onToggle"];
|
|
5980
|
+
// Destructuring properties from ToggleProps to be used within the ToggleComponent.
|
|
5834
5981
|
var ToggleComponent = function ToggleComponent(_ref) {
|
|
5835
5982
|
var children = _ref.children,
|
|
5836
5983
|
shape = _ref.shape,
|
|
@@ -5841,14 +5988,17 @@ var ToggleComponent = function ToggleComponent(_ref) {
|
|
|
5841
5988
|
isToggled = _ref$isToggled === void 0 ? false : _ref$isToggled,
|
|
5842
5989
|
onToggle = _ref.onToggle,
|
|
5843
5990
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$L);
|
|
5991
|
+
// Initializing toggle state and set state functions using the custom hook useToggleState.
|
|
5844
5992
|
var _useToggleState = useToggleState(isToggled),
|
|
5845
5993
|
isHovered = _useToggleState.isHovered,
|
|
5846
5994
|
setIsHovered = _useToggleState.setIsHovered,
|
|
5847
5995
|
isToggle = _useToggleState.isToggle,
|
|
5848
5996
|
setIsToggled = _useToggleState.setIsToggled;
|
|
5997
|
+
// Creating an effect that updates the isToggled state whenever the isToggled prop changes.
|
|
5849
5998
|
useEffect(function () {
|
|
5850
5999
|
setIsToggled(isToggled);
|
|
5851
6000
|
}, [isToggled]);
|
|
6001
|
+
// Beginning of the JSX block to render the Toggle view component.
|
|
5852
6002
|
return React.createElement(ToggleView, Object.assign({
|
|
5853
6003
|
shape: shape,
|
|
5854
6004
|
colorScheme: colorScheme,
|
|
@@ -5863,6 +6013,7 @@ var ToggleComponent = function ToggleComponent(_ref) {
|
|
|
5863
6013
|
};
|
|
5864
6014
|
var Toggle = ToggleComponent;
|
|
5865
6015
|
|
|
6016
|
+
// Define a custom hook for managing ToggleGroup state
|
|
5866
6017
|
var useToggleGroupState = function useToggleGroupState() {
|
|
5867
6018
|
var _useState = useState([]),
|
|
5868
6019
|
activeToggles = _useState[0],
|
|
@@ -5873,6 +6024,7 @@ var useToggleGroupState = function useToggleGroupState() {
|
|
|
5873
6024
|
};
|
|
5874
6025
|
};
|
|
5875
6026
|
|
|
6027
|
+
// ToggleGroupView component declaration with destructured properties from props.
|
|
5876
6028
|
var ToggleGroupView = function ToggleGroupView(_ref) {
|
|
5877
6029
|
var items = _ref.items,
|
|
5878
6030
|
onToggleChange = _ref.onToggleChange,
|
|
@@ -5884,14 +6036,13 @@ var ToggleGroupView = function ToggleGroupView(_ref) {
|
|
|
5884
6036
|
variant = _ref$variant === void 0 ? 'ghost' : _ref$variant,
|
|
5885
6037
|
_ref$colorScheme = _ref.colorScheme,
|
|
5886
6038
|
colorScheme = _ref$colorScheme === void 0 ? 'color.trueGray.400' : _ref$colorScheme;
|
|
6039
|
+
// handleToggle is a memoized callback that handles the toggle state changes.
|
|
5887
6040
|
var handleToggle = useCallback(function (id, isActive) {
|
|
5888
6041
|
setActiveToggles(function (prevActiveToggles) {
|
|
5889
6042
|
var newActiveToggles;
|
|
5890
6043
|
if (isActive) {
|
|
5891
|
-
// Add the ID only if it's not already included
|
|
5892
6044
|
newActiveToggles = prevActiveToggles.includes(id) ? prevActiveToggles : [].concat(prevActiveToggles, [id]);
|
|
5893
6045
|
} else {
|
|
5894
|
-
// Remove the ID if it's included
|
|
5895
6046
|
newActiveToggles = prevActiveToggles.filter(function (toggleId) {
|
|
5896
6047
|
return toggleId !== id;
|
|
5897
6048
|
});
|
|
@@ -5921,12 +6072,14 @@ var ToggleGroupView = function ToggleGroupView(_ref) {
|
|
|
5921
6072
|
}));
|
|
5922
6073
|
};
|
|
5923
6074
|
|
|
6075
|
+
// Define the functional component with destructured props
|
|
5924
6076
|
var ToggleGroupComponent = function ToggleGroupComponent(_ref) {
|
|
5925
6077
|
var items = _ref.items,
|
|
5926
6078
|
shape = _ref.shape,
|
|
5927
6079
|
colorScheme = _ref.colorScheme,
|
|
5928
6080
|
variant = _ref.variant,
|
|
5929
6081
|
onToggleChange = _ref.onToggleChange;
|
|
6082
|
+
// Hook to manage toggle group state, returns active toggles and a setter for it
|
|
5930
6083
|
var _useToggleGroupState = useToggleGroupState(),
|
|
5931
6084
|
activeToggles = _useToggleGroupState.activeToggles,
|
|
5932
6085
|
setActiveToggles = _useToggleGroupState.setActiveToggles;
|
|
@@ -5940,6 +6093,7 @@ var ToggleGroupComponent = function ToggleGroupComponent(_ref) {
|
|
|
5940
6093
|
onToggleChange: onToggleChange
|
|
5941
6094
|
});
|
|
5942
6095
|
};
|
|
6096
|
+
// Expose the ToggleGroupComponent for import into other modules
|
|
5943
6097
|
var ToggleGroup = ToggleGroupComponent;
|
|
5944
6098
|
|
|
5945
6099
|
// Create your store with the initial state and actions.
|