@vector-business-services/cristal-ds-web 0.22.0 → 0.23.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.cjs CHANGED
@@ -140,6 +140,7 @@ var AutoComplete = react.forwardRef(function AutoComplete2({
140
140
  error,
141
141
  dropdown = false,
142
142
  dropdownAriaLabel = "Mostrar op\xE7\xF5es",
143
+ openOnClick = true,
143
144
  inputId,
144
145
  required,
145
146
  disabled,
@@ -151,6 +152,8 @@ var AutoComplete = react.forwardRef(function AutoComplete2({
151
152
  const id = inputId ?? autoId;
152
153
  const hintId = `${id}-hint`;
153
154
  const supportText = error ?? hint;
155
+ const prime = react.useRef(null);
156
+ const aberta = () => Boolean(prime.current?.getOverlay());
154
157
  const classes2 = [
155
158
  "cr-field",
156
159
  "cr-autocomplete",
@@ -169,6 +172,7 @@ var AutoComplete = react.forwardRef(function AutoComplete2({
169
172
  /* @__PURE__ */ jsxRuntime.jsx(
170
173
  autocomplete.AutoComplete,
171
174
  {
175
+ ref: prime,
172
176
  unstyled: true,
173
177
  inputRef: ref,
174
178
  inputId: id,
@@ -184,12 +188,31 @@ var AutoComplete = react.forwardRef(function AutoComplete2({
184
188
  root: {
185
189
  className: "cr-field__control cr-autocomplete__input",
186
190
  "aria-describedby": juntarIds(supportText && hintId, props["aria-describedby"]),
187
- "aria-invalid": error ? true : void 0
191
+ "aria-invalid": error ? true : void 0,
192
+ // O clique no campo abre a lista (o Prime só abre ao digitar ou pela seta).
193
+ ...openOnClick && {
194
+ onClick: (event) => {
195
+ if (!aberta() && !disabled) {
196
+ prime.current?.search(event, event.currentTarget.value, "dropdown");
197
+ }
198
+ }
199
+ }
188
200
  }
189
201
  },
190
202
  // A seta: o botão de dropdown do Prime, por cima do fim do <input> (que segue sendo a caixa,
191
203
  // para a lista continuar alinhada ao campo).
192
- dropdownButton: { root: { className: "cr-autocomplete__dropdown" } },
204
+ dropdownButton: {
205
+ root: {
206
+ className: "cr-autocomplete__dropdown",
207
+ // Com a lista aberta, a seta fecha (como no p-autoComplete do PrimeNG 19); a do
208
+ // PrimeReact só abre. Na captura, antes do clique do Prime, que buscaria de novo.
209
+ onClickCapture: (event) => {
210
+ if (!aberta()) return;
211
+ event.stopPropagation();
212
+ prime.current?.hide();
213
+ }
214
+ }
215
+ },
193
216
  // O Prime mostra um spinner próprio enquanto busca; o Figma não define esse estado.
194
217
  loadingIcon: { className: "cr-autocomplete__loader" },
195
218
  panel: { className: "cr-lista cr-autocomplete__panel" },
@@ -1288,18 +1311,26 @@ function ListaDePeriodos({
1288
1311
  onEscolher
1289
1312
  }) {
1290
1313
  const grupo = react.useId();
1291
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cr-data-picker__periods", role: "radiogroup", "aria-label": "Per\xEDodos", children: periods.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
1292
- Radio,
1314
+ return /* @__PURE__ */ jsxRuntime.jsx(
1315
+ "div",
1293
1316
  {
1294
- className: "cr-data-picker__period",
1295
- name: grupo,
1296
- label: item.label,
1297
- value: item.label,
1298
- checked: periodo === item,
1299
- onChange: () => onEscolher(item)
1300
- },
1301
- item.label
1302
- )) });
1317
+ className: "cr-data-picker__periods cr-rolagem-fina",
1318
+ role: "radiogroup",
1319
+ "aria-label": "Per\xEDodos",
1320
+ children: periods.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
1321
+ Radio,
1322
+ {
1323
+ className: "cr-data-picker__period",
1324
+ name: grupo,
1325
+ label: item.label,
1326
+ value: item.label,
1327
+ checked: periodo === item,
1328
+ onChange: () => onEscolher(item)
1329
+ },
1330
+ item.label
1331
+ ))
1332
+ }
1333
+ );
1303
1334
  }
1304
1335
  var mesmoRascunho = (a, b) => (a[0] === b[0] || mesmoDia2(a[0], b[0])) && (a[1] === b[1] || mesmoDia2(a[1], b[1]));
1305
1336
  function CamposDoPeriodo({