@haniffalab/cherita-react 0.2.0-dev.2024-09-26.f9979478 → 0.2.0-dev.2024-09-26.d9293c4c

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.
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ObsValueList = ObsValueList;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactVirtual = require("@tanstack/react-virtual");
9
- var _lodash = _interopRequireDefault(require("lodash"));
10
- var _reactBootstrap = require("react-bootstrap");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
- function ObsValueList(_ref) {
16
- var _virtualItems$0$start, _virtualItems$;
17
- let {
18
- item,
19
- onChange,
20
- getFillColor
21
- } = _ref;
22
- const [parentNode, setParentNode] = (0, _react.useState)(null);
23
- const valueVirtualizer = (0, _reactVirtual.useVirtualizer)({
24
- count: item.values.length,
25
- getScrollElement: () => parentNode,
26
- estimateSize: () => 44,
27
- overscan: 25
28
- });
29
- const refCallback = (0, _react.useCallback)(node => {
30
- setParentNode(node);
31
- }, []);
32
- const virtualItems = valueVirtualizer.getVirtualItems();
33
- (0, _react.useEffect)(() => {
34
- valueVirtualizer.measure();
35
- }, [valueVirtualizer, parentNode === null || parentNode === void 0 ? void 0 : parentNode.clientHeight]);
36
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
37
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
38
- ref: refCallback,
39
- style: {
40
- overflowY: "auto",
41
- maxHeight: "80vh"
42
- },
43
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
44
- style: {
45
- height: "".concat(valueVirtualizer.getTotalSize(), "px"),
46
- width: "100%",
47
- position: "relative",
48
- willChange: "transform"
49
- },
50
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
51
- style: {
52
- position: "absolute",
53
- top: 0,
54
- left: 0,
55
- width: "100%",
56
- transform: "translateY(".concat((_virtualItems$0$start = (_virtualItems$ = virtualItems[0]) === null || _virtualItems$ === void 0 ? void 0 : _virtualItems$.start) !== null && _virtualItems$0$start !== void 0 ? _virtualItems$0$start : 0, "px)")
57
- },
58
- children: virtualItems.map(virtualItem => {
59
- const value = item.values[virtualItem.index];
60
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
61
- "data-index": virtualItem.index,
62
- ref: valueVirtualizer.measureElement,
63
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
64
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
65
- className: "d-flex",
66
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
67
- className: "flex-grow-1",
68
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Form.Check, {
69
- // prettier-ignore
70
- className: "obs-value-list-check",
71
- type: "switch",
72
- id: "custom-switch",
73
- label: value,
74
- checked: !_lodash.default.includes(item.omit, item.codes[value]),
75
- onChange: () => onChange(value)
76
- })
77
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
78
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
79
- xmlns: "http://www.w3.org/2000/svg",
80
- width: "24",
81
- height: "24",
82
- fill: "currentColor",
83
- viewBox: "0 0 10 10",
84
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
85
- x: "0",
86
- y: "0",
87
- width: "10",
88
- height: "10",
89
- fill: getFillColor(value)
90
- })
91
- })
92
- })]
93
- })
94
- }, value)
95
- }, virtualItem.key);
96
- })
97
- })
98
- })
99
- })
100
- });
101
- }