blixify-ui-web 1.2.256 → 1.2.257

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.
@@ -133,13 +133,25 @@ exports.FILL_CLASS = {
133
133
  var PORTAL_LIST_HEIGHT = 240;
134
134
  var PORTAL_EDGE_GAP = 8;
135
135
  // INFO: the colour board fills columns top to bottom, about six blocks each,
136
- // and grows sideways rather than scrolling — up to four columns. A block is
137
- // 144px (min-w-[9rem]) with 8px gaps inside 12px of padding.
136
+ // and grows sideways — up to four columns, and only as many as fit in the
137
+ // window; past that it scrolls. A block is 144px (w-36) and 32px tall, 40px
138
+ // on a touch screen, with 8px gaps inside 12px of padding.
138
139
  var FILL_BOARD_ROWS = 6;
139
140
  var FILL_BOARD_MAX_COLUMNS = 4;
140
141
  var FILL_BLOCK_WIDTH = 144;
142
+ var FILL_BLOCK_HEIGHT = 32;
143
+ var FILL_BLOCK_HEIGHT_TOUCH = 40;
141
144
  var FILL_BOARD_GAP = 8;
142
145
  var FILL_BOARD_PADDING = 12;
146
+ // INFO: the board is never taller than this share of the window, so a long
147
+ // list scrolls inside it rather than covering the page
148
+ var FILL_BOARD_MAX_HEIGHT_RATIO = 0.6;
149
+ // INFO: the search box above the blocks — a 36px field and an 8px gap. A
150
+ // column that takes new values always has it; one that does not gets it once
151
+ // its list is long enough to need finding in
152
+ var FILL_SEARCH_HEIGHT = 44;
153
+ var FILL_SEARCH_MIN_OPTIONS = 12;
154
+ var FILL_BOARD_CELL_GAP = 4;
143
155
  // INFO: a filled cell's input is sized in characters. Chinese, Japanese and
144
156
  // Korean characters, and emoji, take about two, so each counts twice
145
157
  var handleGetLabelWidth = function (label) {
@@ -171,12 +183,17 @@ var Select = /** @class */ (function (_super) {
171
183
  };
172
184
  _this.optionContainerRef = (0, react_2.createRef)();
173
185
  _this.triggerRef = (0, react_2.createRef)();
186
+ _this.fillSearchRef = (0, react_2.createRef)();
187
+ _this.isUnmounted = false;
174
188
  _this.isMultiSelect = _this.props.value && Array.isArray(_this.props.value);
175
189
  _this.MOBILE_BREAKPOINT = 768;
176
190
  _this.setAsyncState = function (newState) {
177
191
  return new Promise(function (resolve) { return _this.setState(newState, resolve); });
178
192
  };
179
193
  _this.componentDidMount = function () {
194
+ // INFO: StrictMode mounts, unmounts and mounts the same instance again in
195
+ // development, so the flag set on that unmount is cleared here
196
+ _this.isUnmounted = false;
180
197
  _this.handleGetSuggestions();
181
198
  _this.handleGetPlaceholder();
182
199
  _this.handleInitModalState();
@@ -334,23 +351,29 @@ var Select = /** @class */ (function (_super) {
334
351
  return [2 /*return*/];
335
352
  });
336
353
  }); };
354
+ // INFO: the typed text, trimmed — what a new value is saved as
355
+ _this.handleGetTypedValue = function () {
356
+ return typeof _this.state.valuePlaceholder === "string"
357
+ ? _this.state.valuePlaceholder.trim()
358
+ : "";
359
+ };
337
360
  _this.handleGetSuggestions = function () { return __awaiter(_this, void 0, void 0, function () {
338
- var filterOptions, clonedOptions, existingOption, newOptions, newOption, newChipOptions, exists, searchTerm;
361
+ var filterOptions, clonedOptions, typedValue_1, existingOption, newOptions, newOption, newChipOptions, exists, searchTerm;
339
362
  var _this = this;
340
363
  var _a;
341
364
  return __generator(this, function (_b) {
342
365
  filterOptions = [];
343
366
  clonedOptions = this.renderBareOptions(this.props.options, this.notDefaultType || this.props.showOptionAvatar);
344
367
  if (this.props.newValue && !this.notDefaultType) {
345
- if (this.state.valuePlaceholder) {
368
+ typedValue_1 = this.handleGetTypedValue();
369
+ if (typedValue_1) {
346
370
  existingOption = clonedOptions.find(function (eachOption) {
347
- return eachOption.key === _this.state.valuePlaceholder ||
348
- eachOption.label === _this.state.valuePlaceholder;
371
+ return eachOption.key === typedValue_1 || eachOption.label === typedValue_1;
349
372
  });
350
373
  if (!existingOption) {
351
374
  clonedOptions.push({
352
- key: this.state.valuePlaceholder,
353
- label: "Add '".concat(this.state.valuePlaceholder, "'"),
375
+ key: typedValue_1,
376
+ label: "Add '".concat(typedValue_1, "'"),
354
377
  });
355
378
  }
356
379
  }
@@ -400,7 +423,8 @@ var Select = /** @class */ (function (_super) {
400
423
  if (Array.isArray(this.state.valuePlaceholder))
401
424
  searchTerm = ((_a = this.state.valuePlaceholder[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "";
402
425
  else if (typeof this.state.valuePlaceholder === "string")
403
- searchTerm = this.state.valuePlaceholder.toLowerCase() || "";
426
+ // INFO: spaces around the typed text do not narrow the search
427
+ searchTerm = this.state.valuePlaceholder.trim().toLowerCase() || "";
404
428
  }
405
429
  clonedOptions.forEach(function (eachOption) {
406
430
  var _a;
@@ -436,10 +460,14 @@ var Select = /** @class */ (function (_super) {
436
460
  }
437
461
  }, 250);
438
462
  };
439
- _this.handleBlur = function () {
463
+ _this.handleBlur = function (e) {
440
464
  var _a, _b;
441
465
  if (_this.props.disabled)
442
466
  return;
467
+ // INFO: focus moving from the cell to the board's search box keeps the
468
+ // board open
469
+ if ((e === null || e === void 0 ? void 0 : e.relatedTarget) && e.relatedTarget === _this.fillSearchRef.current)
470
+ return;
443
471
  _this.setState({
444
472
  onFocus: Boolean(_this.isMultiSelect &&
445
473
  _this.props.closeOnClickOutside &&
@@ -454,6 +482,9 @@ var Select = /** @class */ (function (_super) {
454
482
  }
455
483
  };
456
484
  _this.handlePreventDropdownBlur = function (e) {
485
+ // INFO: the board's search box takes focus like any field
486
+ if (e.target === _this.fillSearchRef.current)
487
+ return;
457
488
  e.preventDefault();
458
489
  };
459
490
  // INFO: the dropdown opens on the input's focus event, but picking an option
@@ -650,9 +681,10 @@ var Select = /** @class */ (function (_super) {
650
681
  show: Boolean(_this.state.onFocus), enter: "transform transition duration-[400ms] ease-in-out", enterFrom: "opacity-0 -translate-y-2", leave: "transform origin-bottom duration-200 transition ease-in-out", leaveTo: "opacity-0 -translate-y-2" }, optionDropdown));
651
682
  }
652
683
  else if (_this.props.portalDropdown && _this.state.onFocus) {
653
- // INFO: a plain fill cell's list hangs from the table cell itself, as
654
- // wide as it and flush under its ring, not from the field inset in it
655
- var anchor = _this.isPlainFill()
684
+ // INFO: a plain fill cell's list and a colour board hang from the table
685
+ // cell itself, lined up with its left edge, not from the field inset in
686
+ // it — as the label picker of a multiple list does
687
+ var anchor = _this.isPlainFill() || _this.isFillDropdown()
656
688
  ? ((_b = (_a = _this.triggerRef.current) === null || _a === void 0 ? void 0 : _a.closest("td")) !== null && _b !== void 0 ? _b : _this.triggerRef.current)
657
689
  : _this.triggerRef.current;
658
690
  var rect = anchor === null || anchor === void 0 ? void 0 : anchor.getBoundingClientRect();
@@ -684,20 +716,19 @@ var Select = /** @class */ (function (_super) {
684
716
  // its own height rather than the list's 240px
685
717
  _this.handleGetPortalPlacement = function (rect) {
686
718
  var listHeight = _this.isFillDropdown()
687
- ? (function () {
688
- var rows = _this.handleGetFillBoardShape().rows;
689
- return (rows * 32 + (rows - 1) * FILL_BOARD_GAP + 2 * FILL_BOARD_PADDING);
690
- })()
719
+ ? Math.min(_this.handleGetFillBoardShape().height, Math.round(window.innerHeight * FILL_BOARD_MAX_HEIGHT_RATIO))
691
720
  : PORTAL_LIST_HEIGHT;
692
- var roomBelow = window.innerHeight - rect.bottom - PORTAL_EDGE_GAP;
693
- var roomAbove = rect.top - PORTAL_EDGE_GAP;
721
+ // INFO: a colour board sits 4px off its cell, as the label picker does
722
+ var gap = _this.isFillDropdown() ? FILL_BOARD_CELL_GAP : 0;
723
+ var roomBelow = window.innerHeight - rect.bottom - PORTAL_EDGE_GAP - gap;
724
+ var roomAbove = rect.top - PORTAL_EDGE_GAP - gap;
694
725
  if (roomBelow < listHeight && roomAbove > roomBelow)
695
726
  return {
696
- bottom: window.innerHeight - rect.top,
727
+ bottom: window.innerHeight - rect.top + gap,
697
728
  maxHeight: Math.min(listHeight, roomAbove),
698
729
  };
699
730
  return {
700
- top: rect.bottom,
731
+ top: rect.bottom + gap,
701
732
  maxHeight: Math.min(listHeight, Math.max(roomBelow, 0)),
702
733
  };
703
734
  };
@@ -721,48 +752,206 @@ var Select = /** @class */ (function (_super) {
721
752
  !Array.isArray(_this.props.value) &&
722
753
  !_this.props.type;
723
754
  };
755
+ _this.isTouchScreen = function () {
756
+ var _a;
757
+ return typeof window !== "undefined" &&
758
+ !!((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, "(pointer: coarse)").matches);
759
+ };
760
+ _this.hasFillSearch = function () {
761
+ return _this.isFillDropdown() &&
762
+ !_this.props.disabled &&
763
+ (_this.canAddFillValue() ||
764
+ _this.props.options.length > FILL_SEARCH_MIN_OPTIONS);
765
+ };
766
+ // INFO: a pick or Escape made from the search box closes the board with
767
+ // focus already off the cell, so the cell's own blur — which ends the edit
768
+ // and saves — is run here once the pick has reached the parent
769
+ _this.handleCloseFromFillSearch = function () {
770
+ if (document.activeElement !== _this.fillSearchRef.current)
771
+ return false;
772
+ _this.setState({ onFocus: false });
773
+ setTimeout(function () {
774
+ if (!_this.isUnmounted)
775
+ _this.handleBlur();
776
+ }, 0);
777
+ return true;
778
+ };
779
+ // INFO: focus can leave the search box with nowhere recorded to go — a press
780
+ // on the board's own padding, or the box being drawn again — so the blur is
781
+ // judged a tick later, once focus has settled, and ignored when it is back
782
+ // in this field or its search box
783
+ _this.handleFillSearchBlur = function (e) {
784
+ var _a;
785
+ if (!_this.state.onFocus)
786
+ return;
787
+ var cellInput = (_a = _this.triggerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("input");
788
+ if (e.relatedTarget && e.relatedTarget === cellInput)
789
+ return;
790
+ setTimeout(function () {
791
+ var _a;
792
+ if (_this.isUnmounted || !_this.state.onFocus)
793
+ return;
794
+ var active = document.activeElement;
795
+ if (active &&
796
+ (active === _this.fillSearchRef.current ||
797
+ active === ((_a = _this.triggerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("input"))))
798
+ return;
799
+ _this.handleBlur();
800
+ }, 0);
801
+ };
802
+ // INFO: whether the board offers typed text as a new value — the column
803
+ // takes new values and its keyboard search is not turned off
804
+ _this.canAddFillValue = function () { return !!_this.props.newValue && !_this.props.disableKeyboard; };
805
+ // INFO: Enter picks an exact match or the one option left, and the typed
806
+ // text as a new value only when no option matches it. It reads the options
807
+ // and the text as typed now — the board's own list catches up 250ms after a
808
+ // key, so a quick Enter would otherwise act on the text before the last key
809
+ _this.handleFillSearchEnter = function () {
810
+ var _a;
811
+ var typed = _this.handleGetTypedValue();
812
+ var query = typed.toLowerCase();
813
+ if (!query)
814
+ return;
815
+ var candidates = _this.props.options.filter(function (each) { var _a; return !((_a = _this.props.exclude) === null || _a === void 0 ? void 0 : _a.includes(each.key)); });
816
+ // INFO: a value not in the list stays on the board as an option of its own
817
+ if (_this.props.newValue &&
818
+ _this.props.value &&
819
+ !Array.isArray(_this.props.value) &&
820
+ !candidates.some(function (each) { return each.key === _this.props.value; }))
821
+ candidates.push({ key: _this.props.value, label: _this.props.value });
822
+ var labelOf = function (each) { var _a; return String((_a = each.label) !== null && _a !== void 0 ? _a : "").toLowerCase(); };
823
+ var exact = candidates.find(function (each) {
824
+ return labelOf(each) === query || String(each.key).toLowerCase() === query;
825
+ });
826
+ var matches = candidates.filter(function (each) { return labelOf(each).includes(query); });
827
+ var key = (_a = exact === null || exact === void 0 ? void 0 : exact.key) !== null && _a !== void 0 ? _a : (matches.length === 1
828
+ ? matches[0].key
829
+ : matches.length === 0 && _this.canAddFillValue()
830
+ ? typed
831
+ : undefined);
832
+ if (key !== undefined)
833
+ _this.handleFillPick(key);
834
+ };
835
+ _this.handleFillSearchKeyDown = function (e) {
836
+ if (e.key === "Escape") {
837
+ e.preventDefault();
838
+ e.stopPropagation();
839
+ _this.handleCloseFromFillSearch();
840
+ return;
841
+ }
842
+ // INFO: some phone keyboards send only the keyCode, and an input method
843
+ // still composing Chinese, Japanese or Korean text uses Enter itself
844
+ if ((e.key === "Enter" || e.keyCode === 13) && !e.nativeEvent.isComposing) {
845
+ e.preventDefault();
846
+ e.stopPropagation();
847
+ _this.handleFillSearchEnter();
848
+ }
849
+ };
724
850
  _this.handleFillPick = function (key) {
725
851
  var _a, _b, _c, _d;
852
+ var fromSearch = document.activeElement === _this.fillSearchRef.current;
726
853
  // INFO: picking the value already set changes nothing — it only closes,
727
854
  // where handleOnSelectChange would toggle it off
728
855
  if (key === _this.props.value) {
856
+ if (fromSearch) {
857
+ _this.handleCloseFromFillSearch();
858
+ return;
859
+ }
729
860
  _this.setState({ onFocus: false });
730
861
  (_b = (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.blur) === null || _b === void 0 ? void 0 : _b.call(_a);
731
862
  return;
732
863
  }
733
864
  if (key === "") {
734
865
  (_d = (_c = _this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, "");
735
- _this.setState({ onFocus: false });
866
+ if (fromSearch)
867
+ _this.handleCloseFromFillSearch();
868
+ else
869
+ _this.setState({ onFocus: false });
736
870
  return;
737
871
  }
738
872
  _this.handleOnSelectChange(key);
873
+ if (fromSearch)
874
+ _this.handleCloseFromFillSearch();
739
875
  };
740
876
  _this.handleGetFillBoardShape = function () {
741
- var blocks = _this.state.filterOptions.length +
877
+ var blocks = _this.getFillBoardOptions().length +
742
878
  (_this.props.value && !_this.props.disabled ? 1 : 0);
743
- var columns = Math.min(FILL_BOARD_MAX_COLUMNS, Math.max(1, Math.ceil(blocks / FILL_BOARD_ROWS)));
879
+ // INFO: no more columns than the window has room for, so a narrow window
880
+ // or a phone gets a taller board that scrolls instead of one cut off
881
+ var fitColumns = typeof window === "undefined"
882
+ ? FILL_BOARD_MAX_COLUMNS
883
+ : Math.max(1, Math.floor((window.innerWidth -
884
+ 2 * PORTAL_EDGE_GAP -
885
+ 2 * FILL_BOARD_PADDING +
886
+ FILL_BOARD_GAP) /
887
+ (FILL_BLOCK_WIDTH + FILL_BOARD_GAP)));
888
+ var columns = Math.min(FILL_BOARD_MAX_COLUMNS, fitColumns, Math.max(1, Math.ceil(blocks / FILL_BOARD_ROWS)));
889
+ var rows = Math.max(1, Math.ceil(blocks / columns));
890
+ var blockHeight = _this.isTouchScreen()
891
+ ? FILL_BLOCK_HEIGHT_TOUCH
892
+ : FILL_BLOCK_HEIGHT;
744
893
  return {
745
894
  columns: columns,
746
- rows: Math.max(1, Math.ceil(blocks / columns)),
895
+ rows: rows,
896
+ blockHeight: blockHeight,
747
897
  width: columns * FILL_BLOCK_WIDTH +
748
898
  (columns - 1) * FILL_BOARD_GAP +
749
899
  2 * FILL_BOARD_PADDING,
900
+ height: rows * blockHeight +
901
+ (rows - 1) * FILL_BOARD_GAP +
902
+ 2 * FILL_BOARD_PADDING +
903
+ (_this.hasFillSearch() ? FILL_SEARCH_HEIGHT : 0),
750
904
  };
751
905
  };
906
+ _this.renderFillSearch = function () {
907
+ var _a;
908
+ return (
909
+ // INFO: pinned above the blocks while they scroll
910
+ react_2.default.createElement("li", { key: "fill-search", className: "sticky -top-3 z-10 -mx-3 -mt-3 mb-2 list-none px-3 pt-3 pb-0 ".concat(_this.props.darkMode ? "bg-gray-800" : "bg-white") },
911
+ react_2.default.createElement("form", { onSubmit: function (e) {
912
+ e.preventDefault();
913
+ e.stopPropagation();
914
+ _this.handleFillSearchEnter();
915
+ } },
916
+ react_2.default.createElement("input", { ref: _this.fillSearchRef, "data-testid": "select-fill-search", type: "text", autoComplete: "off", enterKeyHint: "done", value: String((_a = _this.state.valuePlaceholder) !== null && _a !== void 0 ? _a : ""), placeholder: _this.canAddFillValue() ? "Search or add…" : "Search…", "aria-label": _this.canAddFillValue() ? "Search or add" : "Search", onChange: _this.handleOnChange, onKeyDown: _this.handleFillSearchKeyDown, onBlur: _this.handleFillSearchBlur, className: "block h-9 w-full rounded-md border px-3 ".concat(utils_2.touchSafeFontSize.smFromSm, " focus:border-primary-500 focus:outline-none focus:ring-0 ").concat(_this.props.darkMode ? "border-gray-600 bg-gray-900 text-white placeholder-gray-500" : "border-gray-300 bg-white text-gray-900 placeholder-gray-400") }))));
917
+ };
918
+ // INFO: the blocks on the board — the suggestions, less the typed text when
919
+ // the column cannot take new values, and one block per value: typing the
920
+ // cell's own off-list value would otherwise show it twice
921
+ _this.getFillBoardOptions = function () {
922
+ var seen = new Set();
923
+ return _this.state.filterOptions.filter(function (each) {
924
+ if (!_this.canAddFillValue() && _this.isTypedFillOption(each))
925
+ return false;
926
+ if (seen.has(each.key))
927
+ return false;
928
+ seen.add(each.key);
929
+ return true;
930
+ });
931
+ };
932
+ // INFO: the typed text that Select's suggestions offer as a new option
933
+ _this.isTypedFillOption = function (option) {
934
+ return !!_this.handleGetTypedValue() &&
935
+ option.key === _this.handleGetTypedValue() &&
936
+ option.key !== _this.props.value &&
937
+ !_this.props.options.some(function (each) { return each.key === option.key; });
938
+ };
752
939
  _this.renderFillOptions = function () {
753
- var options = _this.state.filterOptions;
940
+ var options = _this.getFillBoardOptions();
941
+ var search = _this.hasFillSearch() ? [_this.renderFillSearch()] : [];
754
942
  // INFO: a search that matches nothing says so, as the list does, rather
755
943
  // than showing an empty board
756
944
  if (options.length === 0 && !(_this.props.value && !_this.props.disabled))
757
- return [
945
+ return __spreadArray(__spreadArray([], search, true), [
758
946
  react_2.default.createElement("li", { key: "fill-board-empty", "data-testid": "select-fill-empty", className: "list-none px-2 py-1 text-sm ".concat(_this.props.darkMode ? "text-gray-400" : "text-gray-500") }, "No options available"),
759
- ];
947
+ ], false);
760
948
  var shape = _this.handleGetFillBoardShape();
761
949
  var blockClass =
762
950
  // INFO: a fixed width, a long label cut off — the board is placed
763
- // inside the window from this width, so a block may not grow past it
764
- "flex h-8 w-36 min-w-0 items-center justify-center rounded-sm px-4 text-sm font-normal focus:outline-none";
765
- return [
951
+ // inside the window from this width, so a block may not grow past it.
952
+ // A touch screen gets a taller block to tap
953
+ "flex ".concat(shape.blockHeight === FILL_BLOCK_HEIGHT_TOUCH ? "h-10" : "h-8", " w-36 min-w-0 items-center justify-center rounded-sm px-4 text-sm font-normal focus:outline-none");
954
+ return __spreadArray(__spreadArray([], search, true), [
766
955
  react_2.default.createElement("li", { key: "fill-board", className: "list-none" },
767
956
  react_2.default.createElement("div", { "data-testid": "select-fill-board", className: "grid grid-flow-col gap-2", style: {
768
957
  gridTemplateRows: "repeat(".concat(shape.rows, ", minmax(0, auto))"),
@@ -775,6 +964,18 @@ var Select = /** @class */ (function (_super) {
775
964
  var _a;
776
965
  var customColor = eachOption.color && eachOption.color.startsWith("#");
777
966
  var isSelected = eachOption.key === _this.props.value;
967
+ // INFO: the typed text offered as a new value — set apart from the
968
+ // options as an outlined block, so it never reads as one of them
969
+ var isNewValue = _this.isTypedFillOption(eachOption);
970
+ if (isNewValue)
971
+ return (react_2.default.createElement("button", { key: "new-".concat(eachOption.key), type: "button", "data-fill-option": eachOption.key, "data-testid": "select-fill-new", className: "".concat(blockClass, " gap-1 border border-dashed ").concat(_this.props.darkMode
972
+ ? "border-gray-500 text-gray-200 hover:bg-gray-700"
973
+ : "border-gray-400 text-gray-700 hover:bg-gray-50"), title: eachOption.key, onMouseDown: function (e) {
974
+ e.preventDefault();
975
+ _this.handleFillPick(eachOption.key);
976
+ } },
977
+ react_2.default.createElement(outline_1.PlusIcon, { "aria-hidden": "true", className: "h-4 w-4 flex-shrink-0" }),
978
+ react_2.default.createElement("span", { className: "truncate" }, eachOption.key)));
778
979
  return (react_2.default.createElement("button", { key: eachOption.key, type: "button", "data-fill-option": eachOption.key, "aria-pressed": isSelected, className: "".concat(blockClass, " hover:brightness-110 ").concat(customColor
779
980
  ? "text-white"
780
981
  : eachOption.color
@@ -791,7 +992,7 @@ var Select = /** @class */ (function (_super) {
791
992
  } },
792
993
  react_2.default.createElement("span", { className: "truncate" }, eachOption.label)));
793
994
  }))),
794
- ];
995
+ ], false);
795
996
  };
796
997
  _this.renderOptions = function () {
797
998
  if (_this.isFillDropdown())
@@ -1198,13 +1399,14 @@ var Select = /** @class */ (function (_super) {
1198
1399
  return _this;
1199
1400
  }
1200
1401
  Select.prototype.componentWillUnmount = function () {
1402
+ this.isUnmounted = true;
1201
1403
  if (this.props.closeOnClickOutside && this.isMultiSelect) {
1202
1404
  document.removeEventListener("mousedown", this.handleClickOutsideOptionContainer);
1203
1405
  }
1204
1406
  };
1205
1407
  Select.prototype.render = function () {
1206
1408
  var _this = this;
1207
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
1409
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1208
1410
  var defaultPadding = "px-5 py-3";
1209
1411
  // INFO: cell mode drops the padding, so an editable row stays close to a
1210
1412
  // read-only one, and on a desktop uses the table's own text-sm so a cell's
@@ -1254,9 +1456,10 @@ var Select = /** @class */ (function (_super) {
1254
1456
  // INFO: a coloured list cell (cellInput + showTag) keeps its filled look
1255
1457
  // while closed, so tapping into a row does not change the cell's shape;
1256
1458
  // the fill drops while the dropdown is open so the typed filter is legible
1257
- // INFO: in fill mode a cell that cannot be typed into has no filter to
1258
- // read, so it keeps its colour and label while the board is open
1259
- var keepsFillOpen = this.isFillDropdown() && !!this.props.disableKeyboard;
1459
+ // INFO: in fill mode the cell is never typed into — it keeps its colour
1460
+ // and label while the board is open, and any typing happens in the
1461
+ // board's own search box
1462
+ var keepsFillOpen = this.isFillDropdown();
1260
1463
  var isFilledCell = !!((_e = this.props.cellInput) === null || _e === void 0 ? void 0 : _e.active) &&
1261
1464
  !!this.props.showTag &&
1262
1465
  !Array.isArray(this.props.value) &&
@@ -1278,10 +1481,7 @@ var Select = /** @class */ (function (_super) {
1278
1481
  // INFO: a value with no colour of its own — typed in through
1279
1482
  // listNewValue, or an option left uncoloured — reads as flat text in the
1280
1483
  // painted grid, as the empty cell does, rather than a boxed field
1281
- var isFillUncoloured = this.isFillDropdown() &&
1282
- !!this.props.value &&
1283
- !selectedColor &&
1284
- !this.state.onFocus;
1484
+ var isFillUncoloured = this.isFillDropdown() && !!this.props.value && !selectedColor;
1285
1485
  var isFillFlat = isFillEmpty || isFillUncoloured;
1286
1486
  var isPlainFill = this.isPlainFill() && !isFilledCell;
1287
1487
  // INFO: focus clears valuePlaceholder so the options are not filtered by
@@ -1289,22 +1489,27 @@ var Select = /** @class */ (function (_super) {
1289
1489
  // INFO: a plain fill cell that takes no typing has nothing to filter, so
1290
1490
  // it keeps its label while open too
1291
1491
  // INFO: a plain fill cell reads its picks as "A, B", like the cell did
1292
- var shownValue = (isCellFill || (isPlainFill && !!this.props.disableKeyboard)) &&
1293
- this.state.onFocus
1294
- ? Array.isArray(this.props.value)
1295
- ? this.handleGetSelectedLabels()
1296
- : ((_j = (_h = this.props.options.find(function (each) { return each.key === _this.props.value; })) === null || _h === void 0 ? void 0 : _h.label) !== null && _j !== void 0 ? _j : String((_k = this.props.value) !== null && _k !== void 0 ? _k : ""))
1297
- : isPlainFill && Array.isArray(this.state.valuePlaceholder)
1298
- ? this.state.valuePlaceholder.join(", ")
1299
- : this.state.valuePlaceholder;
1300
- var useMobileView = (_l = this.props.mobileView) !== null && _l !== void 0 ? _l : false;
1492
+ var currentLabel = Array.isArray(this.props.value)
1493
+ ? this.handleGetSelectedLabels()
1494
+ : ((_j = (_h = this.props.options.find(function (each) { return each.key === _this.props.value; })) === null || _h === void 0 ? void 0 : _h.label) !== null && _j !== void 0 ? _j : String((_k = this.props.value) !== null && _k !== void 0 ? _k : ""));
1495
+ var shownValue = this.isFillDropdown() && this.state.onFocus
1496
+ ? currentLabel
1497
+ : (isCellFill || (isPlainFill && !!this.props.disableKeyboard)) &&
1498
+ this.state.onFocus
1499
+ ? Array.isArray(this.props.value)
1500
+ ? this.handleGetSelectedLabels()
1501
+ : ((_m = (_l = this.props.options.find(function (each) { return each.key === _this.props.value; })) === null || _l === void 0 ? void 0 : _l.label) !== null && _m !== void 0 ? _m : String((_o = this.props.value) !== null && _o !== void 0 ? _o : ""))
1502
+ : isPlainFill && Array.isArray(this.state.valuePlaceholder)
1503
+ ? this.state.valuePlaceholder.join(", ")
1504
+ : this.state.valuePlaceholder;
1505
+ var useMobileView = (_p = this.props.mobileView) !== null && _p !== void 0 ? _p : false;
1301
1506
  return (
1302
1507
  // INFO: flex column + h-full lets the field fill the height its grid row
1303
1508
  // was given, so the control can be dropped onto a shared baseline with a
1304
1509
  // neighbouring field whose subLabel is taller. In a block parent h-full
1305
1510
  // resolves to auto and the column stacks exactly like the old block did,
1306
1511
  // so standalone usage is unchanged.
1307
- react_2.default.createElement("div", { className: "w-full flex flex-col h-full ".concat((_m = this.props.containerClassName) !== null && _m !== void 0 ? _m : "") },
1512
+ react_2.default.createElement("div", { className: "w-full flex flex-col h-full ".concat((_q = this.props.containerClassName) !== null && _q !== void 0 ? _q : "") },
1308
1513
  this.renderMobileSelectOptions(),
1309
1514
  this.props.type === "radioview" ? (react_2.default.createElement("div", { className: "relative" },
1310
1515
  this.renderLabelSection(false),
@@ -1353,7 +1558,7 @@ var Select = /** @class */ (function (_super) {
1353
1558
  : undefined,
1354
1559
  } },
1355
1560
  this.renderValueAvatars(),
1356
- react_2.default.createElement("input", { id: this.props.id, "data-testid": this.props.id, className: "w-full rounded-md ".concat(defaultPadding).concat(this.props.size === "xs" ? " ".concat(utils_2.touchSafeFontSize.xsFromSm) : ((_o = this.props.cellInput) === null || _o === void 0 ? void 0 : _o.active) ? " ".concat(utils_2.touchSafeFontSize.smFromSm) : "", " border-none focus:ring-0 focus:outline-none ").concat(isFilledCell
1561
+ react_2.default.createElement("input", { id: this.props.id, "data-testid": this.props.id, className: "w-full rounded-md ".concat(defaultPadding).concat(this.props.size === "xs" ? " ".concat(utils_2.touchSafeFontSize.xsFromSm) : ((_r = this.props.cellInput) === null || _r === void 0 ? void 0 : _r.active) ? " ".concat(utils_2.touchSafeFontSize.smFromSm) : "", " border-none focus:ring-0 focus:outline-none ").concat(isFilledCell
1357
1562
  ? "".concat(isCellFill ? "cursor-pointer caret-transparent font-normal" : "font-medium", " !w-auto bg-transparent text-center text-inherit placeholder:text-inherit disabled:bg-transparent disabled:text-inherit ").concat(this.props.disabled ? "text-sm" : "")
1358
1563
  : isPlainFill
1359
1564
  ? // INFO: the field gives up room to the chevron,
@@ -1361,10 +1566,9 @@ var Select = /** @class */ (function (_super) {
1361
1566
  // its inputs would push past the cell's edge
1362
1567
  "!min-w-0 flex-1 ".concat(this.props.disableKeyboard ? "cursor-pointer caret-transparent" : "", " bg-transparent ").concat(this.props.darkMode ? "text-white placeholder-gray-500" : textColor)
1363
1568
  : isFillFlat
1364
- ? // INFO: an empty board cell takes no typing
1365
- // unless its column accepts new values, so it
1366
- // shows no caret that suggests it does
1367
- "".concat(this.props.disableKeyboard ? "cursor-pointer caret-transparent" : "", " bg-transparent ").concat(this.props.darkMode ? "text-white" : "")
1569
+ ? // INFO: a board cell is tapped, never typed
1570
+ // into, so it shows no caret that suggests it is
1571
+ "cursor-pointer caret-transparent bg-transparent ".concat(this.props.darkMode ? "text-white" : "")
1368
1572
  : "".concat(textColor, " ").concat(this.props.darkMode ? "bg-gray-800 text-white placeholder-gray-500 disabled:bg-gray-900 disabled:text-gray-500" : "")), value: shownValue, size: isFilledCell
1369
1573
  ? handleGetLabelWidth(String(shownValue !== null && shownValue !== void 0 ? shownValue : ""))
1370
1574
  : undefined, disabled: this.props.disabled, autoFocus: this.props.autoFocus, placeholder: isFillEmpty
@@ -1387,7 +1591,7 @@ var Select = /** @class */ (function (_super) {
1387
1591
  _this.setState({ onFocus: false });
1388
1592
  e.currentTarget.blur();
1389
1593
  }
1390
- : undefined, readOnly: this.props.disableKeyboard, style: {
1594
+ : undefined, readOnly: this.props.disableKeyboard || this.isFillDropdown(), style: {
1391
1595
  // INFO: on a filled cell the hex is the fill, so the
1392
1596
  // label would disappear into it
1393
1597
  color: !isFilledCell && customColor
@@ -1397,9 +1601,7 @@ var Select = /** @class */ (function (_super) {
1397
1601
  isPlainFill ? (
1398
1602
  // INFO: no clear icon in a plain fill cell — a quiet
1399
1603
  // chevron set in from the cell's ring
1400
- react_2.default.createElement(outline_1.ChevronDownIcon, { "aria-hidden": "true", className: "mr-1.5 h-4 w-4 flex-shrink-0 ".concat(this.props.darkMode ? "text-gray-500" : "text-gray-400") })) : (!isFilledCell &&
1401
- !isFillFlat &&
1402
- this.renderClearIcon())),
1604
+ react_2.default.createElement(outline_1.ChevronDownIcon, { "aria-hidden": "true", className: "mr-1.5 h-4 w-4 flex-shrink-0 ".concat(this.props.darkMode ? "text-gray-500" : "text-gray-400") })) : (!isFilledCell && !isFillFlat && this.renderClearIcon())),
1403
1605
  this.props.showTag && this.renderTags())),
1404
1606
  this.renderOptionContainer())),
1405
1607
  react_2.default.createElement("span", { className: "text-red-500 text-sm" }, this.state.error))))));