@jirawatpyk/aura-react 4.8.0 → 4.9.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.
@@ -60,17 +60,20 @@ __export(index_exports, {
60
60
  Icon: () => Icon,
61
61
  IconButton: () => IconButton,
62
62
  Menu: () => Menu,
63
+ NumberField: () => NumberField,
63
64
  Pagination: () => Pagination,
64
65
  Popover: () => Popover,
65
66
  Progress: () => Progress,
66
67
  RadioGroup: () => RadioGroup,
67
68
  STRINGS: () => STRINGS,
69
+ SegmentedControl: () => SegmentedControl,
68
70
  Select: () => Select,
69
71
  SideNav: () => SideNav,
70
72
  Skeleton: () => Skeleton,
71
73
  Stack: () => Stack,
72
74
  Stat: () => Stat,
73
75
  StatusPill: () => StatusPill,
76
+ Stepper: () => Stepper,
74
77
  Surface: () => Surface,
75
78
  Switch: () => Switch,
76
79
  Tabs: () => Tabs,
@@ -606,6 +609,12 @@ var STRINGS = {
606
609
  return "Up to " + n2 + " files";
607
610
  },
608
611
  colorScheme: "Colour scheme",
612
+ increase: "Increase",
613
+ decrease: "Decrease",
614
+ stepDone: "completed",
615
+ stepOf: function(i, total) {
616
+ return "Step " + i + " of " + total;
617
+ },
609
618
  schemeLight: "Light",
610
619
  schemeDark: "Dark",
611
620
  schemeSystem: "System",
@@ -698,6 +707,12 @@ var STRINGS = {
698
707
  return "\u0E41\u0E19\u0E1A\u0E44\u0E14\u0E49\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19 " + n2 + " \u0E44\u0E1F\u0E25\u0E4C";
699
708
  },
700
709
  colorScheme: "\u0E42\u0E2B\u0E21\u0E14\u0E2A\u0E35",
710
+ increase: "\u0E40\u0E1E\u0E34\u0E48\u0E21",
711
+ decrease: "\u0E25\u0E14",
712
+ stepDone: "\u0E40\u0E2A\u0E23\u0E47\u0E08\u0E41\u0E25\u0E49\u0E27",
713
+ stepOf: function(i, total) {
714
+ return "\u0E02\u0E31\u0E49\u0E19\u0E17\u0E35\u0E48 " + i + " \u0E08\u0E32\u0E01 " + total;
715
+ },
701
716
  schemeLight: "\u0E2A\u0E27\u0E48\u0E32\u0E07",
702
717
  schemeDark: "\u0E21\u0E37\u0E14",
703
718
  schemeSystem: "\u0E15\u0E32\u0E21\u0E23\u0E30\u0E1A\u0E1A",
@@ -967,257 +982,332 @@ function defaultFilter(option, query) {
967
982
  return norm(k).indexOf(q) >= 0;
968
983
  });
969
984
  }
