@vector-business-services/cristal-ds-web 0.4.0 → 0.5.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.js CHANGED
@@ -1,19 +1,29 @@
1
- import { forwardRef, useId, useRef, useImperativeHandle, useContext, useState, useEffect } from 'react';
1
+ import { forwardRef, useId, useRef, useImperativeHandle, useCallback, useEffect, useContext, useState, Children, isValidElement, cloneElement } from 'react';
2
2
  import { AutoComplete as AutoComplete$1 } from 'primereact/autocomplete';
3
- import { WarningCircle, Info, CircleNotch, Check, CaretDown, MagnifyingGlass, X, List } from '@phosphor-icons/react';
3
+ import { WarningCircle, Info, Check, CircleNotch, CaretDown, MagnifyingGlass, CaretUp, X, List, ArrowLeft, Question } from '@phosphor-icons/react';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import { Badge as Badge$1 } from 'primereact/badge';
6
6
  import { Button as Button$1 } from 'primereact/button';
7
7
  import { Card as Card$1 } from 'primereact/card';
8
+ import { Checkbox as Checkbox$1 } from 'primereact/checkbox';
8
9
  import { Chip as Chip$1 } from 'primereact/chip';
9
10
  import { Divider as Divider$1 } from 'primereact/divider';
11
+ import { Sidebar } from 'primereact/sidebar';
10
12
  import { InputText } from 'primereact/inputtext';
11
13
  import { PrimeReactContext, PrimeReactProvider } from 'primereact/api';
12
14
  import { Menu as Menu$1 } from 'primereact/menu';
13
15
  import { Menubar as Menubar$1 } from 'primereact/menubar';
14
16
  import { Avatar } from 'primereact/avatar';
15
17
  import { Tooltip as Tooltip$1 } from 'primereact/tooltip';
18
+ import { Dialog } from 'primereact/dialog';
16
19
  import { MultiSelect as MultiSelect$1 } from 'primereact/multiselect';
20
+ import { Panel as Panel$1 } from 'primereact/panel';
21
+ import { RadioButton } from 'primereact/radiobutton';
22
+ import { ScrollPanel as ScrollPanel$1 } from 'primereact/scrollpanel';
23
+ import { SelectButton } from 'primereact/selectbutton';
24
+ import { Dropdown } from 'primereact/dropdown';
25
+ import { InputSwitch } from 'primereact/inputswitch';
26
+ import { TabView, TabPanel as TabPanel$1 } from 'primereact/tabview';
17
27
  import { Tag as Tag$1 } from 'primereact/tag';
18
28
 
19
29
  // src/components/AutoComplete/AutoComplete.tsx
@@ -140,6 +150,76 @@ var Card = forwardRef(function Card2({ padding = "xsmall", outline = false, clas
140
150
  }
141
151
  );
142
152
  });
