blixify-ui-web 1.2.251 → 1.2.253
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/lib/components/data/blobModule.d.ts +1 -0
- package/lib/components/data/blobModule.d.ts.map +1 -1
- package/lib/components/data/blobModule.js +24 -2
- package/lib/components/data/blobModule.js.map +1 -1
- package/lib/components/data/columnTypes/dateRangeCalendar.d.ts +36 -0
- package/lib/components/data/columnTypes/dateRangeCalendar.d.ts.map +1 -0
- package/lib/components/data/columnTypes/dateRangeCalendar.js +226 -0
- package/lib/components/data/columnTypes/dateRangeCalendar.js.map +1 -0
- package/lib/components/data/columnTypes/dateRangeCell.d.ts +2 -0
- package/lib/components/data/columnTypes/dateRangeCell.d.ts.map +1 -1
- package/lib/components/data/columnTypes/dateRangeCell.js +63 -11
- package/lib/components/data/columnTypes/dateRangeCell.js.map +1 -1
- package/lib/components/data/columnTypes/lookup.d.ts.map +1 -1
- package/lib/components/data/columnTypes/lookup.js +14 -2
- package/lib/components/data/columnTypes/lookup.js.map +1 -1
- package/lib/components/data/dataTemplate/chartView.d.ts +1 -0
- package/lib/components/data/dataTemplate/chartView.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/chartView.js +9 -3
- package/lib/components/data/dataTemplate/chartView.js.map +1 -1
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +78 -46
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/model.d.ts +1 -0
- package/lib/components/data/dataTemplate/model.d.ts.map +1 -1
- package/lib/components/data/listModule.d.ts +1 -1
- package/lib/components/data/listModule.d.ts.map +1 -1
- package/lib/components/data/listModule.js +11 -5
- package/lib/components/data/listModule.js.map +1 -1
- package/lib/components/data/updateModule.d.ts +5 -0
- package/lib/components/data/updateModule.d.ts.map +1 -1
- package/lib/components/data/updateModule.js +24 -2
- package/lib/components/data/updateModule.js.map +1 -1
- package/lib/components/display/newTable/index.d.ts +5 -0
- package/lib/components/display/newTable/index.d.ts.map +1 -1
- package/lib/components/display/newTable/index.js +576 -107
- package/lib/components/display/newTable/index.js.map +1 -1
- package/lib/components/display/newTable/labelPicker.d.ts +24 -0
- package/lib/components/display/newTable/labelPicker.d.ts.map +1 -0
- package/lib/components/display/newTable/labelPicker.js +228 -0
- package/lib/components/display/newTable/labelPicker.js.map +1 -0
- package/lib/components/input/datePicker/index.d.ts.map +1 -1
- package/lib/components/input/datePicker/index.js +18 -8
- package/lib/components/input/datePicker/index.js.map +1 -1
- package/lib/components/input/select/index.d.ts +13 -0
- package/lib/components/input/select/index.d.ts.map +1 -1
- package/lib/components/input/select/index.js +248 -31
- package/lib/components/input/select/index.js.map +1 -1
- package/lib/components/input/textInput/index.d.ts.map +1 -1
- package/lib/components/input/textInput/index.js +41 -6
- package/lib/components/input/textInput/index.js.map +1 -1
- package/lib/components/input/utils.d.ts +12 -0
- package/lib/components/input/utils.d.ts.map +1 -1
- package/lib/components/input/utils.js.map +1 -1
- package/lib/tail.css +2 -2
- package/package.json +1 -1
|
@@ -97,7 +97,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
97
97
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
98
98
|
};
|
|
99
99
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100
|
-
exports.Select = void 0;
|
|
100
|
+
exports.Select = exports.FILL_CLASS = void 0;
|
|
101
101
|
var react_1 = require("@headlessui/react");
|
|
102
102
|
var outline_1 = require("@heroicons/react/24/outline");
|
|
103
103
|
var solid_1 = require("@heroicons/react/24/solid");
|
|
@@ -113,8 +113,9 @@ var utils_1 = require("../../display/tag/utils");
|
|
|
113
113
|
var personAvatar_1 = require("../../data/columnTypes/personAvatar");
|
|
114
114
|
var textInput_1 = require("../textInput");
|
|
115
115
|
var utils_2 = require("../utils");
|
|
116
|
-
// INFO: fill colours shared by the closed coloured cell and its option pills
|
|
117
|
-
|
|
116
|
+
// INFO: fill colours shared by the closed coloured cell and its option pills.
|
|
117
|
+
// Exported so a table cell that paints the colour itself uses the same shades.
|
|
118
|
+
exports.FILL_CLASS = {
|
|
118
119
|
default: "bg-primary-500 text-white",
|
|
119
120
|
red: "bg-red-500 text-white",
|
|
120
121
|
blue: "bg-blue-500 text-white",
|
|
@@ -131,6 +132,14 @@ var FILL_CLASS = {
|
|
|
131
132
|
// INFO: max-h-60, the list's own height limit
|
|
132
133
|
var PORTAL_LIST_HEIGHT = 240;
|
|
133
134
|
var PORTAL_EDGE_GAP = 8;
|
|
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.
|
|
138
|
+
var FILL_BOARD_ROWS = 6;
|
|
139
|
+
var FILL_BOARD_MAX_COLUMNS = 4;
|
|
140
|
+
var FILL_BLOCK_WIDTH = 144;
|
|
141
|
+
var FILL_BOARD_GAP = 8;
|
|
142
|
+
var FILL_BOARD_PADDING = 12;
|
|
134
143
|
// INFO: a filled cell's input is sized in characters. Chinese, Japanese and
|
|
135
144
|
// Korean characters, and emoji, take about two, so each counts twice
|
|
136
145
|
var handleGetLabelWidth = function (label) {
|
|
@@ -248,6 +257,21 @@ var Select = /** @class */ (function (_super) {
|
|
|
248
257
|
}
|
|
249
258
|
});
|
|
250
259
|
}); };
|
|
260
|
+
// INFO: the chosen options' labels on one line — a value no option holds
|
|
261
|
+
// reads as itself
|
|
262
|
+
_this.handleGetSelectedLabels = function () {
|
|
263
|
+
var values = Array.isArray(_this.props.value)
|
|
264
|
+
? _this.props.value
|
|
265
|
+
: _this.props.value
|
|
266
|
+
? [_this.props.value]
|
|
267
|
+
: [];
|
|
268
|
+
return values
|
|
269
|
+
.map(function (each) {
|
|
270
|
+
var _a, _b;
|
|
271
|
+
return (_b = (_a = _this.props.options.find(function (option) { return option.key === each; })) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : String(each);
|
|
272
|
+
})
|
|
273
|
+
.join(", ");
|
|
274
|
+
};
|
|
251
275
|
_this.handleGetPlaceholder = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
252
276
|
var valuePlaceholder, valueImage, isArrayValue, clonedOptions, newOptions, existingOption;
|
|
253
277
|
var _this = this;
|
|
@@ -614,7 +638,7 @@ var Select = /** @class */ (function (_super) {
|
|
|
614
638
|
return newOptionList;
|
|
615
639
|
};
|
|
616
640
|
_this.renderOptionContainer = function () {
|
|
617
|
-
var _a;
|
|
641
|
+
var _a, _b;
|
|
618
642
|
var position = _this.props.staticDropdown ? "static" : "absolute";
|
|
619
643
|
var optionDropdown = (react_2.default.createElement("ul", { ref: _this.optionContainerRef, onMouseDown: _this.handlePreventDropdownBlur,
|
|
620
644
|
// INFO: above the form's sticky action bar (z-20) so options never hide
|
|
@@ -626,12 +650,26 @@ var Select = /** @class */ (function (_super) {
|
|
|
626
650
|
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));
|
|
627
651
|
}
|
|
628
652
|
else if (_this.props.portalDropdown && _this.state.onFocus) {
|
|
629
|
-
|
|
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()
|
|
656
|
+
? ((_b = (_a = _this.triggerRef.current) === null || _a === void 0 ? void 0 : _a.closest("td")) !== null && _b !== void 0 ? _b : _this.triggerRef.current)
|
|
657
|
+
: _this.triggerRef.current;
|
|
658
|
+
var rect = anchor === null || anchor === void 0 ? void 0 : anchor.getBoundingClientRect();
|
|
630
659
|
// INFO: position:fixed is viewport-relative — getBoundingClientRect already
|
|
631
660
|
// returns viewport coords so scroll offsets must NOT be added.
|
|
632
661
|
var style = rect
|
|
633
|
-
? __assign({ position: "fixed"
|
|
634
|
-
|
|
662
|
+
? __assign(__assign(__assign({ position: "fixed" }, (_this.isFillDropdown()
|
|
663
|
+
? {
|
|
664
|
+
// INFO: a wide board starting at the cell could run past the
|
|
665
|
+
// window's right edge, so it is pulled back inside it
|
|
666
|
+
left: Math.max(PORTAL_EDGE_GAP, Math.min(rect.left, window.innerWidth -
|
|
667
|
+
_this.handleGetFillBoardShape().width -
|
|
668
|
+
PORTAL_EDGE_GAP)),
|
|
669
|
+
minWidth: rect.width,
|
|
670
|
+
}
|
|
671
|
+
: { left: rect.left, width: rect.width })), { zIndex: 9999 }), _this.handleGetPortalPlacement(rect)) : { position: "fixed", zIndex: 9999 };
|
|
672
|
+
return react_dom_1.default.createPortal(react_2.default.createElement("ul", { id: "select-portal", ref: _this.optionContainerRef, style: style, onMouseDown: _this.handlePreventDropdownBlur, className: "min-w-fit ".concat(_this.props.darkMode ? "bg-gray-800 text-white ring-gray-700" : "bg-white ring-black ring-opacity-5", " shadow-lg max-h-60 rounded-md ").concat(_this.isFillDropdown() ? "p-3" : "py-1", " ").concat(_this.props.size === "xs" ? "text-xs" : "text-base", " ring-1 overflow-auto focus:outline-none").concat(_this.props.size === "xs" ? "" : " sm:text-sm", " ").concat(_this.props.dropdownClassName) }, _this.renderOptions()), document.body);
|
|
635
673
|
}
|
|
636
674
|
else if (_this.state.onFocus) {
|
|
637
675
|
return optionDropdown;
|
|
@@ -642,20 +680,124 @@ var Select = /** @class */ (function (_super) {
|
|
|
642
680
|
// INFO: a fixed list cannot be scrolled to with the page, and a press past
|
|
643
681
|
// the window's edge lands outside any pop-up holding this field and closes
|
|
644
682
|
// it — so it opens on the side with room and ends at the window's edge
|
|
683
|
+
// INFO: the colour board is as tall as its rows need, so it is placed by
|
|
684
|
+
// its own height rather than the list's 240px
|
|
645
685
|
_this.handleGetPortalPlacement = function (rect) {
|
|
686
|
+
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
|
+
})()
|
|
691
|
+
: PORTAL_LIST_HEIGHT;
|
|
646
692
|
var roomBelow = window.innerHeight - rect.bottom - PORTAL_EDGE_GAP;
|
|
647
693
|
var roomAbove = rect.top - PORTAL_EDGE_GAP;
|
|
648
|
-
if (roomBelow <
|
|
694
|
+
if (roomBelow < listHeight && roomAbove > roomBelow)
|
|
649
695
|
return {
|
|
650
696
|
bottom: window.innerHeight - rect.top,
|
|
651
|
-
maxHeight: Math.min(
|
|
697
|
+
maxHeight: Math.min(listHeight, roomAbove),
|
|
652
698
|
};
|
|
653
699
|
return {
|
|
654
700
|
top: rect.bottom,
|
|
655
|
-
maxHeight: Math.min(
|
|
701
|
+
maxHeight: Math.min(listHeight, Math.max(roomBelow, 0)),
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
// INFO: cellInput.fill on a Select with no colours (a yes/no cell) — the
|
|
705
|
+
// table cell is the field, so the trigger drops its own box and surface and
|
|
706
|
+
// the list hangs from the cell's edges
|
|
707
|
+
_this.isPlainFill = function () {
|
|
708
|
+
var _a, _b;
|
|
709
|
+
return !!((_a = _this.props.cellInput) === null || _a === void 0 ? void 0 : _a.active) &&
|
|
710
|
+
!!((_b = _this.props.cellInput) === null || _b === void 0 ? void 0 : _b.fill) &&
|
|
711
|
+
!_this.isFillDropdown() &&
|
|
712
|
+
!_this.props.options.some(function (each) { return !!each.color; });
|
|
713
|
+
};
|
|
714
|
+
// INFO: cellInput.fill on a single coloured list — the table cell carries the
|
|
715
|
+
// colour, and picking happens in a board of full-width colour blocks
|
|
716
|
+
_this.isFillDropdown = function () {
|
|
717
|
+
var _a, _b;
|
|
718
|
+
return !!((_a = _this.props.cellInput) === null || _a === void 0 ? void 0 : _a.active) &&
|
|
719
|
+
!!((_b = _this.props.cellInput) === null || _b === void 0 ? void 0 : _b.fill) &&
|
|
720
|
+
!!_this.props.showTag &&
|
|
721
|
+
!Array.isArray(_this.props.value) &&
|
|
722
|
+
!_this.props.type;
|
|
723
|
+
};
|
|
724
|
+
_this.handleFillPick = function (key) {
|
|
725
|
+
var _a, _b, _c, _d;
|
|
726
|
+
// INFO: picking the value already set changes nothing — it only closes,
|
|
727
|
+
// where handleOnSelectChange would toggle it off
|
|
728
|
+
if (key === _this.props.value) {
|
|
729
|
+
_this.setState({ onFocus: false });
|
|
730
|
+
(_b = (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.blur) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
if (key === "") {
|
|
734
|
+
(_d = (_c = _this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, "");
|
|
735
|
+
_this.setState({ onFocus: false });
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
_this.handleOnSelectChange(key);
|
|
739
|
+
};
|
|
740
|
+
_this.handleGetFillBoardShape = function () {
|
|
741
|
+
var blocks = _this.state.filterOptions.length +
|
|
742
|
+
(_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)));
|
|
744
|
+
return {
|
|
745
|
+
columns: columns,
|
|
746
|
+
rows: Math.max(1, Math.ceil(blocks / columns)),
|
|
747
|
+
width: columns * FILL_BLOCK_WIDTH +
|
|
748
|
+
(columns - 1) * FILL_BOARD_GAP +
|
|
749
|
+
2 * FILL_BOARD_PADDING,
|
|
656
750
|
};
|
|
657
751
|
};
|
|
752
|
+
_this.renderFillOptions = function () {
|
|
753
|
+
var options = _this.state.filterOptions;
|
|
754
|
+
// INFO: a search that matches nothing says so, as the list does, rather
|
|
755
|
+
// than showing an empty board
|
|
756
|
+
if (options.length === 0 && !(_this.props.value && !_this.props.disabled))
|
|
757
|
+
return [
|
|
758
|
+
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
|
+
];
|
|
760
|
+
var shape = _this.handleGetFillBoardShape();
|
|
761
|
+
var blockClass =
|
|
762
|
+
// 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 [
|
|
766
|
+
react_2.default.createElement("li", { key: "fill-board", className: "list-none" },
|
|
767
|
+
react_2.default.createElement("div", { "data-testid": "select-fill-board", className: "grid grid-flow-col gap-2", style: {
|
|
768
|
+
gridTemplateRows: "repeat(".concat(shape.rows, ", minmax(0, auto))"),
|
|
769
|
+
} },
|
|
770
|
+
_this.props.value && !_this.props.disabled && (react_2.default.createElement("button", { type: "button", "aria-label": "Clear", "data-testid": "select-fill-clear", className: "".concat(blockClass, " ").concat(_this.props.darkMode ? "bg-gray-600 hover:bg-gray-500" : "bg-gray-300 hover:bg-gray-400"), onMouseDown: function (e) {
|
|
771
|
+
e.preventDefault();
|
|
772
|
+
_this.handleFillPick("");
|
|
773
|
+
} })),
|
|
774
|
+
options.map(function (eachOption) {
|
|
775
|
+
var _a;
|
|
776
|
+
var customColor = eachOption.color && eachOption.color.startsWith("#");
|
|
777
|
+
var isSelected = eachOption.key === _this.props.value;
|
|
778
|
+
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
|
+
? "text-white"
|
|
780
|
+
: eachOption.color
|
|
781
|
+
? ((_a = exports.FILL_CLASS[eachOption.color]) !== null && _a !== void 0 ? _a : exports.FILL_CLASS.default)
|
|
782
|
+
: _this.props.darkMode
|
|
783
|
+
? "bg-gray-700 text-white"
|
|
784
|
+
: "bg-gray-100 text-gray-700", " ").concat(isSelected
|
|
785
|
+
? "ring-2 ring-offset-2 ".concat(_this.props.darkMode ? "ring-white ring-offset-gray-800" : "ring-gray-900 ring-offset-white")
|
|
786
|
+
: ""), style: {
|
|
787
|
+
backgroundColor: customColor ? eachOption.color : undefined,
|
|
788
|
+
}, title: eachOption.label, onMouseDown: function (e) {
|
|
789
|
+
e.preventDefault();
|
|
790
|
+
_this.handleFillPick(eachOption.key);
|
|
791
|
+
} },
|
|
792
|
+
react_2.default.createElement("span", { className: "truncate" }, eachOption.label)));
|
|
793
|
+
}))),
|
|
794
|
+
];
|
|
795
|
+
};
|
|
658
796
|
_this.renderOptions = function () {
|
|
797
|
+
if (_this.isFillDropdown())
|
|
798
|
+
return _this.renderFillOptions();
|
|
799
|
+
// INFO: worked out once, not for every option
|
|
800
|
+
var isPlainFill = _this.isPlainFill();
|
|
659
801
|
var optionView = [];
|
|
660
802
|
if (_this.state.filterOptions.length <= 0) {
|
|
661
803
|
optionView.push(react_2.default.createElement("li", { className: "cursor-default select-none relative ".concat(_this.props.size === "xs" ? "px-3 py-1.5" : "px-5 py-3") }, "No options available"));
|
|
@@ -682,7 +824,11 @@ var Select = /** @class */ (function (_super) {
|
|
|
682
824
|
// hovered one
|
|
683
825
|
// INFO: the checkbox sheet stays open between taps, and a touch screen keeps
|
|
684
826
|
// :hover on the last tapped row — so it drops the hover fill there
|
|
685
|
-
|
|
827
|
+
// INFO: a plain fill cell's options read at the cell's size, each
|
|
828
|
+
// label starting where the cell's value does; the right padding
|
|
829
|
+
// keeps a long label clear of the tick, widening the list past a
|
|
830
|
+
// narrow cell instead
|
|
831
|
+
className: "cursor-default select-none relative ".concat(_this.props.size === "xs" ? "px-3 py-1.5" : isPlainFill ? "py-2 pl-6 pr-10" : "px-5 py-3", " ").concat(showCheckbox ? "" : "hover:bg-primary-300 group/option"), onMouseDown: _this.handleOnSelectChange.bind(_this, eachOption.key) },
|
|
686
832
|
react_2.default.createElement("div", { className: "flex items-center" },
|
|
687
833
|
showCheckbox && (react_2.default.createElement("span", { className: "mr-3 flex h-5 w-5 shrink-0 items-center justify-center rounded border ".concat(isSelected
|
|
688
834
|
? "border-primary-600 bg-primary-600 text-white"
|
|
@@ -700,7 +846,7 @@ var Select = /** @class */ (function (_super) {
|
|
|
700
846
|
// cell will — as a filled pill, not coloured text
|
|
701
847
|
react_2.default.createElement("span", { className: "inline-block w-max rounded-md px-2 py-0.5 ".concat(_this.props.size === "xs" ? "text-xs" : "text-sm", " font-medium ").concat(customColor
|
|
702
848
|
? "text-white"
|
|
703
|
-
: ((_a = FILL_CLASS[eachOption.color]) !== null && _a !== void 0 ? _a : FILL_CLASS.default)), style: {
|
|
849
|
+
: ((_a = exports.FILL_CLASS[eachOption.color]) !== null && _a !== void 0 ? _a : exports.FILL_CLASS.default)), style: {
|
|
704
850
|
backgroundColor: customColor
|
|
705
851
|
? eachOption.color
|
|
706
852
|
: undefined,
|
|
@@ -1058,7 +1204,7 @@ var Select = /** @class */ (function (_super) {
|
|
|
1058
1204
|
};
|
|
1059
1205
|
Select.prototype.render = function () {
|
|
1060
1206
|
var _this = this;
|
|
1061
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1207
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1062
1208
|
var defaultPadding = "px-5 py-3";
|
|
1063
1209
|
// INFO: cell mode drops the padding, so an editable row stays close to a
|
|
1064
1210
|
// read-only one, and on a desktop uses the table's own text-sm so a cell's
|
|
@@ -1108,26 +1254,57 @@ var Select = /** @class */ (function (_super) {
|
|
|
1108
1254
|
// INFO: a coloured list cell (cellInput + showTag) keeps its filled look
|
|
1109
1255
|
// while closed, so tapping into a row does not change the cell's shape;
|
|
1110
1256
|
// 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;
|
|
1111
1260
|
var isFilledCell = !!((_e = this.props.cellInput) === null || _e === void 0 ? void 0 : _e.active) &&
|
|
1112
1261
|
!!this.props.showTag &&
|
|
1113
1262
|
!Array.isArray(this.props.value) &&
|
|
1114
1263
|
!!selectedColor &&
|
|
1115
|
-
!this.state.onFocus;
|
|
1264
|
+
(!this.state.onFocus || keepsFillOpen);
|
|
1116
1265
|
// INFO: a hex cannot be a Tailwind class, so it fills inline and takes the
|
|
1117
1266
|
// white text every palette class carries — the option list's own rule
|
|
1118
1267
|
var filledClass = isFilledCell
|
|
1119
1268
|
? customColor
|
|
1120
1269
|
? "text-white"
|
|
1121
|
-
: ((_f = FILL_CLASS[selectedColor]) !== null && _f !== void 0 ? _f : FILL_CLASS.default)
|
|
1270
|
+
: ((_f = exports.FILL_CLASS[selectedColor]) !== null && _f !== void 0 ? _f : exports.FILL_CLASS.default)
|
|
1122
1271
|
: "";
|
|
1123
|
-
|
|
1272
|
+
// INFO: cellInput.fill — the table cell already carries the colour, so the
|
|
1273
|
+
// trigger keeps the label colour only and spans the cell
|
|
1274
|
+
var isCellFill = isFilledCell && !!((_g = this.props.cellInput) === null || _g === void 0 ? void 0 : _g.fill);
|
|
1275
|
+
// INFO: an empty fill-mode cell is blank, like an empty sheet cell — no
|
|
1276
|
+
// placeholder, chevron or border; a click still opens the board
|
|
1277
|
+
var isFillEmpty = this.isFillDropdown() && !this.props.value;
|
|
1278
|
+
// INFO: a value with no colour of its own — typed in through
|
|
1279
|
+
// listNewValue, or an option left uncoloured — reads as flat text in the
|
|
1280
|
+
// 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;
|
|
1285
|
+
var isFillFlat = isFillEmpty || isFillUncoloured;
|
|
1286
|
+
var isPlainFill = this.isPlainFill() && !isFilledCell;
|
|
1287
|
+
// INFO: focus clears valuePlaceholder so the options are not filtered by
|
|
1288
|
+
// the current label — an open fill cell shows the label regardless
|
|
1289
|
+
// INFO: a plain fill cell that takes no typing has nothing to filter, so
|
|
1290
|
+
// it keeps its label while open too
|
|
1291
|
+
// 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;
|
|
1124
1301
|
return (
|
|
1125
1302
|
// INFO: flex column + h-full lets the field fill the height its grid row
|
|
1126
1303
|
// was given, so the control can be dropped onto a shared baseline with a
|
|
1127
1304
|
// neighbouring field whose subLabel is taller. In a block parent h-full
|
|
1128
1305
|
// resolves to auto and the column stacks exactly like the old block did,
|
|
1129
1306
|
// so standalone usage is unchanged.
|
|
1130
|
-
react_2.default.createElement("div", { className: "w-full flex flex-col h-full ".concat((
|
|
1307
|
+
react_2.default.createElement("div", { className: "w-full flex flex-col h-full ".concat((_m = this.props.containerClassName) !== null && _m !== void 0 ? _m : "") },
|
|
1131
1308
|
this.renderMobileSelectOptions(),
|
|
1132
1309
|
this.props.type === "radioview" ? (react_2.default.createElement("div", { className: "relative" },
|
|
1133
1310
|
this.renderLabelSection(false),
|
|
@@ -1159,30 +1336,70 @@ var Select = /** @class */ (function (_super) {
|
|
|
1159
1336
|
: "Select An Option"))),
|
|
1160
1337
|
react_2.default.createElement("span", { className: "pointer-events-none absolute inset-y-0 right-0 ml-3 flex items-center pr-2" },
|
|
1161
1338
|
react_2.default.createElement(outline_1.ChevronDownIcon, { className: "h-5 w-5 text-gray-400", "aria-hidden": "true" })))) : (react_2.default.createElement(react_2.default.Fragment, null,
|
|
1162
|
-
react_2.default.createElement("div", { ref: this.triggerRef, "data-filled": isFilledCell ? selectedColor : undefined, className: "flex flex-row items-center ".concat(defaultClassName, " ").concat(
|
|
1163
|
-
?
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1339
|
+
react_2.default.createElement("div", { ref: this.triggerRef, "data-filled": isFilledCell ? selectedColor : undefined, className: "flex flex-row items-center ".concat(defaultClassName, " ").concat(isCellFill
|
|
1340
|
+
? "".concat(filledClass
|
|
1341
|
+
.split(" ")
|
|
1342
|
+
.filter(function (each) { return !each.startsWith("bg-"); })
|
|
1343
|
+
.join(" "), " justify-center !w-full bg-transparent !border-transparent cursor-pointer")
|
|
1344
|
+
: isFilledCell
|
|
1345
|
+
? // INFO: a filled cell is as wide as its label,
|
|
1346
|
+
// like a chip, rather than the whole column
|
|
1347
|
+
"".concat(filledClass, " justify-center !w-fit max-w-full")
|
|
1348
|
+
: isFillFlat || isPlainFill
|
|
1349
|
+
? "!w-full bg-transparent !border-transparent cursor-pointer"
|
|
1350
|
+
: darkSurface), style: {
|
|
1351
|
+
backgroundColor: isFilledCell && customColor && !isCellFill
|
|
1168
1352
|
? selectedColor
|
|
1169
1353
|
: undefined,
|
|
1170
1354
|
} },
|
|
1171
1355
|
this.renderValueAvatars(),
|
|
1172
|
-
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) : ((
|
|
1173
|
-
? "!w-auto bg-transparent text-center
|
|
1174
|
-
:
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
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
|
|
1357
|
+
? "".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
|
+
: isPlainFill
|
|
1359
|
+
? // INFO: the field gives up room to the chevron,
|
|
1360
|
+
// which a table cell's full-width rule for
|
|
1361
|
+
// its inputs would push past the cell's edge
|
|
1362
|
+
"!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
|
+
: 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" : "")
|
|
1368
|
+
: "".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
|
+
? handleGetLabelWidth(String(shownValue !== null && shownValue !== void 0 ? shownValue : ""))
|
|
1370
|
+
: undefined, disabled: this.props.disabled, autoFocus: this.props.autoFocus, placeholder: isFillEmpty
|
|
1371
|
+
? ""
|
|
1372
|
+
: isPlainFill
|
|
1373
|
+
? // INFO: a plain fill cell that takes typing
|
|
1374
|
+
// empties its field to search while open, so
|
|
1375
|
+
// its value shows greyed in its place
|
|
1376
|
+
this.handleGetSelectedLabels()
|
|
1377
|
+
: this.props.placeholder
|
|
1378
|
+
? this.props.placeholder
|
|
1379
|
+
: "Select An Option", autoComplete: "off", onFocus: this.handleFocus, onClick: this.handleReopenOnClick, onBlur: this.handleBlur, onChange: this.handleOnChange,
|
|
1380
|
+
// INFO: Escape leaves a plain fill cell or a colour
|
|
1381
|
+
// board cell, as it does the text cells beside it
|
|
1382
|
+
onKeyDown: isPlainFill || this.isFillDropdown()
|
|
1383
|
+
? function (e) {
|
|
1384
|
+
if (e.key !== "Escape")
|
|
1385
|
+
return;
|
|
1386
|
+
e.preventDefault();
|
|
1387
|
+
_this.setState({ onFocus: false });
|
|
1388
|
+
e.currentTarget.blur();
|
|
1389
|
+
}
|
|
1390
|
+
: undefined, readOnly: this.props.disableKeyboard, style: {
|
|
1179
1391
|
// INFO: on a filled cell the hex is the fill, so the
|
|
1180
1392
|
// label would disappear into it
|
|
1181
1393
|
color: !isFilledCell && customColor
|
|
1182
1394
|
? selectedColor
|
|
1183
1395
|
: undefined,
|
|
1184
1396
|
} }),
|
|
1185
|
-
|
|
1397
|
+
isPlainFill ? (
|
|
1398
|
+
// INFO: no clear icon in a plain fill cell — a quiet
|
|
1399
|
+
// 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())),
|
|
1186
1403
|
this.props.showTag && this.renderTags())),
|
|
1187
1404
|
this.renderOptionContainer())),
|
|
1188
1405
|
react_2.default.createElement("span", { className: "text-red-500 text-sm" }, this.state.error))))));
|