@vector-business-services/cristal-ds-web 0.4.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/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,149 @@ 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
+ modal = true,
323
+ onBack,
324
+ backLabel = "Voltar",
325
+ closeLabel = "Fechar",
326
+ footer,
327
+ children,
328
+ id,
329
+ className
330
+ }) {
331
+ const autoId = useId();
332
+ const titleId = `${autoId}-title`;
333
+ const subtitleId = `${autoId}-subtitle`;
334
+ const panelRef = useRef(null);
335
+ const retorno = useRef(null);
336
+ useEffect(() => {
337
+ if (visible) {
338
+ retorno.current = document.activeElement;
339
+ return;
340
+ }
341
+ retorno.current?.focus();
342
+ retorno.current = null;
343
+ }, [visible]);
344
+ const [rolagem, setRolagem] = useState(null);
345
+ const [rolavel, setRolavel] = useState(false);
346
+ useEffect(() => {
347
+ if (!rolagem) return;
348
+ const medir = () => setRolavel(rolagem.scrollHeight > rolagem.clientHeight);
349
+ medir();
350
+ const observer = new ResizeObserver(medir);
351
+ observer.observe(rolagem);
352
+ [...rolagem.children].forEach((child) => observer.observe(child));
353
+ return () => observer.disconnect();
354
+ }, [rolagem, children]);
355
+ const prenderFoco = (event) => {
356
+ if (!modal || event.key !== "Tab" || !panelRef.current) return;
357
+ const focaveis = [...panelRef.current.querySelectorAll(FOCAVEIS)];
358
+ const primeiro = focaveis[0];
359
+ const ultimo = focaveis[focaveis.length - 1];
360
+ if (!primeiro || !ultimo) return;
361
+ if (event.shiftKey && document.activeElement === primeiro) {
362
+ event.preventDefault();
363
+ ultimo.focus();
364
+ } else if (!event.shiftKey && document.activeElement === ultimo) {
365
+ event.preventDefault();
366
+ primeiro.focus();
367
+ }
368
+ };
369
+ const classes = ["cr-drawer", `cr-drawer--${side}`, `cr-drawer--${behavior}`, className].filter(Boolean).join(" ");
370
+ return /* @__PURE__ */ jsx(
371
+ Sidebar,
372
+ {
373
+ unstyled: true,
374
+ id,
375
+ visible,
376
+ onHide,
377
+ position: side,
378
+ modal,
379
+ blockScroll: modal,
380
+ dismissable: modal,
381
+ pt: {
382
+ mask: {
383
+ className: `cr-drawer__mask cr-drawer__mask--${side}${modal ? "" : " cr-drawer__mask--sem-overlay"}`
384
+ },
385
+ root: {
386
+ className: classes,
387
+ role: "dialog",
388
+ "aria-modal": modal || void 0,
389
+ "aria-labelledby": titleId,
390
+ "aria-describedby": subtitle ? subtitleId : void 0,
391
+ onKeyDown: prenderFoco
392
+ },
393
+ // No unstyled o Prime não põe classes na transição: o Cristal dá as dele (Drawer.css).
394
+ // O tipo do Prime exige o addEndListener do react-transition-group, que aqui não se usa.
395
+ transition: {
396
+ classNames: {
397
+ enter: "cr-drawer--enter",
398
+ enterActive: "cr-drawer--enter-active",
399
+ exitActive: "cr-drawer--exit-active"
400
+ }
401
+ }
402
+ },
403
+ content: ({ closeIconRef, hide }) => /* @__PURE__ */ jsxs(
404
+ "div",
405
+ {
406
+ ref: (element) => {
407
+ panelRef.current = element;
408
+ if (behavior === "full") setRolagem(element);
409
+ },
410
+ className: "cr-drawer__panel",
411
+ tabIndex: behavior === "full" && rolavel ? 0 : void 0,
412
+ children: [
413
+ /* @__PURE__ */ jsxs("div", { className: "cr-drawer__header", children: [
414
+ /* @__PURE__ */ jsxs("div", { className: "cr-drawer__title-row", children: [
415
+ onBack && /* @__PURE__ */ jsx(
416
+ IconButton,
417
+ {
418
+ variant: "tertiary",
419
+ size: "xsmall",
420
+ icon: /* @__PURE__ */ jsx(ArrowLeft, {}),
421
+ "aria-label": backLabel,
422
+ onClick: onBack
423
+ }
424
+ ),
425
+ /* @__PURE__ */ jsx("h2", { id: titleId, className: "cr-drawer__title", children: title })
426
+ ] }),
427
+ subtitle && /* @__PURE__ */ jsx("p", { id: subtitleId, className: "cr-drawer__subtitle", children: subtitle })
428
+ ] }),
429
+ /* @__PURE__ */ jsx(
430
+ "div",
431
+ {
432
+ ref: behavior === "fixed" ? setRolagem : void 0,
433
+ className: "cr-drawer__body",
434
+ tabIndex: behavior === "fixed" && rolavel ? 0 : void 0,
435
+ children
436
+ }
437
+ ),
438
+ footer && /* @__PURE__ */ jsx("div", { className: "cr-drawer__footer", children: footer }),
439
+ /* @__PURE__ */ jsx(
440
+ IconButton,
441
+ {
442
+ ref: closeIconRef,
443
+ className: "cr-drawer__close",
444
+ variant: "tertiary",
445
+ size: "xsmall",
446
+ icon: /* @__PURE__ */ jsx(X, {}),
447
+ "aria-label": closeLabel,
448
+ onClick: (event) => hide(event)
449
+ }
450
+ )
451
+ ]
452
+ }
453
+ )
454
+ }
455
+ );
456
+ }
234
457
  var Input = forwardRef(function Input2({
235
458
  variant = "outline",
236
459
  size = "large",
@@ -619,6 +842,96 @@ var Menubar = forwardRef(function Menubar2({
619
842
  }
620
843
  ) });
621
844
  });