153
+ var Checkbox = forwardRef(function Checkbox2({
154
+ label,
155
+ showLabel = true,
156
+ position = "left",
157
+ labelSize = "default",
158
+ checked = false,
159
+ indeterminate = false,
160
+ onChange,
161
+ disabled,
162
+ required,
163
+ name,
164
+ value,
165
+ id,
166
+ className,
167
+ style
168
+ }, ref) {
169
+ const autoId = useId();
170
+ const inputId = id ?? autoId;
171
+ const inputRef = useRef(null);
172
+ const setInputRef = useCallback(
173
+ (input) => {
174
+ inputRef.current = input;
175
+ if (typeof ref === "function") ref(input);
176
+ else if (ref) ref.current = input;
177
+ },
178
+ [ref]
179
+ );
180
+ useEffect(() => {
181
+ if (inputRef.current) inputRef.current.indeterminate = indeterminate && !checked;
182
+ }, [indeterminate, checked]);
183
+ const classes = [
184
+ "cr-checkbox",
185
+ `cr-checkbox--${position}`,
186
+ `cr-checkbox--label-${labelSize}`,
187
+ indeterminate && !checked && "cr-checkbox--indeterminate",
188
+ disabled && "cr-checkbox--disabled",
189
+ className
190
+ ].filter(Boolean).join(" ");
191
+ return /* @__PURE__ */ jsxs("div", { className: classes, style, children: [
192
+ /* @__PURE__ */ jsx(
193
+ Checkbox$1,
194
+ {
195
+ unstyled: true,
196
+ inputRef: setInputRef,
197
+ inputId,
198
+ checked,
199
+ onChange,
200
+ disabled,
201
+ required,
202
+ name,
203
+ value,
204
+ icon: /* @__PURE__ */ jsx(Check, { size: 16 }),
205
+ pt: {
206
+ root: { className: "cr-checkbox__control" },
207
+ input: { className: "cr-checkbox__input" },
208
+ box: { className: "cr-checkbox__box" },
209
+ icon: { className: "cr-checkbox__icon", "aria-hidden": true }
210
+ }
211
+ }
212
+ ),
213
+ /* @__PURE__ */ jsx(
214
+ "label",
215
+ {
216
+ className: `cr-checkbox__label${showLabel ? "" : " cr-checkbox__label--hidden"}`,
217
+ htmlFor: inputId,
218
+ children: label
219
+ }
220
+ )
221
+ ] });
222
+ });
143
223
  var Chip = forwardRef(function Chip2({
144
224
  label,
145
225
  variant = "default",
@@ -231,6 +311,135 @@ var IconButton = forwardRef(function IconButton2({ variant = "primary", size = "
231
311
  }
232
312
  );
233
313
  });
314
+ var FOCAVEIS = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
315
+ function Drawer({
316
+ visible,
317
+ onHide,
318
+ title,
319
+ subtitle,
320
+ side = "right",
321
+ behavior = "full",
322
+ onBack,
323
+ backLabel = "Voltar",
324
+ closeLabel = "Fechar",
325
+ footer,
326
+ children,
327
+ id,
328
+ className
329
+ }) {
330
+ const autoId = useId();
331
+ const titleId = `${autoId}-title`;
332
+ const subtitleId = `${autoId}-subtitle`;
333
+ const panelRef = useRef(null);
334
+ const retorno = useRef(null);
335
+ useEffect(() => {
336
+ if (visible) {
337
+ retorno.current = document.activeElement;
338
+ return;
339
+ }
340
+ retorno.current?.focus();
341
+ retorno.current = null;
342
+ }, [visible]);
343
+ const [rolagem, setRolagem] = useState(null);
344
+ const [rolavel, setRolavel] = useState(false);
345
+ useEffect(() => {
346
+ if (!rolagem) return;
347
+ const medir = () => setRolavel(rolagem.scrollHeight > rolagem.clientHeight);
348
+ medir();
349
+ const observer = new ResizeObserver(medir);
350
+ observer.observe(rolagem);
351
+ [...rolagem.children].forEach((child) => observer.observe(child));
352
+ return () => observer.disconnect();
353
+ }, [rolagem, children]);
354
+ const prenderFoco = (event) => {
355
+ if (event.key !== "Tab" || !panelRef.current) return;
356
+ const focaveis = [...panelRef.current.querySelectorAll(FOCAVEIS)];
357
+ const primeiro = focaveis[0];
358
+ const ultimo = focaveis[focaveis.length - 1];
359
+ if (!primeiro || !ultimo) return;
360
+ if (event.shiftKey && document.activeElement === primeiro) {
361
+ event.preventDefault();
362
+ ultimo.focus();
363
+ } else if (!event.shiftKey && document.activeElement === ultimo) {
364
+ event.preventDefault();
365
+ primeiro.focus();
366
+ }
367
+ };
368
+ const classes = ["cr-drawer", `cr-drawer--${side}`, `cr-drawer--${behavior}`, className].filter(Boolean).join(" ");
369
+ return /* @__PURE__ */ jsx(
370
+ Sidebar,
371
+ {
372
+ unstyled: true,
373
+ id,
374
+ visible,
375
+ onHide,
376
+ position: side,
377
+ blockScroll: true,
378
+ pt: {
379
+ mask: { className: `cr-drawer__mask cr-drawer__mask--${side}` },
380
+ root: {
381
+ className: classes,
382
+ role: "dialog",
383
+ "aria-modal": true,
384
+ "aria-labelledby": titleId,
385
+ "aria-describedby": subtitle ? subtitleId : void 0,
386
+ onKeyDown: prenderFoco
387
+ }
388
+ },
389
+ content: ({ closeIconRef, hide }) => /* @__PURE__ */ jsxs(
390
+ "div",
391
+ {
392
+ ref: (element) => {
393
+ panelRef.current = element;
394
+ if (behavior === "full") setRolagem(element);
395
+ },
396
+ className: "cr-drawer__panel",
397
+ tabIndex: behavior === "full" && rolavel ? 0 : void 0,
398
+ children: [
399
+ /* @__PURE__ */ jsxs("div", { className: "cr-drawer__header", children: [
400
+ /* @__PURE__ */ jsxs("div", { className: "cr-drawer__title-row", children: [
401
+ onBack && /* @__PURE__ */ jsx(
402
+ IconButton,
403
+ {
404
+ variant: "tertiary",
405
+ size: "xsmall",
406
+ icon: /* @__PURE__ */ jsx(ArrowLeft, {}),
407
+ "aria-label": backLabel,
408
+ onClick: onBack
409
+ }
410
+ ),
411
+ /* @__PURE__ */ jsx("h2", { id: titleId, className: "cr-drawer__title", children: title })
412
+ ] }),
413
+ subtitle && /* @__PURE__ */ jsx("p", { id: subtitleId, className: "cr-drawer__subtitle", children: subtitle })
414
+ ] }),
415
+ /* @__PURE__ */ jsx(
416
+ "div",
417
+ {
418
+ ref: behavior === "fixed" ? setRolagem : void 0,
419
+ className: "cr-drawer__body",
420
+ tabIndex: behavior === "fixed" && rolavel ? 0 : void 0,
421
+ children
422
+ }
423
+ ),
424
+ footer && /* @__PURE__ */ jsx("div", { className: "cr-drawer__footer", children: footer }),
425
+ /* @__PURE__ */ jsx(
426
+ IconButton,
427
+ {
428
+ ref: closeIconRef,
429
+ className: "cr-drawer__close",
430
+ variant: "tertiary",
431
+ size: "xsmall",
432
+ icon: /* @__PURE__ */ jsx(X, {}),
433
+ "aria-label": closeLabel,
434
+ onClick: (event) => hide(event)
435
+ }
436
+ )
437
+ ]
438
+ }
439
+ )
440
+ }
441
+ );
442
+ }
234
443
  var Input = forwardRef(function Input2({
235
444
  variant = "outline",
236
445
  size = "large",
@@ -619,6 +828,96 @@ var Menubar = forwardRef(function Menubar2({
619
828
  }
620
829
  ) });
621
830
  });
831
+ function Modal({
832
+ visible,
833
+ onHide,
834
+ title,
835
+ size = "large",
836
+ onHelp,
837
+ helpLabel = "Ajuda",
838
+ closeLabel = "Fechar",
839
+ footer,
840
+ footerStart,
841
+ children,
842
+ id,
843
+ className
844
+ }) {
845
+ const autoId = useId();
846
+ const titleId = `${autoId}-title`;
847
+ const [body, setBody] = useState(null);
848
+ const [rolavel, setRolavel] = useState(false);
849
+ useEffect(() => {
850
+ if (!body) return;
851
+ const medir = () => setRolavel(body.scrollHeight > body.clientHeight);
852
+ medir();
853
+ const observer = new ResizeObserver(medir);
854
+ observer.observe(body);
855
+ [...body.children].forEach((child) => observer.observe(child));
856
+ return () => observer.disconnect();
857
+ }, [body, children]);
858
+ const classes = ["cr-modal", `cr-modal--${size}`, rolavel && "cr-modal--scrollable", className].filter(Boolean).join(" ");
859
+ return /* @__PURE__ */ jsx(
860
+ Dialog,
861
+ {
862
+ unstyled: true,
863
+ id,
864
+ visible,
865
+ onHide,
866
+ draggable: false,
867
+ resizable: false,
868
+ blockScroll: true,
869
+ pt: {
870
+ mask: { className: "cr-modal__mask" },
871
+ root: {
872
+ className: classes,
873
+ "aria-labelledby": titleId,
874
+ "aria-describedby": void 0
875
+ }
876
+ },
877
+ content: ({ hide, closeRef }) => /* @__PURE__ */ jsxs(Fragment, { children: [
878
+ /* @__PURE__ */ jsxs("div", { className: "cr-modal__header", children: [
879
+ /* @__PURE__ */ jsx("h2", { id: titleId, className: "cr-modal__title", children: title }),
880
+ /* @__PURE__ */ jsxs("div", { className: "cr-modal__tools", children: [
881
+ onHelp && size !== "large" && /* @__PURE__ */ jsx(
882
+ IconButton,
883
+ {
884
+ variant: "tertiary",
885
+ size: "xsmall",
886
+ icon: /* @__PURE__ */ jsx(Question, {}),
887
+ "aria-label": helpLabel,
888
+ onClick: onHelp
889
+ }
890
+ ),
891
+ /* @__PURE__ */ jsx(
892
+ IconButton,
893
+ {
894
+ ref: closeRef,
895
+ variant: "tertiary",
896
+ size: "xsmall",
897
+ icon: /* @__PURE__ */ jsx(X, {}),
898
+ "aria-label": closeLabel,
899
+ onClick: (event) => hide(event)
900
+ }
901
+ )
902
+ ] })
903
+ ] }),
904
+ /* @__PURE__ */ jsx(
905
+ "div",
906
+ {
907
+ ref: setBody,
908
+ className: "cr-modal__body",
909
+ tabIndex: rolavel ? 0 : void 0,
910
+ children
911
+ }
912
+ ),
913
+ (footer || footerStart) && /* @__PURE__ */ jsxs("div", { className: "cr-modal__footer", children: [
914
+ /* @__PURE__ */ jsx("div", { className: "cr-modal__footer-start", children: footerStart }),
915
+ /* @__PURE__ */ jsx("div", { className: "cr-modal__footer-end", children: footer })
916
+ ] })
917
+ ] })
918
+ }
919
+ );
920
+ }
622
921
  var MultiSelect = forwardRef(function MultiSelect2({
623
922
  variant = "outline",
624
923
  size = "large",
@@ -798,6 +1097,402 @@ var MultiSelect = forwardRef(function MultiSelect2({
798
1097
  ] })
799
1098
  ] });
800
1099
  });
