@orianatech/pire 0.7.0 → 0.8.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
@@ -813,6 +813,7 @@ var enMessages = {
813
813
  toastDismiss: "Dismiss",
814
814
  toastRegionLabel: "Notifications",
815
815
  comboBoxShowSuggestions: "Show suggestions",
816
+ comboBoxLoading: "Searching\u2026",
816
817
  datePickerOpenCalendar: "Open calendar",
817
818
  datePickerPreviousMonth: "Previous month",
818
819
  datePickerNextMonth: "Next month",
@@ -844,6 +845,7 @@ var esMessages = {
844
845
  toastDismiss: "Descartar",
845
846
  toastRegionLabel: "Notificaciones",
846
847
  comboBoxShowSuggestions: "Mostrar sugerencias",
848
+ comboBoxLoading: "Buscando\u2026",
847
849
  datePickerOpenCalendar: "Abrir calendario",
848
850
  datePickerPreviousMonth: "Mes anterior",
849
851
  datePickerNextMonth: "Mes siguiente",
@@ -895,12 +897,19 @@ function ComboBox({
895
897
  errorMessage,
896
898
  size = "md",
897
899
  fullWidth = true,
900
+ isFilteredExternally,
901
+ isLoading,
902
+ loadingLabel,
903
+ emptyLabel,
904
+ onLoadMore,
898
905
  className,
899
906
  style,
900
907
  ...rest
901
908
  }) {
902
909
  const msg = usePireMessages();
903
910
  const items = options.map(norm2);
911
+ const collection = isFilteredExternally ? { items } : { defaultItems: items };
912
+ const showsStatus = isLoading || isFilteredExternally && items.length === 0 && emptyLabel != null;
904
913
  return /* @__PURE__ */ jsxs16(
905
914
  AriaComboBox,
906
915
  {
@@ -908,9 +917,13 @@ function ComboBox({
908
917
  style,
909
918
  selectedKey: value,
910
919
  defaultSelectedKey: defaultValue,
911
- onSelectionChange: (k) => onChange?.(k == null ? null : String(k)),
920
+ onSelectionChange: (k) => {
921
+ if (isLoading) return;
922
+ onChange?.(k == null ? null : String(k));
923
+ },
912
924
  onInputChange,
913
- defaultItems: items,
925
+ ...collection,
926
+ allowsEmptyCollection: isFilteredExternally || isLoading,
914
927
  menuTrigger: "input",
915
928
  validationBehavior: "aria",
916
929
  ...rest,
@@ -935,10 +948,21 @@ function ComboBox({
935
948
  ),
936
949
  description ? /* @__PURE__ */ jsx22(Text6, { slot: "description", className: "pire-field-hint", children: description }) : null,
937
950
  /* @__PURE__ */ jsx22(FieldError5, { className: "pire-field-error", children: errorMessage }),
938
- /* @__PURE__ */ jsx22(Popover2, { className: "pire-popover", children: /* @__PURE__ */ jsx22(ListBox2, { className: "pire-listbox", children: (item) => /* @__PURE__ */ jsxs16(ListBoxItem2, { className: "pire-option", id: item.value, textValue: item.label, isDisabled: item.isDisabled, children: [
939
- /* @__PURE__ */ jsx22("span", { style: { flex: 1 }, children: item.label }),
940
- item.secondary ? /* @__PURE__ */ jsx22("span", { style: { font: "var(--type-code)", color: "var(--text-tertiary)" }, children: item.secondary }) : null
941
- ] }) }) })
951
+ /* @__PURE__ */ jsx22(Popover2, { className: "pire-popover", children: /* @__PURE__ */ jsx22(
952
+ ListBox2,
953
+ {
954
+ className: "pire-listbox",
955
+ onScroll: onLoadMore ? (e) => {
956
+ const el = e.currentTarget;
957
+ if (el.scrollHeight - el.scrollTop - el.clientHeight < 48) onLoadMore();
958
+ } : void 0,
959
+ renderEmptyState: showsStatus ? () => /* @__PURE__ */ jsx22("div", { className: "pire-listbox-status", role: "status", "aria-live": "polite", children: isLoading ? loadingLabel ?? msg.comboBoxLoading : emptyLabel }) : void 0,
960
+ children: (item) => /* @__PURE__ */ jsxs16(ListBoxItem2, { className: "pire-option", id: item.value, textValue: item.label, isDisabled: item.isDisabled, children: [
961
+ /* @__PURE__ */ jsx22("span", { className: "pire-option-label", children: item.label }),
962
+ item.secondary ? /* @__PURE__ */ jsx22("span", { className: "pire-option-secondary", children: item.secondary }) : null
963
+ ] })
964
+ }
965
+ ) })
942
966
  ]
943
967
  }
944
968
  );
@@ -973,6 +997,11 @@ function MultiComboBox({
973
997
  errorMessage,
974
998
  allowsCustomValue,
975
999
  size = "md",
1000
+ isFilteredExternally,
1001
+ isLoading,
1002
+ loadingLabel,
1003
+ emptyLabel,
1004
+ onLoadMore,
976
1005
  fullWidth = true,
977
1006
  className,
978
1007
  style,
@@ -980,6 +1009,8 @@ function MultiComboBox({
980
1009
  }) {
981
1010
  const msg = usePireMessages();
982
1011
  const items = React7.useMemo(() => options.map(norm3), [options]);
1012
+ const collection = isFilteredExternally ? { items } : { defaultItems: items };
1013
+ const showsStatus = isLoading || isFilteredExternally && items.length === 0 && emptyLabel != null;
983
1014
  const [uncontrolled, setUncontrolled] = React7.useState(defaultValue ?? []);
984
1015
  const [announcement, setAnnouncement] = React7.useState("");
985
1016
  const inputRef = React7.useRef(null);
@@ -1025,9 +1056,12 @@ function MultiComboBox({
1025
1056
  style,
1026
1057
  selectionMode: "multiple",
1027
1058
  value: values,
1028
- onChange: (keys) => commit(keys.map(String)),
1059
+ onChange: (keys) => {
1060
+ if (!isLoading) commit(keys.map(String));
1061
+ },
1029
1062
  onInputChange,
1030
- defaultItems: items,
1063
+ ...collection,
1064
+ allowsEmptyCollection: isFilteredExternally || isLoading,
1031
1065
  menuTrigger: "input",
1032
1066
  validationBehavior: "aria",
1033
1067
  ...rest,
@@ -1070,10 +1104,21 @@ function MultiComboBox({
1070
1104
  /* @__PURE__ */ jsx23(VisuallyHidden, { children: /* @__PURE__ */ jsx23("span", { "aria-live": "polite", children: announcement }) }),
1071
1105
  description ? /* @__PURE__ */ jsx23(Text7, { slot: "description", className: "pire-field-hint", children: description }) : null,
1072
1106
  /* @__PURE__ */ jsx23(FieldError6, { className: "pire-field-error", children: errorMessage }),
1073
- /* @__PURE__ */ jsx23(Popover3, { className: "pire-popover", children: /* @__PURE__ */ jsx23(ListBox3, { className: "pire-listbox", children: (item) => /* @__PURE__ */ jsxs17(ListBoxItem3, { className: "pire-option", id: item.value, textValue: item.label, isDisabled: item.isDisabled, children: [
1074
- /* @__PURE__ */ jsx23("span", { style: { flex: 1 }, children: item.label }),
1075
- item.secondary ? /* @__PURE__ */ jsx23("span", { style: { font: "var(--type-code)", color: "var(--text-tertiary)" }, children: item.secondary }) : null
1076
- ] }) }) })
1107
+ /* @__PURE__ */ jsx23(Popover3, { className: "pire-popover", children: /* @__PURE__ */ jsx23(
1108
+ ListBox3,
1109
+ {
1110
+ className: "pire-listbox",
1111
+ onScroll: onLoadMore ? (e) => {
1112
+ const el = e.currentTarget;
1113
+ if (el.scrollHeight - el.scrollTop - el.clientHeight < 48) onLoadMore();
1114
+ } : void 0,
1115
+ renderEmptyState: showsStatus ? () => /* @__PURE__ */ jsx23("div", { className: "pire-listbox-status", role: "status", "aria-live": "polite", children: isLoading ? loadingLabel ?? msg.comboBoxLoading : emptyLabel }) : void 0,
1116
+ children: (item) => /* @__PURE__ */ jsxs17(ListBoxItem3, { className: "pire-option", id: item.value, textValue: item.label, isDisabled: item.isDisabled, children: [
1117
+ /* @__PURE__ */ jsx23("span", { className: "pire-option-label", children: item.label }),
1118
+ item.secondary ? /* @__PURE__ */ jsx23("span", { className: "pire-option-secondary", children: item.secondary }) : null
1119
+ ] })
1120
+ }
1121
+ ) })
1077
1122
  ]
1078
1123
  }
1079
1124
  );