845
+ function Modal({
846
+ visible,
847
+ onHide,
848
+ title,
849
+ size = "large",
850
+ onHelp,
851
+ helpLabel = "Ajuda",
852
+ closeLabel = "Fechar",
853
+ footer,
854
+ footerStart,
855
+ children,
856
+ id,
857
+ className
858
+ }) {
859
+ const autoId = useId();
860
+ const titleId = `${autoId}-title`;
861
+ const [body, setBody] = useState(null);
862
+ const [rolavel, setRolavel] = useState(false);
863
+ useEffect(() => {
864
+ if (!body) return;
865
+ const medir = () => setRolavel(body.scrollHeight > body.clientHeight);
866
+ medir();
867
+ const observer = new ResizeObserver(medir);
868
+ observer.observe(body);
869
+ [...body.children].forEach((child) => observer.observe(child));
870
+ return () => observer.disconnect();
871
+ }, [body, children]);
872
+ const classes = ["cr-modal", `cr-modal--${size}`, rolavel && "cr-modal--scrollable", className].filter(Boolean).join(" ");
873
+ return /* @__PURE__ */ jsx(
874
+ Dialog,
875
+ {
876
+ unstyled: true,
877
+ id,
878
+ visible,
879
+ onHide,
880
+ draggable: false,
881
+ resizable: false,
882
+ blockScroll: true,
883
+ pt: {
884
+ mask: { className: "cr-modal__mask" },
885
+ root: {
886
+ className: classes,
887
+ "aria-labelledby": titleId,
888
+ "aria-describedby": void 0
889
+ }
890
+ },
891
+ content: ({ hide, closeRef }) => /* @__PURE__ */ jsxs(Fragment, { children: [
892
+ /* @__PURE__ */ jsxs("div", { className: "cr-modal__header", children: [
893
+ /* @__PURE__ */ jsx("h2", { id: titleId, className: "cr-modal__title", children: title }),
894
+ /* @__PURE__ */ jsxs("div", { className: "cr-modal__tools", children: [
895
+ onHelp && size !== "large" && /* @__PURE__ */ jsx(
896
+ IconButton,
897
+ {
898
+ variant: "tertiary",
899
+ size: "xsmall",
900
+ icon: /* @__PURE__ */ jsx(Question, {}),
901
+ "aria-label": helpLabel,
902
+ onClick: onHelp
903
+ }
904
+ ),
905
+ /* @__PURE__ */ jsx(
906
+ IconButton,
907
+ {
908
+ ref: closeRef,
909
+ variant: "tertiary",
910
+ size: "xsmall",
911
+ icon: /* @__PURE__ */ jsx(X, {}),
912
+ "aria-label": closeLabel,
913
+ onClick: (event) => hide(event)
914
+ }
915
+ )
916
+ ] })
917
+ ] }),
918
+ /* @__PURE__ */ jsx(
919
+ "div",
920
+ {
921
+ ref: setBody,
922
+ className: "cr-modal__body",
923
+ tabIndex: rolavel ? 0 : void 0,
924
+ children
925
+ }
926
+ ),
927
+ (footer || footerStart) && /* @__PURE__ */ jsxs("div", { className: "cr-modal__footer", children: [
928
+ /* @__PURE__ */ jsx("div", { className: "cr-modal__footer-start", children: footerStart }),
929
+ /* @__PURE__ */ jsx("div", { className: "cr-modal__footer-end", children: footer })
930
+ ] })
931
+ ] })
932
+ }
933
+ );
934
+ }
622
935
  var MultiSelect = forwardRef(function MultiSelect2({
623
936
  variant = "outline",
624
937
  size = "large",
@@ -798,6 +1111,402 @@ var MultiSelect = forwardRef(function MultiSelect2({
798
1111
  ] })
799
1112
  ] });