970
- var Combobox = React16.forwardRef(function Combobox2(props, ref) {
971
- const t = useStrings();
972
- const auto = uid(), id = props.id || auto, listId = id + "-list";
973
- const options = (props.options || []).map(toOpt);
974
- const st = useMaybeControlled(
975
- props.value,
976
- props.defaultValue == null ? null : props.defaultValue,
977
- props.onChange
978
- );
979
- const value = st[0], setValue = st[1];
980
- const selected = options.filter(function(o) {
981
- return o.value === value;
982
- })[0] || null;
983
- const openState = React16.useState(false), open = openState[0], setOpen = openState[1];
984
- const qState = React16.useState(null), query = qState[0], setQuery = qState[1];
985
- const aState = React16.useState(0), active = aState[0], setActive = aState[1];
986
- const posState = React16.useState(null);
987
- const inputRef = React16.useRef(null), inputMerged = useMergedRef(ref, inputRef), boxRef = React16.useRef(null), listRef = React16.useRef(null);
988
- const mounted = useMounted();
989
- const limit = props.limit || 200;
990
- const filter = props.filter || defaultFilter;
991
- let shown = props.onSearch || query == null ? options : options.filter(function(o) {
992
- return filter(o, query);
993
- });
994
- const more = shown.length > limit;
995
- shown = shown.slice(0, limit);
996
- const activeIdx = Math.min(active, shown.length - 1);
997
- function place() {
998
- if (!boxRef.current) return;
999
- const r = boxRef.current.getBoundingClientRect();
1000
- const maxH = 320, below = window.innerHeight - r.bottom - 8, up = below < 200 && r.top > below;
1001
- posState[1]({
1002
- left: r.left,
1003
- width: r.width,
1004
- top: up ? void 0 : r.bottom + 4,
1005
- bottom: up ? window.innerHeight - r.top + 4 : void 0,
1006
- maxHeight: Math.min(maxH, (up ? r.top : below) - 8)
985
+ var Combobox = React16.forwardRef(
986
+ function Combobox2(all, ref) {
987
+ const props = all;
988
+ const multi = all.multiple === true;
989
+ const mp = all;
990
+ const t = useStrings();
991
+ const auto = uid(), id = props.id || auto, listId = id + "-list";
992
+ const options = (props.options || []).map(toOpt);
993
+ const st = useMaybeControlled(
994
+ multi ? mp.value : props.value === void 0 ? void 0 : props.value == null ? [] : [props.value],
995
+ multi ? mp.defaultValue || [] : props.defaultValue == null ? [] : [props.defaultValue],
996
+ function(next) {
997
+ if (multi) {
998
+ if (mp.onChange) mp.onChange(next);
999
+ } else if (props.onChange) props.onChange(next.length ? next[0] : null);
1000
+ }
1001
+ );
1002
+ const values = st[0], setValues = st[1];
1003
+ const value = values.length ? values[0] : null;
1004
+ function setValue(v) {
1005
+ setValues(v == null ? [] : [v]);
1006
+ }
1007
+ const isPicked = function(v) {
1008
+ return values.indexOf(v) >= 0;
1009
+ };
1010
+ const full = multi && mp.max != null && values.length >= mp.max;
1011
+ const selected = multi ? null : options.filter(function(o) {
1012
+ return o.value === value;
1013
+ })[0] || null;
1014
+ const picked = multi ? values.map(function(v) {
1015
+ return options.filter(function(o) {
1016
+ return o.value === v;
1017
+ })[0];
1018
+ }).filter(Boolean) : [];
1019
+ const openState = React16.useState(false), open = openState[0], setOpen = openState[1];
1020
+ const qState = React16.useState(null), query = qState[0], setQuery = qState[1];
1021
+ const aState = React16.useState(0), active = aState[0], setActive = aState[1];
1022
+ const posState = React16.useState(null);
1023
+ const inputRef = React16.useRef(null), inputMerged = useMergedRef(ref, inputRef), boxRef = React16.useRef(null), listRef = React16.useRef(null);
1024
+ const mounted = useMounted();
1025
+ const limit = props.limit || 200;
1026
+ const filter = props.filter || defaultFilter;
1027
+ let shown = props.onSearch || query == null ? options : options.filter(function(o) {
1028
+ return filter(o, query);
1007
1029
  });
1008
- }
1009
- useIsoLayoutEffect(
1010
- function() {
1011
- if (open) place();
1012
- },
1013
- [open, shown.length]
1014
- );
1015
- React16.useEffect(
1016
- function() {
1017
- if (!open) return;
1018
- function outside(e) {
1019
- if (boxRef.current && boxRef.current.contains(e.target)) return;
1020
- if (listRef.current && listRef.current.contains(e.target)) return;
1021
- close(false);
1030
+ const more = shown.length > limit;
1031
+ shown = shown.slice(0, limit);
1032
+ const activeIdx = Math.min(active, shown.length - 1);
1033
+ function place() {
1034
+ if (!boxRef.current) return;
1035
+ const r = boxRef.current.getBoundingClientRect();
1036
+ const maxH = 320, below = window.innerHeight - r.bottom - 8, up = below < 200 && r.top > below;
1037
+ posState[1]({
1038
+ left: r.left,
1039
+ width: r.width,
1040
+ top: up ? void 0 : r.bottom + 4,
1041
+ bottom: up ? window.innerHeight - r.top + 4 : void 0,
1042
+ maxHeight: Math.min(maxH, (up ? r.top : below) - 8)
1043
+ });
1044
+ }
1045
+ useIsoLayoutEffect(
1046
+ function() {
1047
+ if (open) place();
1048
+ },
1049
+ [open, shown.length]
1050
+ );
1051
+ React16.useEffect(
1052
+ function() {
1053
+ if (!open) return;
1054
+ function outside(e) {
1055
+ if (boxRef.current && boxRef.current.contains(e.target)) return;
1056
+ if (listRef.current && listRef.current.contains(e.target)) return;
1057
+ close(false);
1058
+ }
1059
+ function onScroll(e) {
1060
+ if (!listRef.current || !listRef.current.contains(e.target)) place();
1061
+ }
1062
+ document.addEventListener("pointerdown", outside, true);
1063
+ window.addEventListener("scroll", onScroll, true);
1064
+ window.addEventListener("resize", place);
1065
+ return function() {
1066
+ document.removeEventListener("pointerdown", outside, true);
1067
+ window.removeEventListener("scroll", onScroll, true);
1068
+ window.removeEventListener("resize", place);
1069
+ };
1070
+ },
1071
+ [open]
1072
+ );
1073
+ React16.useEffect(
1074
+ function() {
1075
+ if (!open || !listRef.current) return;
1076
+ const el = listRef.current.querySelector('[data-idx="' + activeIdx + '"]');
1077
+ if (el && el.scrollIntoView) el.scrollIntoView({ block: "nearest" });
1078
+ },
1079
+ [activeIdx, open]
1080
+ );
1081
+ function openList() {
1082
+ if (!open && !props.disabled && !props.readOnly) {
1083
+ setOpen(true);
1084
+ const i = selected ? shown.indexOf(selected) : 0;
1085
+ setActive(i < 0 ? 0 : i);
1022
1086
  }
1023
- function onScroll(e) {
1024
- if (!listRef.current || !listRef.current.contains(e.target)) place();
1087
+ }
1088
+ function close(restoreLabel) {
1089
+ setOpen(false);
1090
+ setQuery(null);
1091
+ }
1092
+ function choose(o) {
1093
+ if (!o || o.disabled) return;
1094
+ if (multi) {
1095
+ if (isPicked(o.value))
1096
+ setValues(
1097
+ values.filter(function(v) {
1098
+ return v !== o.value;
1099
+ })
1100
+ );
1101
+ else if (!full) setValues(values.concat([o.value]));
1102
+ setQuery(null);
1103
+ if (inputRef.current) inputRef.current.focus();
1104
+ return;
1025
1105
  }
1026
- document.addEventListener("pointerdown", outside, true);
1027
- window.addEventListener("scroll", onScroll, true);
1028
- window.addEventListener("resize", place);
1029
- return function() {
1030
- document.removeEventListener("pointerdown", outside, true);
1031
- window.removeEventListener("scroll", onScroll, true);
1032
- window.removeEventListener("resize", place);
1033
- };
1034
- },
1035
- [open]
1036
- );
1037
- React16.useEffect(
1038
- function() {
1039
- if (!open || !listRef.current) return;
1040
- const el = listRef.current.querySelector('[data-idx="' + activeIdx + '"]');
1041
- if (el && el.scrollIntoView) el.scrollIntoView({ block: "nearest" });
1042
- },
1043
- [activeIdx, open]
1044
- );
1045
- function openList() {
1046
- if (!open && !props.disabled && !props.readOnly) {
1047
- setOpen(true);
1048
- const i = selected ? shown.indexOf(selected) : 0;
1049
- setActive(i < 0 ? 0 : i);
1106
+ setValue(o.value);
1107
+ setQuery(null);
1108
+ setOpen(false);
1109
+ if (inputRef.current) inputRef.current.focus();
1050
1110
  }
1051
- }
1052
- function close(restoreLabel) {
1053
- setOpen(false);
1054
- setQuery(null);
1055
- }
1056
- function choose(o) {
1057
- if (!o || o.disabled) return;
1058
- setValue(o.value);
1059
- setQuery(null);
1060
- setOpen(false);
1061
- if (inputRef.current) inputRef.current.focus();
1062
- }
1063
- function onKeyDown(e) {
1064
- const k = e.key;
1065
- if (k === "ArrowDown") {
1066
- e.preventDefault();
1067
- if (!open) openList();
1068
- else setActive(Math.min(activeIdx + 1, shown.length - 1));
1069
- } else if (k === "ArrowUp") {
1070
- e.preventDefault();
1071
- if (!open) openList();
1072
- else setActive(Math.max(activeIdx - 1, 0));
1073
- } else if (k === "Home" && open) {
1074
- e.preventDefault();
1075
- setActive(0);
1076
- } else if (k === "End" && open) {
1077
- e.preventDefault();
1078
- setActive(shown.length - 1);
1079
- } else if (k === "Enter") {
1080
- if (open && shown[activeIdx]) {
1111
+ function onKeyDown(e) {
1112
+ const k = e.key;
1113
+ if (k === "ArrowDown") {
1081
1114
  e.preventDefault();
1082
- choose(shown[activeIdx]);
1083
- }
1084
- } else if (k === "Escape") {
1085
- if (open) {
1115
+ if (!open) openList();
1116
+ else setActive(Math.min(activeIdx + 1, shown.length - 1));
1117
+ } else if (k === "ArrowUp") {
1086
1118
  e.preventDefault();
1087
- e.stopPropagation();
1088
- close();
1089
- } else if (props.clearable !== false && value != null && query == null) {
1090
- setValue(null);
1119
+ if (!open) openList();
1120
+ else setActive(Math.max(activeIdx - 1, 0));
1121
+ } else if (k === "Home" && open) {
1122
+ e.preventDefault();
1123
+ setActive(0);
1124
+ } else if (k === "End" && open) {
1125
+ e.preventDefault();
1126
+ setActive(shown.length - 1);
1127
+ } else if (k === "Enter") {
1128
+ if (open && shown[activeIdx]) {
1129
+ e.preventDefault();
1130
+ choose(shown[activeIdx]);
1131
+ }
1132
+ } else if (k === "Escape") {
1133
+ if (open) {
1134
+ e.preventDefault();
1135
+ e.stopPropagation();
1136
+ close();
1137
+ } else if (!multi && props.clearable !== false && value != null && query == null) {
1138
+ setValue(null);
1139
+ }
1140
+ } else if (k === "Backspace" && multi && !text && values.length) {
1141
+ setValues(values.slice(0, -1));
1142
+ } else if (k === "Tab") {
1143
+ if (open) close();
1091
1144
  }
1092
- } else if (k === "Tab") {
1093
- if (open) close();
1094
1145
  }
1095
- }
1096
- const text = query != null ? query : selected ? selected.label : "";
1097
- const optId = function(i) {
1098
- return id + "-opt-" + i;
1099
- };
1100
- const list = open && mounted && posState[0] ? (0, import_react_dom2.createPortal)(
1101
- /* @__PURE__ */ React16.createElement("div", { ref: listRef, className: "aura-combo__popover", style: posState[0] }, /* @__PURE__ */ React16.createElement("ul", { id: listId, role: "listbox", "aria-label": props.label, className: "aura-combo__list" }, props.loading ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, /* @__PURE__ */ React16.createElement(Icon, { name: "loader-circle", className: "aura-spin" }), props.loadingText || t.searching) : !shown.length ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, props.emptyText || t.noMatches) : shown.map(function(o, i) {
1102
- const isSel = selected && o.value === selected.value;
1103
- return /* @__PURE__ */ React16.createElement(
1104
- "li",
1146
+ const text = query != null ? query : selected ? selected.label : "";
1147
+ const summaryId = id + "-picked";
1148
+ const optId = function(i) {
1149
+ return id + "-opt-" + i;
1150
+ };
1151
+ const list = open && mounted && posState[0] ? (0, import_react_dom2.createPortal)(
1152
+ /* @__PURE__ */ React16.createElement("div", { ref: listRef, className: "aura-combo__popover", style: posState[0] }, /* @__PURE__ */ React16.createElement(
1153
+ "ul",
1105
1154
  {
1106
- key: o.value,
1107
- id: optId(i),
1108
- role: "option",
1109
- "data-idx": i,
1110
- "aria-selected": isSel,
1111
- "aria-disabled": o.disabled || void 0,
1112
- className: cx(
1113
- "aura-combo__option",
1114
- i === activeIdx && "is-active",
1115
- isSel && "is-selected",
1116
- o.disabled && "is-disabled"
1117
- ),
1118
- onPointerDown: function(e) {
1119
- e.preventDefault();
1120
- },
1121
- onClick: function() {
1122
- choose(o);
1123
- },
1124
- onPointerMove: function() {
1125
- if (activeIdx !== i) setActive(i);
1126
- }
1155
+ id: listId,
1156
+ role: "listbox",
1157
+ "aria-label": props.label,
1158
+ "aria-multiselectable": multi || void 0,
1159
+ className: "aura-combo__list"
1127
1160
  },
1128
- o.icon ? /* @__PURE__ */ React16.createElement(Icon, { name: o.icon }) : null,
1129
- /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__text" }, /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__label" }, o.label), o.description ? /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__desc" }, o.description) : null),
1130
- isSel ? /* @__PURE__ */ React16.createElement(Icon, { name: "check", className: "aura-combo__check" }) : null
1131
- );
1132
- }), more && !props.loading ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, t.keepTyping((props.options || []).length)) : null)),
1133
- document.body
1134
- ) : null;
1135
- return /* @__PURE__ */ React16.createElement(
1136
- Field,
1137
- {
1138
- id,
1139
- label: props.label,
1140
- hint: props.hint,
1141
- error: props.error,
1142
- required: props.required,
1143
- optional: props.optional,
1144
- disabled: props.disabled,
1145
- className: props.className
1146
- },
1147
- /* @__PURE__ */ React16.createElement("div", { ref: boxRef, className: cx("aura-input aura-combo has-icon", open && "is-open") }, /* @__PURE__ */ React16.createElement(Icon, { name: props.icon || "search", className: "aura-input__icon" }), /* @__PURE__ */ React16.createElement(
1148
- "input",
1161
+ props.loading ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, /* @__PURE__ */ React16.createElement(Icon, { name: "loader-circle", className: "aura-spin" }), props.loadingText || t.searching) : !shown.length ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, props.emptyText || t.noMatches) : shown.map(function(o, i) {
1162
+ const isSel = multi ? isPicked(o.value) : !!selected && o.value === selected.value;
1163
+ const blocked = o.disabled || multi && full && !isSel;
1164
+ return /* @__PURE__ */ React16.createElement(
1165
+ "li",
1166
+ {
1167
+ key: o.value,
1168
+ id: optId(i),
1169
+ role: "option",
1170
+ "data-idx": i,
1171
+ "aria-selected": isSel,
1172
+ "aria-disabled": blocked || void 0,
1173
+ className: cx(
1174
+ "aura-combo__option",
1175
+ i === activeIdx && "is-active",
1176
+ isSel && "is-selected",
1177
+ blocked && "is-disabled"
1178
+ ),
1179
+ onPointerDown: function(e) {
1180
+ e.preventDefault();
1181
+ },
1182
+ onClick: function() {
1183
+ if (!blocked || isSel) choose(o);
1184
+ },
1185
+ onPointerMove: function() {
1186
+ if (activeIdx !== i) setActive(i);
1187
+ }
1188
+ },
1189
+ o.icon ? /* @__PURE__ */ React16.createElement(Icon, { name: o.icon }) : null,
1190
+ /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__text" }, /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__label" }, o.label), o.description ? /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__desc" }, o.description) : null),
1191
+ isSel ? /* @__PURE__ */ React16.createElement(Icon, { name: "check", className: "aura-combo__check" }) : null
1192
+ );
1193
+ }),
1194
+ more && !props.loading ? /* @__PURE__ */ React16.createElement("li", { className: "aura-combo__note", role: "presentation" }, t.keepTyping((props.options || []).length)) : null
1195
+ )),
1196
+ document.body
1197
+ ) : null;
1198
+ return /* @__PURE__ */ React16.createElement(
1199
+ Field,
1149
1200
  {
1150
- ref: inputMerged,
1151
1201
  id,
1152
- type: "text",
1153
- role: "combobox",
1154
- className: "aura-input__control",
1155
- autoComplete: "off",
1156
- "aria-expanded": open,
1157
- "aria-controls": listId,
1158
- "aria-autocomplete": "list",
1159
- "aria-activedescendant": open && shown[activeIdx] ? optId(activeIdx) : void 0,
1160
- "aria-invalid": props.error ? true : void 0,
1161
- "aria-describedby": props.error ? id + "-error" : props.hint ? id + "-hint" : void 0,
1162
- placeholder: props.placeholder,
1163
- disabled: props.disabled,
1164
- readOnly: props.readOnly,
1202
+ label: props.label,
1203
+ hint: props.hint,
1204
+ error: props.error,
1165
1205
  required: props.required,
1166
- name: props.name,
1167
- value: text,
1168
- onChange: function(e) {
1169
- setQuery(e.target.value);
1170
- setActive(0);
1171
- if (!open) setOpen(true);
1172
- if (props.onSearch) props.onSearch(e.target.value);
1173
- },
1174
- onClick: openList,
1175
- onKeyDown,
1176
- onBlur: function() {
1177
- setTimeout(function() {
1178
- if (listRef.current && listRef.current.contains(document.activeElement)) return;
1179
- setOpen(false);
1180
- setQuery(null);
1181
- }, 0);
1182
- }
1183
- }
1184
- ), props.clearable !== false && value != null && !props.disabled ? /* @__PURE__ */ React16.createElement(
1185
- "button",
1186
- {
1187
- type: "button",
1188
- className: "aura-combo__clear",
1189
- "aria-label": t.clear(props.label),
1190
- tabIndex: -1,
1191
- onClick: function() {
1192
- setValue(null);
1193
- setQuery(null);
1194
- if (inputRef.current) inputRef.current.focus();
1195
- }
1206
+ optional: props.optional,
1207
+ disabled: props.disabled,
1208
+ className: props.className
1196
1209
  },
1197
- /* @__PURE__ */ React16.createElement(Icon, { name: "x" })
1198
- ) : null, /* @__PURE__ */ React16.createElement(
1199
- "button",
1200
- {
1201
- type: "button",
1202
- tabIndex: -1,
1203
- "aria-hidden": true,
1204
- className: "aura-combo__toggle",
1205
- onPointerDown: function(e) {
1206
- e.preventDefault();
1207
- },
1208
- onClick: function() {
1209
- if (open) close();
1210
- else {
1211
- openList();
1212
- inputRef.current && inputRef.current.focus();
1210
+ /* @__PURE__ */ React16.createElement("div", { ref: boxRef, className: cx("aura-input aura-combo has-icon", open && "is-open", multi && "is-multi") }, /* @__PURE__ */ React16.createElement(Icon, { name: props.icon || "search", className: "aura-input__icon" }), multi && picked.length ? /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__chips" }, picked.map(function(o) {
1211
+ return /* @__PURE__ */ React16.createElement("span", { key: o.value, className: "aura-combo__chip" }, /* @__PURE__ */ React16.createElement("span", { className: "aura-combo__chip-label" }, o.label), props.disabled || props.readOnly ? null : /* @__PURE__ */ React16.createElement(
1212
+ "button",
1213
+ {
1214
+ type: "button",
1215
+ tabIndex: -1,
1216
+ className: "aura-combo__chip-remove",
1217
+ "aria-label": t.remove(o.label),
1218
+ onPointerDown: function(e) {
1219
+ e.preventDefault();
1220
+ },
1221
+ onClick: function() {
1222
+ setValues(
1223
+ values.filter(function(v) {
1224
+ return v !== o.value;
1225
+ })
1226
+ );
1227
+ if (inputRef.current) inputRef.current.focus();
1228
+ }
1229
+ },
1230
+ /* @__PURE__ */ React16.createElement(Icon, { name: "x" })
1231
+ ));
1232
+ })) : null, multi ? /* @__PURE__ */ React16.createElement("span", { id: summaryId, className: "aura-sr-only" }, picked.length ? t.selectedCount(picked.length) + ": " + picked.map(function(o) {
1233
+ return o.label;
1234
+ }).join(", ") : "") : null, multi && props.name ? values.map(function(v) {
1235
+ return /* @__PURE__ */ React16.createElement("input", { key: v, type: "hidden", name: props.name, value: v });
1236
+ }) : null, /* @__PURE__ */ React16.createElement(
1237
+ "input",
1238
+ {
1239
+ ref: inputMerged,
1240
+ id,
1241
+ type: "text",
1242
+ role: "combobox",
1243
+ className: "aura-input__control",
1244
+ autoComplete: "off",
1245
+ "aria-expanded": open,
1246
+ "aria-controls": listId,
1247
+ "aria-autocomplete": "list",
1248
+ "aria-activedescendant": open && shown[activeIdx] ? optId(activeIdx) : void 0,
1249
+ "aria-invalid": props.error ? true : void 0,
1250
+ "aria-describedby": [props.error ? id + "-error" : props.hint ? id + "-hint" : "", multi && picked.length ? summaryId : ""].filter(Boolean).join(" ") || void 0,
1251
+ placeholder: multi && values.length ? void 0 : props.placeholder,
1252
+ disabled: props.disabled,
1253
+ readOnly: props.readOnly,
1254
+ required: props.required && (!multi || !values.length),
1255
+ name: multi ? void 0 : props.name,
1256
+ value: text,
1257
+ onChange: function(e) {
1258
+ setQuery(e.target.value);
1259
+ setActive(0);
1260
+ if (!open) setOpen(true);
1261
+ if (props.onSearch) props.onSearch(e.target.value);
1262
+ },
1263
+ onClick: openList,
1264
+ onKeyDown,
1265
+ onBlur: function() {
1266
+ setTimeout(function() {
1267
+ if (listRef.current && listRef.current.contains(document.activeElement)) return;
1268
+ setOpen(false);
1269
+ setQuery(null);
1270
+ }, 0);
1213
1271
  }
1214
1272
  }
1215
- },
1216
- /* @__PURE__ */ React16.createElement(Icon, { name: "chevron-down" })
1217
- )),
1218
- list
1219
- );
1220
- });
1273
+ ), props.clearable !== false && values.length && !props.disabled ? /* @__PURE__ */ React16.createElement(
1274
+ "button",
1275
+ {
1276
+ type: "button",
1277
+ className: "aura-combo__clear",
1278
+ "aria-label": t.clear(props.label),
1279
+ tabIndex: -1,
1280
+ onClick: function() {
1281
+ setValues([]);
1282
+ setQuery(null);
1283
+ if (inputRef.current) inputRef.current.focus();
1284
+ }
1285
+ },
1286
+ /* @__PURE__ */ React16.createElement(Icon, { name: "x" })
1287
+ ) : null, /* @__PURE__ */ React16.createElement(
1288
+ "button",
1289
+ {
1290
+ type: "button",
1291
+ tabIndex: -1,
1292
+ "aria-hidden": true,
1293
+ className: "aura-combo__toggle",
1294
+ onPointerDown: function(e) {
1295
+ e.preventDefault();
1296
+ },
1297
+ onClick: function() {
1298
+ if (open) close();
1299
+ else {
1300
+ openList();
1301
+ inputRef.current && inputRef.current.focus();
1302
+ }
1303
+ }
1304
+ },
1305
+ /* @__PURE__ */ React16.createElement(Icon, { name: "chevron-down" })
1306
+ )),
1307
+ list
1308
+ );
1309
+ }
1310
+ );
1221
1311
 