1100
+ var Panel = forwardRef(function Panel2({ className, style, children, ...props }, ref) {
1101
+ const primeRef = useRef(null);
1102
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
1103
+ return /* @__PURE__ */ jsx(
1104
+ Panel$1,
1105
+ {
1106
+ unstyled: true,
1107
+ ref: primeRef,
1108
+ pt: {
1109
+ root: { className: ["cr-panel", className].filter(Boolean).join(" "), style },
1110
+ toggleableContent: {
1111
+ className: "cr-panel__body",
1112
+ role: void 0,
1113
+ "aria-labelledby": void 0
1114
+ },
1115
+ content: { className: "cr-panel__content" }
1116
+ },
1117
+ ...props,
1118
+ children
1119
+ }
1120
+ );
1121
+ });
1122
+ var Radio = forwardRef(function Radio2({
1123
+ label,
1124
+ showLabel = true,
1125
+ labelSize = "default",
1126
+ checked = false,
1127
+ value,
1128
+ name,
1129
+ onChange,
1130
+ disabled,
1131
+ required,
1132
+ id,
1133
+ className,
1134
+ style
1135
+ }, ref) {
1136
+ const autoId = useId();
1137
+ const inputId = id ?? autoId;
1138
+ const classes = [
1139
+ "cr-radio",
1140
+ `cr-radio--label-${labelSize}`,
1141
+ disabled && "cr-radio--disabled",
1142
+ className
1143
+ ].filter(Boolean).join(" ");
1144
+ return /* @__PURE__ */ jsxs("div", { className: classes, style, children: [
1145
+ /* @__PURE__ */ jsx(
1146
+ RadioButton,
1147
+ {
1148
+ unstyled: true,
1149
+ inputRef: ref,
1150
+ inputId,
1151
+ checked,
1152
+ value,
1153
+ name,
1154
+ onChange,
1155
+ disabled,
1156
+ required,
1157
+ pt: {
1158
+ root: { className: "cr-radio__control" },
1159
+ input: { className: "cr-radio__input" },
1160
+ box: { className: "cr-radio__box" },
1161
+ icon: { className: "cr-radio__icon" }
1162
+ }
1163
+ }
1164
+ ),
1165
+ /* @__PURE__ */ jsx(
1166
+ "label",
1167
+ {
1168
+ className: `cr-radio__label${showLabel ? "" : " cr-radio__label--hidden"}`,
1169
+ htmlFor: inputId,
1170
+ children: label
1171
+ }
1172
+ )
1173
+ ] });
1174
+ });
1175
+ var porcentagem = (posicao, total, visivel) => total > visivel ? Math.round(posicao / (total - visivel) * 100) : 0;
1176
+ var ScrollPanel = forwardRef(function ScrollPanel2({ children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, style, id, className }, ref) {
1177
+ const primeRef = useRef(null);
1178
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
1179
+ const contentId = `${useId()}-content`;
1180
+ const [posicao, setPosicao] = useState({ x: 0, y: 0 });
1181
+ const aoRolar = (event) => {
1182
+ const el = event.currentTarget;
1183
+ setPosicao({
1184
+ x: porcentagem(el.scrollLeft, el.scrollWidth, el.clientWidth),
1185
+ y: porcentagem(el.scrollTop, el.scrollHeight, el.clientHeight)
1186
+ });
1187
+ };
1188
+ const barra = (orientacao, valor) => ({
1189
+ className: `cr-scrollpanel__bar cr-scrollpanel__bar--${orientacao}`,
1190
+ tabIndex: -1,
1191
+ "aria-controls": contentId,
1192
+ "aria-valuenow": valor,
1193
+ "aria-valuemin": 0,
1194
+ "aria-valuemax": 100
1195
+ });
1196
+ const pt = {
1197
+ root: { className: ["cr-scrollpanel", className].filter(Boolean).join(" "), style },
1198
+ wrapper: { className: "cr-scrollpanel__wrapper" },
1199
+ content: {
1200
+ id: contentId,
1201
+ className: "cr-scrollpanel__content",
1202
+ tabIndex: 0,
1203
+ role: "region",
1204
+ "aria-label": ariaLabel,
1205
+ "aria-labelledby": ariaLabelledBy,
1206
+ onScroll: aoRolar
1207
+ },
1208
+ barx: barra("horizontal", posicao.x),
1209
+ bary: barra("vertical", posicao.y)
1210
+ };
1211
+ return /* @__PURE__ */ jsx(ScrollPanel$1, { unstyled: true, ref: primeRef, id, pt, children });
1212
+ });
1213
+ var SegmentControl = forwardRef(
1214
+ function SegmentControl2({
1215
+ options,
1216
+ value,
1217
+ onChange,
1218
+ variant = "primary",
1219
+ "aria-label": ariaLabel,
1220
+ "aria-labelledby": ariaLabelledBy,
1221
+ disabled,
1222
+ id,
1223
+ className
1224
+ }, ref) {
1225
+ const primeRef = useRef(null);
1226
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
1227
+ const classes = ["cr-segment", `cr-segment--${variant}`, className].filter(Boolean).join(" ");
1228
+ return /* @__PURE__ */ jsx(
1229
+ SelectButton,
1230
+ {
1231
+ unstyled: true,
1232
+ ref: primeRef,
1233
+ id,
1234
+ options,
1235
+ optionLabel: "label",
1236
+ optionValue: "value",
1237
+ optionDisabled: "disabled",
1238
+ value,
1239
+ onChange: (event) => {
1240
+ if (event.value != null) onChange?.(event.value);
1241
+ },
1242
+ allowEmpty: false,
1243
+ disabled,
1244
+ "aria-label": ariaLabel,
1245
+ "aria-labelledby": ariaLabelledBy,
1246
+ itemTemplate: (option) => /* @__PURE__ */ jsxs(Fragment, { children: [
1247
+ option.icon && /* @__PURE__ */ jsx("span", { className: "cr-segment__icon", "aria-hidden": "true", children: option.icon }),
1248
+ /* @__PURE__ */ jsx("span", { className: "cr-segment__label", children: option.label })
1249
+ ] }),
1250
+ pt: {
1251
+ root: { className: classes },
1252
+ button: {
1253
+ className: "cr-segment__item",
1254
+ // O Prime só ativa com a barra de espaço; um role=button responde também ao Enter.
1255
+ onKeyDown: (event) => {
1256
+ if (event.key === "Enter") event.currentTarget.click();
1257
+ }
1258
+ }
1259
+ }
1260
+ }
1261
+ );
1262
+ }
1263
+ );
1264
+ var Select = forwardRef(function Select2({
1265
+ variant = "outline",
1266
+ size = "large",
1267
+ label,
1268
+ "aria-label": ariaLabel,
1269
+ options,
1270
+ optionLabel = "label",
1271
+ optionValue,
1272
+ value,
1273
+ onChange,
1274
+ placeholder = "Selecione uma op\xE7\xE3o",
1275
+ hint,
1276
+ error,
1277
+ required,
1278
+ disabled,
1279
+ id,
1280
+ name,
1281
+ className
1282
+ }, ref) {
1283
+ const autoId = useId();
1284
+ const inputId = id ?? autoId;
1285
+ const hintId = `${inputId}-hint`;
1286
+ const listId = `${inputId}-list`;
1287
+ const supportText = error ?? hint;
1288
+ const [open, setOpen] = useState(false);
1289
+ const setInputRef = useCallback(
1290
+ (input) => {
1291
+ input?.setAttribute("role", "combobox");
1292
+ if (typeof ref === "function") ref(input);
1293
+ else if (ref) ref.current = input;
1294
+ },
1295
+ [ref]
1296
+ );
1297
+ const classes = [
1298
+ "cr-field",
1299
+ `cr-field--${variant}`,
1300
+ `cr-field--${size}`,
1301
+ "cr-select",
1302
+ error && "cr-field--error",
1303
+ disabled && "cr-field--disabled",
1304
+ className
1305
+ ].filter(Boolean).join(" ");
1306
+ const pt = {
1307
+ root: {
1308
+ className: `cr-field__control cr-select__control${open ? " cr-select__control--open" : ""}`,
1309
+ // O Prime aponta para um item mesmo sem destaque (dropdownItem_-1); o foco vai no item.
1310
+ "aria-activedescendant": void 0
1311
+ },
1312
+ // O <select> escondido do Prime só existe para formulários: fora da árvore de acessibilidade.
1313
+ select: { "aria-hidden": true },
1314
+ hiddenSelectedMessage: { className: "cr-select__hidden" },
1315
+ // O Prime usa a mesma chave no texto do campo e no combobox escondido.
1316
+ input: { className: "cr-select__value" },
1317
+ trigger: { className: "cr-field__icon cr-select__trigger", "aria-hidden": true },
1318
+ panel: { className: "cr-select__panel" },
1319
+ wrapper: { className: "cr-select__wrapper" },
1320
+ list: { className: "cr-select__list", id: listId },
1321
+ item: { className: "cr-select__item" },
1322
+ emptyMessage: { className: "cr-select__item cr-select__empty" }
1323
+ };
1324
+ return /* @__PURE__ */ jsxs("div", { className: classes, children: [
1325
+ label && /* @__PURE__ */ jsxs("label", { className: "cr-field__label", htmlFor: inputId, children: [
1326
+ label,
1327
+ required && /* @__PURE__ */ jsx("span", { className: "cr-field__required", "aria-hidden": "true", children: "*" })
1328
+ ] }),
1329
+ /* @__PURE__ */ jsx(
1330
+ Dropdown,
1331
+ {
1332
+ unstyled: true,
1333
+ inputId,
1334
+ focusInputRef: setInputRef,
1335
+ value,
1336
+ options,
1337
+ optionLabel,
1338
+ optionValue,
1339
+ onChange: (event) => onChange?.(event.value),
1340
+ onShow: () => setOpen(true),
1341
+ onHide: () => setOpen(false),
1342
+ disabled,
1343
+ required,
1344
+ name,
1345
+ invalid: Boolean(error),
1346
+ placeholder,
1347
+ valueTemplate: (option) => option == null ? /* @__PURE__ */ jsx("span", { className: "cr-select__placeholder", children: placeholder }) : String(option[optionLabel] ?? option),
1348
+ scrollHeight: "185px",
1349
+ dropdownIcon: /* @__PURE__ */ jsx(CaretDown, {}),
1350
+ collapseIcon: /* @__PURE__ */ jsx(CaretUp, {}),
1351
+ "aria-label": label ? void 0 : ariaLabel,
1352
+ "aria-expanded": open,
1353
+ "aria-controls": open ? listId : void 0,
1354
+ "aria-describedby": supportText ? hintId : void 0,
1355
+ "aria-invalid": error ? true : void 0,
1356
+ "aria-required": required || void 0,
1357
+ pt
1358
+ }
1359
+ ),
1360
+ supportText && /* @__PURE__ */ jsxs("p", { id: hintId, className: `cr-field__hint${error ? " cr-field__hint--error" : ""}`, children: [
1361
+ /* @__PURE__ */ jsx("span", { className: "cr-field__hint-icon", "aria-hidden": "true", children: error ? /* @__PURE__ */ jsx(WarningCircle, {}) : /* @__PURE__ */ jsx(Info, {}) }),
1362
+ supportText
1363
+ ] })
1364
+ ] });
1365
+ });
1366
+ var Switch = forwardRef(function Switch2({
1367
+ label,
1368
+ showLabel = true,
1369
+ labelPosition = "right",
1370
+ size = "medium",
1371
+ checked = false,
1372
+ onChange,
1373
+ disabled,
1374
+ name,
1375
+ id,
1376
+ className,
1377
+ style
1378
+ }, ref) {
1379
+ const autoId = useId();
1380
+ const inputId = id ?? autoId;
1381
+ const classes = [
1382
+ "cr-switch",
1383
+ `cr-switch--${size}`,
1384
+ `cr-switch--label-${labelPosition}`,
1385
+ disabled && "cr-switch--disabled",
1386
+ className
1387
+ ].filter(Boolean).join(" ");
1388
+ return /* @__PURE__ */ jsxs("div", { className: classes, style, children: [
1389
+ /* @__PURE__ */ jsx(
1390
+ InputSwitch,
1391
+ {
1392
+ unstyled: true,
1393
+ inputRef: ref,
1394
+ inputId,
1395
+ checked,
1396
+ onChange,
1397
+ disabled,
1398
+ name,
1399
+ pt: {
1400
+ root: { className: "cr-switch__control", role: void 0, "aria-checked": void 0 },
1401
+ input: { className: "cr-switch__input" },
1402
+ slider: { className: "cr-switch__track" }
1403
+ }
1404
+ }
1405
+ ),
1406
+ /* @__PURE__ */ jsx(
1407
+ "label",
1408
+ {
1409
+ className: `cr-switch__label${showLabel ? "" : " cr-switch__label--hidden"}`,
1410
+ htmlFor: inputId,
1411
+ children: label
1412
+ }
1413
+ )
1414
+ ] });
1415
+ });
1416
+ function TabPanel(_props) {
1417
+ return null;
1418
+ }
1419
+ var Tabs = forwardRef(function Tabs2({ activeIndex, onTabChange, children, id, className }, ref) {
1420
+ const primeRef = useRef(null);
1421
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
1422
+ const [interno, setInterno] = useState(0);
1423
+ const ativa = activeIndex ?? interno;
1424
+ const panels = Children.toArray(children).filter(
1425
+ (child) => isValidElement(child)
1426
+ );
1427
+ const header = (panel) => function TabHeader(options) {
1428
+ const element = options.element;
1429
+ const close = panel.onClose;
1430
+ return cloneElement(
1431
+ element,
1432
+ {
1433
+ "aria-keyshortcuts": close ? "Delete" : void 0,
1434
+ onKeyDown: (event) => {
1435
+ if (close && event.key === "Delete") close();
1436
+ else element.props.onKeyDown?.(event);
1437
+ }
1438
+ },
1439
+ /* @__PURE__ */ jsxs(Fragment, { children: [
1440
+ panel.leftIcon && /* @__PURE__ */ jsx("span", { className: "cr-tabs__icon", "aria-hidden": "true", children: panel.leftIcon }),
1441
+ /* @__PURE__ */ jsx("span", { className: "cr-tabs__label", children: panel.header }),
1442
+ panel.badge !== void 0 && /* @__PURE__ */ jsx(Badge, { className: "cr-tabs__badge", children: panel.badge }),
1443
+ close && // O X é só para o mouse: pelo teclado a aba fecha com Delete (aria-keyshortcuts).
1444
+ /* @__PURE__ */ jsx(
1445
+ "span",
1446
+ {
1447
+ className: "cr-tabs__close",
1448
+ "aria-hidden": "true",
1449
+ onClick: (event) => {
1450
+ event.stopPropagation();
1451
+ close();
1452
+ },
1453
+ children: /* @__PURE__ */ jsx(X, {})
1454
+ }
1455
+ )
1456
+ ] })
1457
+ );
1458
+ };
1459
+ return /* @__PURE__ */ jsx(
1460
+ TabView,
1461
+ {
1462
+ unstyled: true,
1463
+ ref: primeRef,
1464
+ id,
1465
+ activeIndex: ativa,
1466
+ onTabChange: (event) => {
1467
+ setInterno(event.index);
1468
+ onTabChange?.(event.index);
1469
+ },
1470
+ pt: {
1471
+ root: { className: ["cr-tabs", className].filter(Boolean).join(" ") },
1472
+ navContainer: { className: "cr-tabs__nav-container" },
1473
+ navContent: { className: "cr-tabs__nav-content" },
1474
+ nav: { className: "cr-tabs__nav" },
1475
+ inkbar: { className: "cr-tabs__inkbar" },
1476
+ panelContainer: { className: "cr-tabs__panels" }
1477
+ },
1478
+ children: panels.map((panel, index) => /* @__PURE__ */ jsx(
1479
+ TabPanel$1,
1480
+ {
1481
+ header: panel.props.header,
1482
+ disabled: panel.props.disabled,
1483
+ headerTemplate: header(panel.props),
1484
+ pt: {
1485
+ header: { className: "cr-tabs__item" },
1486
+ headerAction: { className: "cr-tabs__tab" },
1487
+ content: { className: "cr-tabs__panel" }
1488
+ },
1489
+ children: panel.props.children
1490
+ },
1491
+ panel.key ?? index
1492
+ ))
1493
+ }
1494
+ );
1495
+ });
801
1496
  var Tag = forwardRef(function Tag2({ variant = "default", size = "small", icon, className, children, ...props }, ref) {
802
1497
  const primeRef = useRef(null);
803
1498
  useImperativeHandle(ref, () => primeRef.current?.getElement());
@@ -815,6 +1510,6 @@ var Tag = forwardRef(function Tag2({ variant = "default", size = "small", icon,
815
1510
  );
816
1511
  });
817
1512
 
818
- export { AutoComplete, Badge, Button, Card, Chip, Divider, IconButton, Input, Menu, Menubar, MultiSelect, Tag, Tooltip };
1513
+ export { AutoComplete, Badge, Button, Card, Checkbox, Chip, Divider, Drawer, IconButton, Input, Menu, Menubar, Modal, MultiSelect, Panel, Radio, ScrollPanel, SegmentControl, Select, Switch, TabPanel, Tabs, Tag, Tooltip };
819
1514
  //# sourceMappingURL=index.js.map
820
1515
  //# sourceMappingURL=index.js.map