800
1113
  });
1114
+ var Panel = forwardRef(function Panel2({ className, style, children, ...props }, ref) {
1115
+ const primeRef = useRef(null);
1116
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
1117
+ return /* @__PURE__ */ jsx(
1118
+ Panel$1,
1119
+ {
1120
+ unstyled: true,
1121
+ ref: primeRef,
1122
+ pt: {
1123
+ root: { className: ["cr-panel", className].filter(Boolean).join(" "), style },
1124
+ toggleableContent: {
1125
+ className: "cr-panel__body",
1126
+ role: void 0,
1127
+ "aria-labelledby": void 0
1128
+ },
1129
+ content: { className: "cr-panel__content" }
1130
+ },
1131
+ ...props,
1132
+ children
1133
+ }
1134
+ );
1135
+ });
1136
+ var Radio = forwardRef(function Radio2({
1137
+ label,
1138
+ showLabel = true,
1139
+ labelSize = "default",
1140
+ checked = false,
1141
+ value,
1142
+ name,
1143
+ onChange,
1144
+ disabled,
1145
+ required,
1146
+ id,
1147
+ className,
1148
+ style
1149
+ }, ref) {
1150
+ const autoId = useId();
1151
+ const inputId = id ?? autoId;
1152
+ const classes = [
1153
+ "cr-radio",
1154
+ `cr-radio--label-${labelSize}`,
1155
+ disabled && "cr-radio--disabled",
1156
+ className
1157
+ ].filter(Boolean).join(" ");
1158
+ return /* @__PURE__ */ jsxs("div", { className: classes, style, children: [
1159
+ /* @__PURE__ */ jsx(
1160
+ RadioButton,
1161
+ {
1162
+ unstyled: true,
1163
+ inputRef: ref,
1164
+ inputId,
1165
+ checked,
1166
+ value,
1167
+ name,
1168
+ onChange,
1169
+ disabled,
1170
+ required,
1171
+ pt: {
1172
+ root: { className: "cr-radio__control" },
1173
+ input: { className: "cr-radio__input" },
1174
+ box: { className: "cr-radio__box" },
1175
+ icon: { className: "cr-radio__icon" }
1176
+ }
1177
+ }
1178
+ ),
1179
+ /* @__PURE__ */ jsx(
1180
+ "label",
1181
+ {
1182
+ className: `cr-radio__label${showLabel ? "" : " cr-radio__label--hidden"}`,
1183
+ htmlFor: inputId,
1184
+ children: label
1185
+ }
1186
+ )
1187
+ ] });
1188
+ });
1189
+ var porcentagem = (posicao, total, visivel) => total > visivel ? Math.round(posicao / (total - visivel) * 100) : 0;
1190
+ var ScrollPanel = forwardRef(function ScrollPanel2({ children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, style, id, className }, ref) {
1191
+ const primeRef = useRef(null);
1192
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
1193
+ const contentId = `${useId()}-content`;
1194
+ const [posicao, setPosicao] = useState({ x: 0, y: 0 });
1195
+ const aoRolar = (event) => {
1196
+ const el = event.currentTarget;
1197
+ setPosicao({
1198
+ x: porcentagem(el.scrollLeft, el.scrollWidth, el.clientWidth),
1199
+ y: porcentagem(el.scrollTop, el.scrollHeight, el.clientHeight)
1200
+ });
1201
+ };
1202
+ const barra = (orientacao, valor) => ({
1203
+ className: `cr-scrollpanel__bar cr-scrollpanel__bar--${orientacao}`,
1204
+ tabIndex: -1,
1205
+ "aria-controls": contentId,
1206
+ "aria-valuenow": valor,
1207
+ "aria-valuemin": 0,
1208
+ "aria-valuemax": 100
1209
+ });
1210
+ const pt = {
1211
+ root: { className: ["cr-scrollpanel", className].filter(Boolean).join(" "), style },
1212
+ wrapper: { className: "cr-scrollpanel__wrapper" },
1213
+ content: {
1214
+ id: contentId,
1215
+ className: "cr-scrollpanel__content",
1216
+ tabIndex: 0,
1217
+ role: "region",
1218
+ "aria-label": ariaLabel,
1219
+ "aria-labelledby": ariaLabelledBy,
1220
+ onScroll: aoRolar
1221
+ },
1222
+ barx: barra("horizontal", posicao.x),
1223
+ bary: barra("vertical", posicao.y)
1224
+ };
1225
+ return /* @__PURE__ */ jsx(ScrollPanel$1, { unstyled: true, ref: primeRef, id, pt, children });
1226
+ });
1227
+ var SegmentControl = forwardRef(
1228
+ function SegmentControl2({
1229
+ options,
1230
+ value,
1231
+ onChange,
1232
+ variant = "primary",
1233
+ "aria-label": ariaLabel,
1234
+ "aria-labelledby": ariaLabelledBy,
1235
+ disabled,
1236
+ id,
1237
+ className
1238
+ }, ref) {
1239
+ const primeRef = useRef(null);
1240
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
1241
+ const classes = ["cr-segment", `cr-segment--${variant}`, className].filter(Boolean).join(" ");
1242
+ return /* @__PURE__ */ jsx(
1243
+ SelectButton,
1244
+ {
1245
+ unstyled: true,
1246
+ ref: primeRef,
1247
+ id,
1248
+ options,
1249
+ optionLabel: "label",
1250
+ optionValue: "value",
1251
+ optionDisabled: "disabled",
1252
+ value,
1253
+ onChange: (event) => {
1254
+ if (event.value != null) onChange?.(event.value);
1255
+ },
1256
+ allowEmpty: false,
1257
+ disabled,
1258
+ "aria-label": ariaLabel,
1259
+ "aria-labelledby": ariaLabelledBy,
1260
+ itemTemplate: (option) => /* @__PURE__ */ jsxs(Fragment, { children: [
1261
+ option.icon && /* @__PURE__ */ jsx("span", { className: "cr-segment__icon", "aria-hidden": "true", children: option.icon }),
1262
+ /* @__PURE__ */ jsx("span", { className: "cr-segment__label", children: option.label })
1263
+ ] }),
1264
+ pt: {
1265
+ root: { className: classes },
1266
+ button: {
1267
+ className: "cr-segment__item",
1268
+ // O Prime só ativa com a barra de espaço; um role=button responde também ao Enter.
1269
+ onKeyDown: (event) => {
1270
+ if (event.key === "Enter") event.currentTarget.click();
1271
+ }
1272
+ }
1273
+ }
1274
+ }
1275
+ );
1276
+ }
1277
+ );
1278
+ var Select = forwardRef(function Select2({
1279
+ variant = "outline",
1280
+ size = "large",
1281
+ label,
1282
+ "aria-label": ariaLabel,
1283
+ options,
1284
+ optionLabel = "label",
1285
+ optionValue,
1286
+ value,
1287
+ onChange,
1288
+ placeholder = "Selecione uma op\xE7\xE3o",
1289
+ hint,
1290
+ error,
1291
+ required,
1292
+ disabled,
1293
+ id,
1294
+ name,
1295
+ className
1296
+ }, ref) {
1297
+ const autoId = useId();
1298
+ const inputId = id ?? autoId;
1299
+ const hintId = `${inputId}-hint`;
1300
+ const listId = `${inputId}-list`;
1301
+ const supportText = error ?? hint;
1302
+ const [open, setOpen] = useState(false);
1303
+ const setInputRef = useCallback(
1304
+ (input) => {
1305
+ input?.setAttribute("role", "combobox");
1306
+ if (typeof ref === "function") ref(input);
1307
+ else if (ref) ref.current = input;
1308
+ },
1309
+ [ref]
1310
+ );
1311
+ const classes = [
1312
+ "cr-field",
1313
+ `cr-field--${variant}`,
1314
+ `cr-field--${size}`,
1315
+ "cr-select",
1316
+ error && "cr-field--error",
1317
+ disabled && "cr-field--disabled",
1318
+ className
1319
+ ].filter(Boolean).join(" ");
1320
+ const pt = {
1321
+ root: {
1322
+ className: `cr-field__control cr-select__control${open ? " cr-select__control--open" : ""}`,
1323
+ // O Prime aponta para um item mesmo sem destaque (dropdownItem_-1); o foco vai no item.
1324
+ "aria-activedescendant": void 0
1325
+ },
1326
+ // O <select> escondido do Prime só existe para formulários: fora da árvore de acessibilidade.
1327
+ select: { "aria-hidden": true },
1328
+ hiddenSelectedMessage: { className: "cr-select__hidden" },
1329
+ // O Prime usa a mesma chave no texto do campo e no combobox escondido.
1330
+ input: { className: "cr-select__value" },
1331
+ trigger: { className: "cr-field__icon cr-select__trigger", "aria-hidden": true },
1332
+ panel: { className: "cr-select__panel" },
1333
+ wrapper: { className: "cr-select__wrapper" },
1334
+ list: { className: "cr-select__list", id: listId },
1335
+ item: { className: "cr-select__item" },
1336
+ emptyMessage: { className: "cr-select__item cr-select__empty" }
1337
+ };
1338
+ return /* @__PURE__ */ jsxs("div", { className: classes, children: [
1339
+ label && /* @__PURE__ */ jsxs("label", { className: "cr-field__label", htmlFor: inputId, children: [
1340
+ label,
1341
+ required && /* @__PURE__ */ jsx("span", { className: "cr-field__required", "aria-hidden": "true", children: "*" })
1342
+ ] }),
1343
+ /* @__PURE__ */ jsx(
1344
+ Dropdown,
1345
+ {
1346
+ unstyled: true,
1347
+ inputId,
1348
+ focusInputRef: setInputRef,
1349
+ value,
1350
+ options,
1351
+ optionLabel,
1352
+ optionValue,
1353
+ onChange: (event) => onChange?.(event.value),
1354
+ onShow: () => setOpen(true),
1355
+ onHide: () => setOpen(false),
1356
+ disabled,
1357
+ required,
1358
+ name,
1359
+ invalid: Boolean(error),
1360
+ placeholder,
1361
+ valueTemplate: (option) => option == null ? /* @__PURE__ */ jsx("span", { className: "cr-select__placeholder", children: placeholder }) : String(option[optionLabel] ?? option),
1362
+ scrollHeight: "185px",
1363
+ dropdownIcon: /* @__PURE__ */ jsx(CaretDown, {}),
1364
+ collapseIcon: /* @__PURE__ */ jsx(CaretUp, {}),
1365
+ "aria-label": label ? void 0 : ariaLabel,
1366
+ "aria-expanded": open,
1367
+ "aria-controls": open ? listId : void 0,
1368
+ "aria-describedby": supportText ? hintId : void 0,
1369
+ "aria-invalid": error ? true : void 0,
1370
+ "aria-required": required || void 0,
1371
+ pt
1372
+ }
1373
+ ),
1374
+ supportText && /* @__PURE__ */ jsxs("p", { id: hintId, className: `cr-field__hint${error ? " cr-field__hint--error" : ""}`, children: [
1375
+ /* @__PURE__ */ jsx("span", { className: "cr-field__hint-icon", "aria-hidden": "true", children: error ? /* @__PURE__ */ jsx(WarningCircle, {}) : /* @__PURE__ */ jsx(Info, {}) }),
1376
+ supportText
1377
+ ] })
1378
+ ] });
1379
+ });
1380
+ var Switch = forwardRef(function Switch2({
1381
+ label,
1382
+ showLabel = true,
1383
+ labelPosition = "right",
1384
+ size = "medium",
1385
+ checked = false,
1386
+ onChange,
1387
+ disabled,
1388
+ name,
1389
+ id,
1390
+ className,
1391
+ style
1392
+ }, ref) {
1393
+ const autoId = useId();
1394
+ const inputId = id ?? autoId;
1395
+ const classes = [
1396
+ "cr-switch",
1397
+ `cr-switch--${size}`,
1398
+ `cr-switch--label-${labelPosition}`,
1399
+ disabled && "cr-switch--disabled",
1400
+ className
1401
+ ].filter(Boolean).join(" ");
1402
+ return /* @__PURE__ */ jsxs("div", { className: classes, style, children: [
1403
+ /* @__PURE__ */ jsx(
1404
+ InputSwitch,
1405
+ {
1406
+ unstyled: true,
1407
+ inputRef: ref,
1408
+ inputId,
1409
+ checked,
1410
+ onChange,
1411
+ disabled,
1412
+ name,
1413
+ pt: {
1414
+ root: { className: "cr-switch__control", role: void 0, "aria-checked": void 0 },
1415
+ input: { className: "cr-switch__input" },
1416
+ slider: { className: "cr-switch__track" }
1417
+ }
1418
+ }
1419
+ ),
1420
+ /* @__PURE__ */ jsx(
1421
+ "label",
1422
+ {
1423
+ className: `cr-switch__label${showLabel ? "" : " cr-switch__label--hidden"}`,
1424
+ htmlFor: inputId,
1425
+ children: label
1426
+ }
1427
+ )
1428
+ ] });
1429
+ });
1430
+ function TabPanel(_props) {
1431
+ return null;
1432
+ }
1433
+ var Tabs = forwardRef(function Tabs2({ activeIndex, onTabChange, children, id, className }, ref) {
1434
+ const primeRef = useRef(null);
1435
+ useImperativeHandle(ref, () => primeRef.current?.getElement());
1436
+ const [interno, setInterno] = useState(0);
1437
+ const ativa = activeIndex ?? interno;
1438
+ const panels = Children.toArray(children).filter(
1439
+ (child) => isValidElement(child)
1440
+ );
1441
+ const header = (panel) => function TabHeader(options) {
1442
+ const element = options.element;
1443
+ const close = panel.onClose;
1444
+ return cloneElement(
1445
+ element,
1446
+ {
1447
+ "aria-keyshortcuts": close ? "Delete" : void 0,
1448
+ onKeyDown: (event) => {
1449
+ if (close && event.key === "Delete") close();
1450
+ else element.props.onKeyDown?.(event);
1451
+ }
1452
+ },
1453
+ /* @__PURE__ */ jsxs(Fragment, { children: [
1454
+ panel.leftIcon && /* @__PURE__ */ jsx("span", { className: "cr-tabs__icon", "aria-hidden": "true", children: panel.leftIcon }),
1455
+ /* @__PURE__ */ jsx("span", { className: "cr-tabs__label", children: panel.header }),
1456
+ panel.badge !== void 0 && /* @__PURE__ */ jsx(Badge, { className: "cr-tabs__badge", children: panel.badge }),
1457
+ close && // O X é só para o mouse: pelo teclado a aba fecha com Delete (aria-keyshortcuts).
1458
+ /* @__PURE__ */ jsx(
1459
+ "span",
1460
+ {
1461
+ className: "cr-tabs__close",
1462
+ "aria-hidden": "true",
1463
+ onClick: (event) => {
1464
+ event.stopPropagation();
1465
+ close();
1466
+ },
1467
+ children: /* @__PURE__ */ jsx(X, {})
1468
+ }
1469
+ )
1470
+ ] })
1471
+ );
1472
+ };
1473
+ return /* @__PURE__ */ jsx(
1474
+ TabView,
1475
+ {
1476
+ unstyled: true,
1477
+ ref: primeRef,
1478
+ id,
1479
+ activeIndex: ativa,
1480
+ onTabChange: (event) => {
1481
+ setInterno(event.index);
1482
+ onTabChange?.(event.index);
1483
+ },
1484
+ pt: {
1485
+ root: { className: ["cr-tabs", className].filter(Boolean).join(" ") },
1486
+ navContainer: { className: "cr-tabs__nav-container" },
1487
+ navContent: { className: "cr-tabs__nav-content" },
1488
+ nav: { className: "cr-tabs__nav" },
1489
+ inkbar: { className: "cr-tabs__inkbar" },
1490
+ panelContainer: { className: "cr-tabs__panels" }
1491
+ },
1492
+ children: panels.map((panel, index) => /* @__PURE__ */ jsx(
1493
+ TabPanel$1,
1494
+ {
1495
+ header: panel.props.header,
1496
+ disabled: panel.props.disabled,
1497
+ headerTemplate: header(panel.props),
1498
+ pt: {
1499
+ header: { className: "cr-tabs__item" },
1500
+ headerAction: { className: "cr-tabs__tab" },
1501
+ content: { className: "cr-tabs__panel" }
1502
+ },
1503
+ children: panel.props.children
1504
+ },
1505
+ panel.key ?? index
1506
+ ))
1507
+ }
1508
+ );
1509
+ });
801
1510
  var Tag = forwardRef(function Tag2({ variant = "default", size = "small", icon, className, children, ...props }, ref) {
802
1511
  const primeRef = useRef(null);
803
1512
  useImperativeHandle(ref, () => primeRef.current?.getElement());
@@ -815,6 +1524,6 @@ var Tag = forwardRef(function Tag2({ variant = "default", size = "small", icon,
815
1524
  );
816
1525
  });
817
1526
 
818
- export { AutoComplete, Badge, Button, Card, Chip, Divider, IconButton, Input, Menu, Menubar, MultiSelect, Tag, Tooltip };
1527
+ 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
1528
  //# sourceMappingURL=index.js.map
820
1529
  //# sourceMappingURL=index.js.map