1222
1312
  // src/DatePicker.tsx
1223
1313
  var React17 = __toESM(require("react"), 1);
@@ -4784,3 +4874,321 @@ var Popover = React47.forwardRef(function Popover2(props, ref) {
4784
4874
  "aria-controls": open ? id : void 0
4785
4875
  }), panel);
4786
4876
  });
4877
+
4878
+ // src/NumberField.tsx
4879
+ var React48 = __toESM(require("react"), 1);
4880
+ function decimalsOf(n2) {
4881
+ const s = String(n2);
4882
+ const i = s.indexOf(".");
4883
+ return i < 0 ? 0 : s.length - i - 1;
4884
+ }
4885
+ function parse(text) {
4886
+ const s = text.replace(/[,\s ]/g, "");
4887
+ if (!/^-?(\d+\.?\d*|\.\d+)$/.test(s)) return NaN;
4888
+ return Number(s);
4889
+ }
4890
+ var NumberField = React48.forwardRef(function NumberField2(props, ref) {
4891
+ const t = useStrings();
4892
+ const auto = uid(), id = props.id || auto;
4893
+ const step = props.step || 1;
4894
+ const decimals = props.decimals != null ? props.decimals : decimalsOf(step);
4895
+ const st = useMaybeControlled(
4896
+ props.value,
4897
+ props.defaultValue == null ? null : props.defaultValue,
4898
+ props.onChange
4899
+ );
4900
+ const value = st[0], setValue = st[1];
4901
+ const draftState = React48.useState(null), draft = draftState[0], setDraft = draftState[1];
4902
+ function fmt2(n2) {
4903
+ if (n2 == null || isNaN(n2)) return "";
4904
+ return n2.toLocaleString("en", { minimumFractionDigits: decimals, maximumFractionDigits: decimals });
4905
+ }
4906
+ function fit2(n2) {
4907
+ let v = n2;
4908
+ if (props.min != null && v < props.min) v = props.min;
4909
+ if (props.max != null && v > props.max) v = props.max;
4910
+ const f = Math.pow(10, decimals);
4911
+ return Math.round(v * f) / f;
4912
+ }
4913
+ function nudge(by) {
4914
+ if (props.disabled || props.readOnly) return;
4915
+ const base = value == null ? props.min != null && props.min > 0 ? props.min - by : 0 : value;
4916
+ const next = fit2(base + by);
4917
+ setValue(next);
4918
+ setDraft(null);
4919
+ }
4920
+ function onKeyDown(e) {
4921
+ const k = e.key;
4922
+ let by = 0;
4923
+ if (k === "ArrowUp") by = step;
4924
+ else if (k === "ArrowDown") by = -step;
4925
+ else if (k === "PageUp") by = step * 10;
4926
+ else if (k === "PageDown") by = -step * 10;
4927
+ else if (k === "Home" && props.min != null) {
4928
+ e.preventDefault();
4929
+ setValue(props.min);
4930
+ setDraft(null);
4931
+ return;
4932
+ } else if (k === "End" && props.max != null) {
4933
+ e.preventDefault();
4934
+ setValue(props.max);
4935
+ setDraft(null);
4936
+ return;
4937
+ }
4938
+ if (by) {
4939
+ e.preventDefault();
4940
+ nudge(by);
4941
+ }
4942
+ }
4943
+ const atMin = value != null && props.min != null && value <= props.min;
4944
+ const atMax = value != null && props.max != null && value >= props.max;
4945
+ const affixText = function(x) {
4946
+ return typeof x === "string" || typeof x === "number" ? String(x) : "";
4947
+ };
4948
+ const valueText = value == null ? void 0 : [affixText(props.prefix), fmt2(value), affixText(props.suffix)].join(" ").trim();
4949
+ const stepper = props.stepper !== false && !props.readOnly;
4950
+ return /* @__PURE__ */ React48.createElement(
4951
+ Field,
4952
+ {
4953
+ id,
4954
+ label: props.label,
4955
+ hint: props.hint,
4956
+ error: props.error,
4957
+ required: props.required,
4958
+ optional: props.optional,
4959
+ disabled: props.disabled,
4960
+ className: props.className
4961
+ },
4962
+ /* @__PURE__ */ React48.createElement("div", { className: cx("aura-input aura-number", stepper && "has-stepper") }, props.prefix != null ? /* @__PURE__ */ React48.createElement("span", { className: "aura-number__affix", "aria-hidden": true }, props.prefix) : null, /* @__PURE__ */ React48.createElement(
4963
+ "input",
4964
+ {
4965
+ ref,
4966
+ id,
4967
+ type: "text",
4968
+ role: "spinbutton",
4969
+ inputMode: decimals > 0 || props.min != null && props.min < 0 ? "decimal" : "numeric",
4970
+ autoComplete: "off",
4971
+ className: "aura-input__control",
4972
+ name: props.name,
4973
+ placeholder: props.placeholder,
4974
+ disabled: props.disabled,
4975
+ readOnly: props.readOnly,
4976
+ required: props.required,
4977
+ "aria-valuenow": value == null ? void 0 : value,
4978
+ "aria-valuemin": props.min,
4979
+ "aria-valuemax": props.max,
4980
+ "aria-valuetext": valueText,
4981
+ "aria-invalid": props.error ? true : void 0,
4982
+ "aria-describedby": describedBy(id, props),
4983
+ value: draft != null ? draft : fmt2(value),
4984
+ onFocus: function() {
4985
+ setDraft(fmt2(value));
4986
+ },
4987
+ onChange: function(e) {
4988
+ const text = e.target.value;
4989
+ setDraft(text);
4990
+ if (!text.trim()) setValue(null);
4991
+ else {
4992
+ const n2 = parse(text);
4993
+ if (!isNaN(n2)) setValue(n2);
4994
+ }
4995
+ },
4996
+ onBlur: function(e) {
4997
+ const n2 = draft == null ? value : !draft.trim() ? null : parse(draft);
4998
+ if (n2 == null) {
4999
+ if (value != null) setValue(null);
5000
+ } else if (!isNaN(n2)) {
5001
+ const f = fit2(n2);
5002
+ if (f !== value) setValue(f);
5003
+ }
5004
+ setDraft(null);
5005
+ if (props.onBlur) props.onBlur(e);
5006
+ },
5007
+ onKeyDown
5008
+ }
5009
+ ), props.suffix != null ? /* @__PURE__ */ React48.createElement("span", { className: "aura-number__affix", "aria-hidden": true }, props.suffix) : null, stepper ? /* @__PURE__ */ React48.createElement("span", { className: "aura-number__steps" }, /* @__PURE__ */ React48.createElement(
5010
+ "button",
5011
+ {
5012
+ type: "button",
5013
+ tabIndex: -1,
5014
+ className: "aura-number__step",
5015
+ "aria-label": t.decrease,
5016
+ "aria-controls": id,
5017
+ disabled: props.disabled || atMin,
5018
+ onPointerDown: function(e) {
5019
+ e.preventDefault();
5020
+ },
5021
+ onClick: function() {
5022
+ nudge(-step);
5023
+ }
5024
+ },
5025
+ /* @__PURE__ */ React48.createElement(Icon, { name: "minus" })
5026
+ ), /* @__PURE__ */ React48.createElement(
5027
+ "button",
5028
+ {
5029
+ type: "button",
5030
+ tabIndex: -1,
5031
+ className: "aura-number__step",
5032
+ "aria-label": t.increase,
5033
+ "aria-controls": id,
5034
+ disabled: props.disabled || atMax,
5035
+ onPointerDown: function(e) {
5036
+ e.preventDefault();
5037
+ },
5038
+ onClick: function() {
5039
+ nudge(step);
5040
+ }
5041
+ },
5042
+ /* @__PURE__ */ React48.createElement(Icon, { name: "plus" })
5043
+ )) : null)
5044
+ );
5045
+ });
5046
+
5047
+ // src/Stepper.tsx
5048
+ var React49 = __toESM(require("react"), 1);
5049
+ var Stepper = React49.forwardRef(function Stepper2(props, ref) {
5050
+ const t = useStrings();
5051
+ const steps = props.steps || [];
5052
+ let at = -1;
5053
+ steps.forEach(function(s, i) {
5054
+ if (s.id === props.current) at = i;
5055
+ });
5056
+ if (at < 0) at = 0;
5057
+ const vertical = props.orientation === "vertical";
5058
+ const cur = steps[at];
5059
+ return /* @__PURE__ */ React49.createElement(
5060
+ "nav",
5061
+ {
5062
+ ref,
5063
+ "aria-label": props.label,
5064
+ className: cx("aura-stepper", vertical ? "aura-stepper--vertical" : "aura-stepper--horizontal", props.className)
5065
+ },
5066
+ /* @__PURE__ */ React49.createElement("ol", { className: "aura-stepper__list" }, steps.map(function(s, i) {
5067
+ const state = i < at ? "done" : i === at ? "current" : "upcoming";
5068
+ const marker = /* @__PURE__ */ React49.createElement("span", { className: "aura-stepper__marker", "aria-hidden": true }, state === "done" ? /* @__PURE__ */ React49.createElement(Icon, { name: "check" }) : i + 1);
5069
+ const text = /* @__PURE__ */ React49.createElement("span", { className: "aura-stepper__text" }, /* @__PURE__ */ React49.createElement("span", { className: "aura-stepper__label" }, s.label, state === "done" ? /* @__PURE__ */ React49.createElement("span", { className: "aura-sr-only" }, ", " + t.stepDone) : null), s.description ? /* @__PURE__ */ React49.createElement("span", { className: "aura-stepper__desc" }, s.description) : null);
5070
+ const clickable = state === "done" && !!props.onStepClick;
5071
+ return /* @__PURE__ */ React49.createElement(
5072
+ "li",
5073
+ {
5074
+ key: s.id,
5075
+ className: cx("aura-stepper__item", "is-" + state),
5076
+ "aria-current": state === "current" ? "step" : void 0
5077
+ },
5078
+ clickable ? /* @__PURE__ */ React49.createElement(
5079
+ "button",
5080
+ {
5081
+ type: "button",
5082
+ className: "aura-stepper__step aura-focusable",
5083
+ onClick: function() {
5084
+ props.onStepClick(s.id);
5085
+ }
5086
+ },
5087
+ marker,
5088
+ text
5089
+ ) : /* @__PURE__ */ React49.createElement("span", { className: "aura-stepper__step" }, marker, text)
5090
+ );
5091
+ })),
5092
+ !vertical && cur ? /* @__PURE__ */ React49.createElement("p", { className: "aura-stepper__compact", "aria-hidden": true }, /* @__PURE__ */ React49.createElement("span", { className: "aura-stepper__count" }, t.stepOf(at + 1, steps.length)), /* @__PURE__ */ React49.createElement("span", { className: "aura-stepper__compact-label" }, cur.label)) : null
5093
+ );
5094
+ });
5095
+
5096
+ // src/SegmentedControl.tsx
5097
+ var React50 = __toESM(require("react"), 1);
5098
+ function toOpt2(o) {
5099
+ return typeof o === "object" ? o : { value: o, label: o };
5100
+ }
5101
+ var SegmentedControl = React50.forwardRef(
5102
+ function SegmentedControl2(props, ref) {
5103
+ const options = (props.options || []).map(toOpt2);
5104
+ const firstEnabled = options.filter(function(o) {
5105
+ return !o.disabled;
5106
+ })[0];
5107
+ const st = useMaybeControlled(
5108
+ props.value,
5109
+ props.defaultValue != null ? props.defaultValue : firstEnabled ? firstEnabled.value : void 0,
5110
+ props.onChange
5111
+ );
5112
+ const value = st[0], setValue = st[1];
5113
+ const auto = uid(), id = props.id || auto;
5114
+ const refs = React50.useRef([]);
5115
+ const selIdx = options.findIndex(function(o) {
5116
+ return o.value === value;
5117
+ });
5118
+ const tabIdx = selIdx >= 0 && !options[selIdx].disabled ? selIdx : options.indexOf(firstEnabled);
5119
+ function move(from, dir) {
5120
+ const n2 = options.length;
5121
+ for (let k = 1; k <= n2; k++) {
5122
+ const i = ((from + dir * k) % n2 + n2) % n2;
5123
+ if (!options[i].disabled) {
5124
+ setValue(options[i].value);
5125
+ const el = refs.current[i];
5126
+ if (el) el.focus();
5127
+ return;
5128
+ }
5129
+ }
5130
+ }
5131
+ function onKeyDown(e, i) {
5132
+ const k = e.key;
5133
+ if (k === "ArrowRight" || k === "ArrowDown") {
5134
+ e.preventDefault();
5135
+ move(i, 1);
5136
+ } else if (k === "ArrowLeft" || k === "ArrowUp") {
5137
+ e.preventDefault();
5138
+ move(i, -1);
5139
+ } else if (k === "Home") {
5140
+ e.preventDefault();
5141
+ move(-1, 1);
5142
+ } else if (k === "End") {
5143
+ e.preventDefault();
5144
+ move(options.length, -1);
5145
+ }
5146
+ }
5147
+ return /* @__PURE__ */ React50.createElement(
5148
+ "div",
5149
+ {
5150
+ ref,
5151
+ id,
5152
+ role: "radiogroup",
5153
+ "aria-label": props.label,
5154
+ "aria-disabled": props.disabled || void 0,
5155
+ className: cx(
5156
+ "aura-segmented",
5157
+ props.size === "sm" && "aura-segmented--sm",
5158
+ props.fullWidth && "is-full",
5159
+ props.disabled && "is-disabled",
5160
+ props.className
5161
+ )
5162
+ },
5163
+ options.map(function(o, i) {
5164
+ const on = o.value === value;
5165
+ const off = props.disabled || o.disabled;
5166
+ return /* @__PURE__ */ React50.createElement(
5167
+ "button",
5168
+ {
5169
+ key: o.value,
5170
+ ref: function(el) {
5171
+ refs.current[i] = el;
5172
+ },
5173
+ type: "button",
5174
+ role: "radio",
5175
+ "aria-checked": on,
5176
+ "aria-label": o.iconOnly ? o.label : void 0,
5177
+ title: o.iconOnly ? o.label : void 0,
5178
+ tabIndex: i === tabIdx && !props.disabled ? 0 : -1,
5179
+ disabled: off,
5180
+ className: cx("aura-segmented__option", on && "is-selected", o.iconOnly && "is-icon"),
5181
+ onClick: function() {
5182
+ setValue(o.value);
5183
+ },
5184
+ onKeyDown: function(e) {
5185
+ onKeyDown(e, i);
5186
+ }
5187
+ },
5188
+ o.icon ? /* @__PURE__ */ React50.createElement(Icon, { name: o.icon }) : null,
5189
+ o.iconOnly ? null : /* @__PURE__ */ React50.createElement("span", null, o.label)
5190
+ );
5191
+ })
5192
+ );
5193
+ }
5194
+ );