@darajs/core 1.0.0-a.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,83 @@
1
- ***************************
2
- DARA-CORE
3
- ***************************
4
-
5
- [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
6
-
7
- ![image](https://i.kym-cdn.com/entries/icons/original/000/013/564/doge.jpg)
1
+ # Dara Application Framework
2
+
3
+ <picture>
4
+ <source srcset="https://github.com/causalens/dara/blob/master/img/dara_dark.svg?raw=true" media="(prefers-color-scheme: dark)">
5
+ <img src="https://github.com/causalens/dara/blob/master/img/dara_light.svg?raw=true" alt="Dara Logo">
6
+ </picture>
7
+
8
+ ![Master tests](https://github.com/causalens/dara/actions/workflows/tests.yml/badge.svg?branch=master)
9
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
10
+ [![PyPI](https://img.shields.io/pypi/v/dara-core.svg?color=dark-green)](https://pypi.org/project/dara-core/)
11
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dara-core.svg?color=dark-green)](https://pypi.org/project/dara-core/)
12
+ [![NPM](https://img.shields.io/npm/v/@darajs/components.svg?color=dark-green)](https://www.npmjs.com/package/@darajs/components)
13
+
14
+ ### Build decision apps in Python
15
+
16
+ _Tap into the power of causality by transforming data into interactive graphs and applications_
17
+
18
+ Dara is a dynamic application framework designed for creating interactive web apps with ease, all in pure Python. Over the past two years, Dara has fueled the development of hundreds of apps, now widely used and appreciated by both our customers and our in-house teams!
19
+
20
+ ## Quickstart
21
+
22
+ To get started with Dara, you can use the `create-dara-app` CLI tool to create a new app.
23
+
24
+ ```bash
25
+ pip install create-dara-app
26
+ ```
27
+
28
+ You can also use [`pipx`](https://pypa.github.io/pipx/) to install the CLI tool in an isolated environment.
29
+
30
+ Then simply run the following command to create a new app.
31
+
32
+ ```bash
33
+ create-dara-app
34
+ ```
35
+
36
+ By default the CLI will attempt to scaffold your project with [`poetry`](https://python-poetry.org/) but will fall back to `pip` if `poetry` is not present. This can be overriden with `--packaging pip` or `--packaging poetry` flag.
37
+
38
+ After the project is created, you can run it with:
39
+
40
+ ```bash
41
+ cd my-dara-app
42
+ # with poetry installation
43
+ poetry run dara start
44
+ # with pip installation
45
+ dara start
46
+ ```
47
+
48
+ ![Dara App](https://github.com/causalens/dara/blob/master/img/components_gallery.png?raw=true)
49
+
50
+ Note: `pip` installation uses [PEP 660](https://peps.python.org/pep-0660/) `pyproject.toml`-based editable installs which require `pip >= 21.3` and `setuptools >= 64.0.0`. You can upgrade both with:
51
+
52
+ ```bash
53
+ python -m pip install --upgrade pip
54
+ pip install --user --upgrade setuptools
55
+ ```
56
+
57
+ For more details check out our [Documentation](https://dara.causalens.com/docs/category/build-dara-apps).
58
+
59
+ ## Dara App examples
60
+
61
+ Explore some of our favorite apps - a great way of getting started and getting to know the framework!
62
+
63
+ | Dara App | Description |
64
+ | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
65
+ | ![Large Language Model](https://github.com/causalens/dara/blob/master/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
66
+ | ![Plot Interactivity](https://github.com/causalens/dara/blob/master/img/plot_interactivity.png?raw=true) | Demonstrates how to enable the user to interact with plots, trigger actions based on clicks, mouse movements and other interactions with `Bokeh` or `Plotly` plots |
67
+ | ![Graph Editor](https://github.com/causalens/dara/blob/master/img/graph_viewer.png?raw=true) | Demonstrates how to use the `CausalGraphViewer` component to display your graphs or networks, customising the displayed information through colors and tooltips, and updating the page based on user interaction. |
68
+
69
+ Check out our [App Gallery](https://dara.causalens.com/gallery) for more inspiration!
70
+
71
+ ## Repository introduction
72
+
73
+ This repository covers the Dara Application Framework first-party packages.
74
+
75
+ - `dara-core`: The core of the Dara framework, this includes the core framework code for creating applications.
76
+ - `dara-components`: Components for the Dara Framework.
77
+ - `create-dara-app`: A CLI tool for creating new Dara applications.
78
+
79
+ More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/master/CONTRIBUTING.md) file.
80
+
81
+ ## License
82
+
83
+ Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/master/LICENSE).
@@ -17074,10 +17074,10 @@ var __publicField = (obj, key, value) => {
17074
17074
  }
17075
17075
  var _baseIsEqual = baseIsEqual$3;
17076
17076
  var baseIsEqual$2 = _baseIsEqual;
17077
- function isEqual$3(value, other) {
17077
+ function isEqual$4(value, other) {
17078
17078
  return baseIsEqual$2(value, other);
17079
17079
  }
17080
- var isEqual_1 = isEqual$3;
17080
+ var isEqual_1 = isEqual$4;
17081
17081
  function useDeepCompare(value) {
17082
17082
  const ref = React$2.useRef();
17083
17083
  if (!isEqual_1(value, ref.current)) {
@@ -17974,7 +17974,7 @@ var __publicField = (obj, key, value) => {
17974
17974
  var _a;
17975
17975
  return jsxRuntime.exports.jsxs(Wrapper$8, { className: props.className, style: props.style, children: [jsxRuntime.exports.jsxs(Loader, { color: props.color, size: props.size, children: [jsxRuntime.exports.jsx("div", { className: "sk-chase-dot" }), jsxRuntime.exports.jsx("div", { className: "sk-chase-dot" }), jsxRuntime.exports.jsx("div", { className: "sk-chase-dot" }), jsxRuntime.exports.jsx("div", { className: "sk-chase-dot" }), jsxRuntime.exports.jsx("div", { className: "sk-chase-dot" }), jsxRuntime.exports.jsx("div", { className: "sk-chase-dot" })] }), (props.showText || props.text) && jsxRuntime.exports.jsx(LoadingText, { color: props.color, children: (_a = props.text) !== null && _a !== void 0 ? _a : "LOADING" })] });
17976
17976
  }
17977
- var __rest$4 = globalThis && globalThis.__rest || function(s, e3) {
17977
+ var __rest$5 = globalThis && globalThis.__rest || function(s, e3) {
17978
17978
  var t2 = {};
17979
17979
  for (var p2 in s)
17980
17980
  if (Object.prototype.hasOwnProperty.call(s, p2) && e3.indexOf(p2) < 0)
@@ -18082,7 +18082,7 @@ var __publicField = (obj, key, value) => {
18082
18082
  secondary: SecondaryButton
18083
18083
  };
18084
18084
  function Button(_a, ref) {
18085
- var { autoFocus, children, className, disabled: disabled2, download, href, loading, id, onClick, outline = false, style, styling = "primary", type = "button" } = _a, props = __rest$4(_a, ["autoFocus", "children", "className", "disabled", "download", "href", "loading", "id", "onClick", "outline", "style", "styling", "type"]);
18085
+ var { autoFocus, children, className, disabled: disabled2, download, href, loading, id, onClick, outline = false, style, styling = "primary", type = "button" } = _a, props = __rest$5(_a, ["autoFocus", "children", "className", "disabled", "download", "href", "loading", "id", "onClick", "outline", "style", "styling", "type"]);
18086
18086
  const currentTheme = useClTheme();
18087
18087
  const Component = stylingMap[styling];
18088
18088
  const content = loading ? jsxRuntime.exports.jsx(StyledLoading, { color: outline ? currentTheme.colors.grey2 : currentTheme.colors.blue1 }) : children;
@@ -18482,7 +18482,7 @@ var __publicField = (obj, key, value) => {
18482
18482
  return jsxRuntime.exports.jsx(CheckboxWrapper, { "aria-disabled": props.disabled, children: jsxRuntime.exports.jsx(Checkbox, { disabled: isSelectPermitted ? props.disabled : ((_a = checkedState.find((option) => option.value === item.value)) === null || _a === void 0 ? void 0 : _a.state) === false, id: index2, isListStyle: props.isListStyle, label: item.label ? item.label : item.value, onChange: (checked, e3) => onChangeValue(e3), selected: (_b = checkedState.find((option) => option.value === item.value)) === null || _b === void 0 ? void 0 : _b.state }) }, `item-${index2}`);
18483
18483
  })] });
18484
18484
  }
18485
- var __rest$3 = globalThis && globalThis.__rest || function(s, e3) {
18485
+ var __rest$4 = globalThis && globalThis.__rest || function(s, e3) {
18486
18486
  var t2 = {};
18487
18487
  for (var p2 in s)
18488
18488
  if (Object.prototype.hasOwnProperty.call(s, p2) && e3.indexOf(p2) < 0)
@@ -18541,7 +18541,7 @@ var __publicField = (obj, key, value) => {
18541
18541
  color: ${(props) => props.theme.colors.error};
18542
18542
  `;
18543
18543
  const Input$1 = React$2.forwardRef((_a, ref) => {
18544
- var { type = "text" } = _a, props = __rest$3(_a, ["type"]);
18544
+ var { type = "text" } = _a, props = __rest$4(_a, ["type"]);
18545
18545
  const onChange2 = (e3) => {
18546
18546
  const target = e3.target;
18547
18547
  if (props.onChange) {
@@ -27593,7 +27593,7 @@ var __publicField = (obj, key, value) => {
27593
27593
  var dateToCompare = toDate$1(dirtyDateToCompare);
27594
27594
  return date2.getTime() < dateToCompare.getTime();
27595
27595
  }
27596
- function isEqual$2(dirtyLeftDate, dirtyRightDate) {
27596
+ function isEqual$3(dirtyLeftDate, dirtyRightDate) {
27597
27597
  requiredArgs$1(2, arguments);
27598
27598
  var dateLeft = toDate$1(dirtyLeftDate);
27599
27599
  var dateRight = toDate$1(dirtyRightDate);
@@ -36565,7 +36565,7 @@ var __publicField = (obj, key, value) => {
36565
36565
  date2.setHours(23, 59, 59, 999);
36566
36566
  return date2;
36567
36567
  }
36568
- function isEqual$1(dirtyLeftDate, dirtyRightDate) {
36568
+ function isEqual$2(dirtyLeftDate, dirtyRightDate) {
36569
36569
  requiredArgs(2, arguments);
36570
36570
  var dateLeft = toDate(dirtyLeftDate);
36571
36571
  var dateRight = toDate(dirtyRightDate);
@@ -39765,7 +39765,7 @@ var __publicField = (obj, key, value) => {
39765
39765
  return e3 && t2 ? isSameDay(e3, t2) : !e3 && !t2;
39766
39766
  }
39767
39767
  function je(e3, t2) {
39768
- return e3 && t2 ? isEqual$1(e3, t2) : !e3 && !t2;
39768
+ return e3 && t2 ? isEqual$2(e3, t2) : !e3 && !t2;
39769
39769
  }
39770
39770
  function He(e3, t2, r2) {
39771
39771
  var n2, o2 = startOfDay(t2), a2 = endOfDay(r2);
@@ -41067,7 +41067,7 @@ var __publicField = (obj, key, value) => {
41067
41067
  } }]), a2;
41068
41068
  }(), jt = "input", Ht = "navigate";
41069
41069
  const reactDatepicker = "";
41070
- var __rest$2 = globalThis && globalThis.__rest || function(s, e3) {
41070
+ var __rest$3 = globalThis && globalThis.__rest || function(s, e3) {
41071
41071
  var t2 = {};
41072
41072
  for (var p2 in s)
41073
41073
  if (Object.prototype.hasOwnProperty.call(s, p2) && e3.indexOf(p2) < 0)
@@ -41254,7 +41254,7 @@ var __publicField = (obj, key, value) => {
41254
41254
  (_a2 = props.dropdownRef) === null || _a2 === void 0 ? void 0 : _a2.call(props, value);
41255
41255
  };
41256
41256
  return jsxRuntime.exports.jsx(Tooltip, { content: props.errorMsg, disabled: !props.errorMsg, styling: "error", children: jsxRuntime.exports.jsxs(Wrapper$5, { className: props.className, isDisabled: props.disabled, isErrored: !!props.errorMsg, onClick: props.onClick, style: props.style, children: [jsxRuntime.exports.jsxs(SelectButtonPrimary, Object.assign({ disabled: props.disabled }, buttonProps, { ref: setButtonReference, type: "button", children: [jsxRuntime.exports.jsx(SelectedItem$1, { size: props.size, children: selectedItem ? selectedItem.label : "Select" }), jsxRuntime.exports.jsx(Chevron$2, { disabled: props.disabled, isOpen })] })), ReactDOM__default.default.createPortal(jsxRuntime.exports.jsx(DropdownList$1, Object.assign({}, menuProps, attributes.popper, { className: `${(_a = menuProps === null || menuProps === void 0 ? void 0 : menuProps.className) !== null && _a !== void 0 ? _a : ""} ${(_c = (_b = attributes === null || attributes === void 0 ? void 0 : attributes.popper) === null || _b === void 0 ? void 0 : _b.className) !== null && _c !== void 0 ? _c : ""} ${props.itemClass}`, displacement: props.displacement, isOpen, maxItems: 7, ref: setMenuReference, style: Object.assign(Object.assign({}, styles2.popper), { marginTop: `0.8rem`, width: "16.25rem", zIndex: 9999 }), children: props.items.map((item, index2) => {
41257
- const _a2 = getItemProps({ index: index2, item }), { itemClassName } = _a2, itemProps = __rest$2(_a2, ["itemClassName"]);
41257
+ const _a2 = getItemProps({ index: index2, item }), { itemClassName } = _a2, itemProps = __rest$3(_a2, ["itemClassName"]);
41258
41258
  return React$2.createElement(DatepickerListItem, Object.assign({}, itemProps, { "aria-selected": selectedItem.label === item.label, className: `${itemClassName} ${props.itemClass}`, hovered: index2 === highlightedIndex, isSelected: selectedItem.label === item.label, key: `item-${index2}`, size: props.size, title: item.label }), item.label);
41259
41259
  }) })), document.body)] }) });
41260
41260
  }
@@ -43006,7 +43006,7 @@ var __publicField = (obj, key, value) => {
43006
43006
 
43007
43007
  background-color: transparent !important;
43008
43008
  `;
43009
- var __rest$1 = globalThis && globalThis.__rest || function(s, e3) {
43009
+ var __rest$2 = globalThis && globalThis.__rest || function(s, e3) {
43010
43010
  var t2 = {};
43011
43011
  for (var p2 in s)
43012
43012
  if (Object.prototype.hasOwnProperty.call(s, p2) && e3.indexOf(p2) < 0)
@@ -43140,7 +43140,7 @@ var __publicField = (obj, key, value) => {
43140
43140
  (_a2 = props.dropdownRef) === null || _a2 === void 0 ? void 0 : _a2.call(props, value);
43141
43141
  };
43142
43142
  return jsxRuntime.exports.jsx(Tooltip, { content: props.errorMsg, disabled: !props.errorMsg, styling: "error", children: jsxRuntime.exports.jsxs(Wrapper$4, { className: props.className, isDisabled: props.disabled, isErrored: !!props.errorMsg, isOpen, onClick: props.onClick, style: props.style, children: [jsxRuntime.exports.jsxs(SelectButton, Object.assign({ disabled: props.disabled, isOpen }, buttonProps, { ref: setButtonReference, type: "button", children: [jsxRuntime.exports.jsx(SelectedItem, { size: props.size, children: (_b = (_a = selectedItem === null ? props.placeholder : selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.label) !== null && _a !== void 0 ? _a : props.placeholder) !== null && _b !== void 0 ? _b : "Select" }), jsxRuntime.exports.jsx(Chevron$2, { disabled: props.disabled, isOpen })] })), ReactDOM__default.default.createPortal(jsxRuntime.exports.jsx(DropdownList, Object.assign({}, menuProps, attributes.popper, { className: `${(_c = menuProps === null || menuProps === void 0 ? void 0 : menuProps.className) !== null && _c !== void 0 ? _c : ""} ${(_e2 = (_d = attributes === null || attributes === void 0 ? void 0 : attributes.popper) === null || _d === void 0 ? void 0 : _d.className) !== null && _e2 !== void 0 ? _e2 : ""} ${props.itemClass}`, isOpen, maxItems: props.maxItems, ref: setMenuReference, style: Object.assign(Object.assign({}, styles2.popper), { width: props.applySameWidthModifier === false ? void 0 : parseFloat((_f = styles2.popper) === null || _f === void 0 ? void 0 : _f.width) + 2, zIndex: 9999 }), children: props.items.map((item, index2) => {
43143
- const _a2 = getItemProps({ index: index2, item }), { itemClassName } = _a2, itemProps = __rest$1(_a2, ["itemClassName"]);
43143
+ const _a2 = getItemProps({ index: index2, item }), { itemClassName } = _a2, itemProps = __rest$2(_a2, ["itemClassName"]);
43144
43144
  return React$2.createElement(ListItem, Object.assign({}, itemProps, { className: `${itemClassName} ${props.itemClass}`, hovered: index2 === highlightedIndex, key: `item-${index2}`, size: props.size, title: item.label }), item.label);
43145
43145
  }) })), document.body)] }) });
43146
43146
  }
@@ -45435,6 +45435,55 @@ var __publicField = (obj, key, value) => {
45435
45435
  swapOpacity: false
45436
45436
  };
45437
45437
  var convertCurry = convert.bind(null, React__default.default.createElement);
45438
+ var safeIsNaN$1 = Number.isNaN || function ponyfill(value) {
45439
+ return typeof value === "number" && value !== value;
45440
+ };
45441
+ function isEqual$1(first, second) {
45442
+ if (first === second) {
45443
+ return true;
45444
+ }
45445
+ if (safeIsNaN$1(first) && safeIsNaN$1(second)) {
45446
+ return true;
45447
+ }
45448
+ return false;
45449
+ }
45450
+ function areInputsEqual$1(newInputs, lastInputs) {
45451
+ if (newInputs.length !== lastInputs.length) {
45452
+ return false;
45453
+ }
45454
+ for (var i2 = 0; i2 < newInputs.length; i2++) {
45455
+ if (!isEqual$1(newInputs[i2], lastInputs[i2])) {
45456
+ return false;
45457
+ }
45458
+ }
45459
+ return true;
45460
+ }
45461
+ function memoizeOne$1(resultFn, isEqual2) {
45462
+ if (isEqual2 === void 0) {
45463
+ isEqual2 = areInputsEqual$1;
45464
+ }
45465
+ var cache2 = null;
45466
+ function memoized() {
45467
+ var newArgs = [];
45468
+ for (var _i = 0; _i < arguments.length; _i++) {
45469
+ newArgs[_i] = arguments[_i];
45470
+ }
45471
+ if (cache2 && cache2.lastThis === this && isEqual2(newArgs, cache2.lastArgs)) {
45472
+ return cache2.lastResult;
45473
+ }
45474
+ var lastResult = resultFn.apply(this, newArgs);
45475
+ cache2 = {
45476
+ lastResult,
45477
+ lastArgs: newArgs,
45478
+ lastThis: this
45479
+ };
45480
+ return lastResult;
45481
+ }
45482
+ memoized.clear = function clear() {
45483
+ cache2 = null;
45484
+ };
45485
+ return memoized;
45486
+ }
45438
45487
  var reactTable = { exports: {} };
45439
45488
  var reactTable_production_min = { exports: {} };
45440
45489
  (function(module2, exports2) {
@@ -48080,6 +48129,24 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
48080
48129
  _ref7.itemSize;
48081
48130
  }
48082
48131
  });
48132
+ function shallowDiffers(prev, next) {
48133
+ for (var attribute in prev) {
48134
+ if (!(attribute in next)) {
48135
+ return true;
48136
+ }
48137
+ }
48138
+ for (var _attribute in next) {
48139
+ if (prev[_attribute] !== next[_attribute]) {
48140
+ return true;
48141
+ }
48142
+ }
48143
+ return false;
48144
+ }
48145
+ function areEqual(prevProps, nextProps) {
48146
+ var prevStyle = prevProps.style, prevRest = _objectWithoutPropertiesLoose$6(prevProps, ["style"]);
48147
+ var nextStyle = nextProps.style, nextRest = _objectWithoutPropertiesLoose$6(nextProps, ["style"]);
48148
+ return !shallowDiffers(prevStyle, nextStyle) && !shallowDiffers(prevRest, nextRest);
48149
+ }
48083
48150
  const GlobalStyle = styled.createGlobalStyle`
48084
48151
  body {
48085
48152
  .DatetimeFilterSelect {
@@ -48451,7 +48518,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
48451
48518
  }
48452
48519
  switch (operator) {
48453
48520
  case DateOperator.EQ:
48454
- return isEqual$2(parsedValue, filterValue);
48521
+ return isEqual$3(parsedValue, filterValue);
48455
48522
  case DateOperator.GT:
48456
48523
  return isAfter$1(parsedValue, filterValue);
48457
48524
  case DateOperator.LT:
@@ -48664,7 +48731,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
48664
48731
  }, [allColumns, allowColumnHiding]);
48665
48732
  return jsxRuntime.exports.jsxs(HeaderOptions, { ref: setOptionsElement, children: [jsxRuntime.exports.jsx(HeaderOptionsIcon, { icon: faEllipsisV, onClick: toggleOptions }), ReactDOM__default.default.createPortal(jsxRuntime.exports.jsx(OptionsDropdownList, Object.assign({}, attributes.popper, { isOpen: showOptions, ref: setPopperElement, style: Object.assign(Object.assign(Object.assign({}, styles2.popper), { maxHeight: 800, minWidth: 150, zIndex: 9999 }), style), children: jsxRuntime.exports.jsx(SectionedList, { items: allowColumnHiding ? [resetFunctions, columnToggles] : [resetFunctions], onSelect: onOptionSelect }) })), document.body)] });
48666
48733
  };
48667
- var __rest = globalThis && globalThis.__rest || function(s, e3) {
48734
+ var __rest$1 = globalThis && globalThis.__rest || function(s, e3) {
48668
48735
  var t2 = {};
48669
48736
  for (var p2 in s)
48670
48737
  if (Object.prototype.hasOwnProperty.call(s, p2) && e3.indexOf(p2) < 0)
@@ -48677,6 +48744,139 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
48677
48744
  return t2;
48678
48745
  };
48679
48746
  const ROW_HEIGHT = 40;
48747
+ const shouldForwardProp$2 = (prop) => !["isSorted", "onClickRow"].includes(prop);
48748
+ const Row = styled__default.default.div.withConfig({ shouldForwardProp: shouldForwardProp$2 })`
48749
+ cursor: ${(props) => props.onClickRow ? "pointer" : "default"};
48750
+ display: flex;
48751
+
48752
+ :hover {
48753
+ div {
48754
+ background-color: ${(props) => props.theme.colors.grey1};
48755
+ }
48756
+ }
48757
+
48758
+ :active,
48759
+ focused {
48760
+ div {
48761
+ background-color: ${(props) => props.theme.colors.grey2};
48762
+ }
48763
+ }
48764
+ `;
48765
+ const RowPlaceholder = styled__default.default(Row)`
48766
+ position: absolute;
48767
+ left: 0px;
48768
+
48769
+ display: flex;
48770
+ align-items: center;
48771
+ justify-content: center;
48772
+ `;
48773
+ const CellPlaceholder = styled__default.default.div`
48774
+ min-width: 80px;
48775
+ height: 0.7rem;
48776
+ margin: 0.5rem;
48777
+
48778
+ background: ${(props) => `linear-gradient(to right, ${props.theme.colors.grey2}, ${curriedTransparentize$2(0.2, props.theme.colors.grey3)}, ${props.theme.colors.grey2});`};
48779
+ background-size: 50%;
48780
+ border-radius: 0.5rem;
48781
+
48782
+ animation-name: aniHorizontal;
48783
+ animation-duration: 3.5s;
48784
+ animation-timing-function: linear;
48785
+ animation-iteration-count: infinite;
48786
+
48787
+ @keyframes aniHorizontal {
48788
+ 0% {
48789
+ background-position: -100% 0;
48790
+ }
48791
+
48792
+ 100% {
48793
+ background-position: 100% 0;
48794
+ }
48795
+ }
48796
+ `;
48797
+ const Cell = styled__default.default.div`
48798
+ display: flex !important;
48799
+ align-items: center;
48800
+
48801
+ min-width: 80px;
48802
+ height: 2.5rem;
48803
+
48804
+ color: ${(props) => props.theme.colors.grey6};
48805
+
48806
+ background-color: ${(props) => props.theme.colors.blue1};
48807
+ border-bottom: 1px solid ${(props) => props.theme.colors.grey3};
48808
+
48809
+ :last-child {
48810
+ border-right: 0;
48811
+ }
48812
+ `;
48813
+ const CellContent = styled__default.default.span`
48814
+ overflow: hidden;
48815
+
48816
+ width: 100%;
48817
+ padding: 0 1rem;
48818
+
48819
+ text-overflow: ellipsis;
48820
+ white-space: nowrap;
48821
+ `;
48822
+ const RenderRow = React__namespace.memo(({ data: { width, currentEditCell, headerGroups, rows, prepareRow, getItem, totalColumnsWidth, onClickRow, throttledClickRow, backgroundColor, mappedColumns }, index: index2, style: renderRowStyle }) => {
48823
+ let row = rows[index2];
48824
+ if (getItem) {
48825
+ const value = getItem(index2);
48826
+ if (!value) {
48827
+ row = null;
48828
+ } else {
48829
+ row.original = value;
48830
+ row.values = value;
48831
+ }
48832
+ }
48833
+ if (!row) {
48834
+ return jsxRuntime.exports.jsx("div", { children: headerGroups.map((headerGroup, gidx) => jsxRuntime.exports.jsx(RowPlaceholder, { style: {
48835
+ height: ROW_HEIGHT,
48836
+ top: (index2 + 1) * ROW_HEIGHT,
48837
+ width: totalColumnsWidth > width ? totalColumnsWidth : "100%"
48838
+ }, children: headerGroup === null || headerGroup === void 0 ? void 0 : headerGroup.headers.map((col, cidx) => {
48839
+ const headerProps = col.getHeaderProps();
48840
+ const headerWidth = headerProps.style.width === "NaNpx" ? mappedColumns[cidx].width : headerProps.style.width;
48841
+ return jsxRuntime.exports.jsx(CellPlaceholder, { style: {
48842
+ maxWidth: col.maxWidth,
48843
+ width: headerWidth
48844
+ } }, `col-${index2}-${cidx}`);
48845
+ }) }, `row-${gidx}`)) });
48846
+ }
48847
+ prepareRow(row);
48848
+ const onClick = () => {
48849
+ if (onClickRow) {
48850
+ throttledClickRow(row.original);
48851
+ }
48852
+ };
48853
+ const _a = row.getRowProps({ style: renderRowStyle }), { style: rowStyle } = _a, restRow = __rest$1(_a, ["style"]);
48854
+ return React$2.createElement(Row, Object.assign({}, restRow, { key: `row-${index2}`, onClick, onClickRow, style: Object.assign(Object.assign({}, rowStyle), { top: (index2 + 1) * ROW_HEIGHT, width: totalColumnsWidth > width ? totalColumnsWidth : "100%" }) }), row.cells.map((cell, colIdx) => {
48855
+ var _a2;
48856
+ const cellProps = cell.getCellProps();
48857
+ return React$2.createElement(
48858
+ Cell,
48859
+ Object.assign({}, cellProps, { key: `cell-${index2}-${colIdx}`, style: Object.assign(Object.assign({}, cellProps.style), { backgroundColor, justifyContent: mappedColumns[colIdx].align, maxWidth: (_a2 = cell.column) === null || _a2 === void 0 ? void 0 : _a2.maxWidth, width: cellProps.style.width === "NaNpx" ? mappedColumns[colIdx].width : cellProps.style.width }) }),
48860
+ jsxRuntime.exports.jsx(CellContent, { children: cell.render("Cell", {
48861
+ colIdx,
48862
+ currentEditCell,
48863
+ rowIdx: index2
48864
+ }) })
48865
+ );
48866
+ }));
48867
+ }, areEqual);
48868
+ var __rest = globalThis && globalThis.__rest || function(s, e3) {
48869
+ var t2 = {};
48870
+ for (var p2 in s)
48871
+ if (Object.prototype.hasOwnProperty.call(s, p2) && e3.indexOf(p2) < 0)
48872
+ t2[p2] = s[p2];
48873
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
48874
+ for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s); i2 < p2.length; i2++) {
48875
+ if (e3.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i2]))
48876
+ t2[p2[i2]] = s[p2[i2]];
48877
+ }
48878
+ return t2;
48879
+ };
48680
48880
  const Wrapper$3 = styled__default.default.div`
48681
48881
  display: inline-block;
48682
48882
  width: 100%;
@@ -48787,86 +48987,11 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
48787
48987
  width: 10px;
48788
48988
  height: 100%;
48789
48989
  `;
48790
- const shouldForwardProp$2 = (prop) => !["isSorted", "onClickRow"].includes(prop);
48791
48990
  const SortIcon = styled__default.default(FontAwesomeIcon).withConfig({ shouldForwardProp: shouldForwardProp$2 })`
48792
48991
  color: ${(props) => props.isSorted ? props.theme.colors.grey3 : props.theme.colors.blue3};
48793
48992
  `;
48794
48993
  const TooltipIcon = styled__default.default(FontAwesomeIcon)`
48795
48994
  color: ${(props) => props.theme.colors.grey4};
48796
- `;
48797
- const Row = styled__default.default.div.withConfig({ shouldForwardProp: shouldForwardProp$2 })`
48798
- cursor: ${(props) => props.onClickRow ? "pointer" : "default"};
48799
- display: flex;
48800
-
48801
- :hover {
48802
- div {
48803
- background-color: ${(props) => props.theme.colors.grey1};
48804
- }
48805
- }
48806
-
48807
- :active,
48808
- focused {
48809
- div {
48810
- background-color: ${(props) => props.theme.colors.grey2};
48811
- }
48812
- }
48813
- `;
48814
- const RowPlaceholder = styled__default.default(Row)`
48815
- position: absolute;
48816
- left: 0px;
48817
-
48818
- display: flex;
48819
- align-items: center;
48820
- justify-content: center;
48821
- `;
48822
- const CellPlaceholder = styled__default.default.div`
48823
- min-width: 80px;
48824
- height: 0.7rem;
48825
- margin: 0.5rem;
48826
-
48827
- background: ${(props) => `linear-gradient(to right, ${props.theme.colors.grey2}, ${curriedTransparentize$2(0.2, props.theme.colors.grey3)}, ${props.theme.colors.grey2});`};
48828
- background-size: 50%;
48829
- border-radius: 0.5rem;
48830
-
48831
- animation-name: aniHorizontal;
48832
- animation-duration: 3.5s;
48833
- animation-timing-function: linear;
48834
- animation-iteration-count: infinite;
48835
-
48836
- @keyframes aniHorizontal {
48837
- 0% {
48838
- background-position: -100% 0;
48839
- }
48840
-
48841
- 100% {
48842
- background-position: 100% 0;
48843
- }
48844
- }
48845
- `;
48846
- const Cell = styled__default.default.div`
48847
- display: flex !important;
48848
- align-items: center;
48849
-
48850
- min-width: 80px;
48851
- height: 2.5rem;
48852
-
48853
- color: ${(props) => props.theme.colors.grey6};
48854
-
48855
- background-color: ${(props) => props.theme.colors.blue1};
48856
- border-bottom: 1px solid ${(props) => props.theme.colors.grey3};
48857
-
48858
- :last-child {
48859
- border-right: 0;
48860
- }
48861
- `;
48862
- const CellContent = styled__default.default.span`
48863
- overflow: hidden;
48864
-
48865
- width: 100%;
48866
- padding: 0 1rem;
48867
-
48868
- text-overflow: ellipsis;
48869
- white-space: nowrap;
48870
48995
  `;
48871
48996
  const getSortIcon = (isSorted, isSortedDesc) => {
48872
48997
  if (!isSorted) {
@@ -48916,6 +49041,19 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
48916
49041
  EDIT_INPUT: EditInputCell,
48917
49042
  EDIT_SELECT: EditSelectCell
48918
49043
  };
49044
+ const createItemData = memoizeOne$1((width, currentEditCell, headerGroups, rows, prepareRow, getItem, totalColumnsWidth, onClickRow, throttledClickRow, backgroundColor, mappedColumns) => ({
49045
+ backgroundColor,
49046
+ currentEditCell,
49047
+ getItem,
49048
+ headerGroups,
49049
+ mappedColumns,
49050
+ onClickRow,
49051
+ prepareRow,
49052
+ rows,
49053
+ throttledClickRow,
49054
+ totalColumnsWidth,
49055
+ width
49056
+ }));
48919
49057
  const Table = React$2.forwardRef(({ allowHiding, backgroundColor, className, columns, data, getItem, initialSort = [], itemCount, maxRows, onAction, onChange: onChange2, onClickRow, onItemsRendered, onFilter, onSort, showTableOptions, style, tableOptionsStyle }, ref) => {
48920
49058
  const [currentSortBy, setCurrentSortBy] = React$2.useState(initialSort);
48921
49059
  React$2.useEffect(() => {
@@ -49006,57 +49144,11 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
49006
49144
  );
49007
49145
  }))) }), React$2.createElement("div", Object.assign({}, tableProps, rest, { key: "table-body-inner", style: tableStyle }), children)] }, "table-inner");
49008
49146
  }, useDeepCompare([tableProps, totalColumnsWidth, headerGroups]));
49009
- const renderRow = React$2.useCallback(({ data: rowData, index: index2, style: renderRowStyle }) => {
49010
- let row = rows[index2];
49011
- if (getItem) {
49012
- const value = getItem(index2);
49013
- if (!value) {
49014
- row = null;
49015
- } else {
49016
- row.original = value;
49017
- row.values = value;
49018
- }
49019
- }
49020
- if (!row) {
49021
- return jsxRuntime.exports.jsx("div", { children: headerGroups.map((headerGroup, gidx) => jsxRuntime.exports.jsx(RowPlaceholder, { style: {
49022
- height: ROW_HEIGHT,
49023
- top: (index2 + 1) * ROW_HEIGHT,
49024
- width: totalColumnsWidth > rowData.width ? totalColumnsWidth : "100%"
49025
- }, children: headerGroup === null || headerGroup === void 0 ? void 0 : headerGroup.headers.map((col, cidx) => {
49026
- const headerProps = col.getHeaderProps();
49027
- const width = headerProps.style.width === "NaNpx" ? mappedColumns[cidx].width : headerProps.style.width;
49028
- return jsxRuntime.exports.jsx(CellPlaceholder, { style: {
49029
- maxWidth: col.maxWidth,
49030
- width
49031
- } }, `col-${index2}-${cidx}`);
49032
- }) }, `row-${gidx}`)) });
49033
- }
49034
- prepareRow(row);
49035
- const onClick = () => {
49036
- if (onClickRow) {
49037
- throttledClickRow(row.original);
49038
- }
49039
- };
49040
- const _a = row.getRowProps({ style: renderRowStyle }), { style: rowStyle } = _a, restRow = __rest(_a, ["style"]);
49041
- return React$2.createElement(Row, Object.assign({}, restRow, { key: `row-${index2}`, onClick, onClickRow, style: Object.assign(Object.assign({}, rowStyle), { top: (index2 + 1) * ROW_HEIGHT, width: totalColumnsWidth > rowData.width ? totalColumnsWidth : "100%" }) }), row.cells.map((cell, colIdx) => {
49042
- var _a2;
49043
- const cellProps = cell.getCellProps();
49044
- return React$2.createElement(
49045
- Cell,
49046
- Object.assign({}, cellProps, { key: `cell-${index2}-${colIdx}`, style: Object.assign(Object.assign({}, cellProps.style), { backgroundColor, justifyContent: mappedColumns[colIdx].align, maxWidth: (_a2 = cell.column) === null || _a2 === void 0 ? void 0 : _a2.maxWidth, width: cellProps.style.width === "NaNpx" ? mappedColumns[colIdx].width : cellProps.style.width }) }),
49047
- jsxRuntime.exports.jsx(CellContent, { children: cell.render("Cell", {
49048
- colIdx,
49049
- currentEditCell: rowData.currentEditCell,
49050
- rowIdx: index2
49051
- }) })
49052
- );
49053
- }));
49054
- }, useDeepCompare([currentEditCell, prepareRow, rows, getItem]));
49055
49147
  return jsxRuntime.exports.jsx(Wrapper$3, Object.assign({}, getTableProps(), { "$hasMaxRows": !!maxRows, className: `${className} ${hasFixedColumns ? "sticky" : ""}`, style: Object.assign({ height: maxRows ? (Math.min(rows.length, maxRows) + 1) * ROW_HEIGHT : "100%" }, style), children: jsxRuntime.exports.jsx(AutoSizer, { children: ({ height, width }) => {
49056
- return jsxRuntime.exports.jsx(StyledFixedSizeList, { height, innerElementType: renderTable, itemCount: itemCount || rows.length, itemData: { currentEditCell, width }, itemSize: ROW_HEIGHT, onItemsRendered, style: {
49148
+ return jsxRuntime.exports.jsx(StyledFixedSizeList, { height, innerElementType: renderTable, itemCount: itemCount || rows.length, itemData: createItemData(width, currentEditCell, headerGroups, rows, prepareRow, getItem, totalColumnsWidth, onClickRow, throttledClickRow, backgroundColor, mappedColumns), itemSize: ROW_HEIGHT, onItemsRendered, style: {
49057
49149
  overflowX: width < totalColumnsWidth ? "auto" : "hidden",
49058
49150
  overflowY: height < (rows.length + 1) * ROW_HEIGHT ? "auto" : "hidden"
49059
- }, width, children: renderRow }, "table-list");
49151
+ }, width, children: RenderRow }, "table-list");
49060
49152
  } }) }));
49061
49153
  });
49062
49154
  Table.displayName = "Table";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darajs/core",
3
- "version": "1.0.0-a.2",
3
+ "version": "1.0.0",
4
4
  "description": "Dara Framework core",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -35,9 +35,9 @@
35
35
  "@babel/preset-env": "^7.16.11",
36
36
  "@babel/preset-react": "^7.16.7",
37
37
  "@babel/preset-typescript": "^7.16.7",
38
- "@darajs/eslint-config": "~1.0.0-a.1",
39
- "@darajs/prettier-config": "~1.0.0-a.1",
40
- "@darajs/stylelint-config": "~1.0.0-a.1",
38
+ "@darajs/eslint-config": "~1.0.0",
39
+ "@darajs/prettier-config": "~1.0.0",
40
+ "@darajs/stylelint-config": "~1.0.0",
41
41
  "@rollup/plugin-inject": "^4.0.4",
42
42
  "@testing-library/dom": "^9.3.0",
43
43
  "@testing-library/jest-dom": "^5.16.5",
@@ -73,10 +73,10 @@
73
73
  "whatwg-fetch": "^3.6.2"
74
74
  },
75
75
  "dependencies": {
76
- "@darajs/styled-components": "~1.0.0-a.1",
77
- "@darajs/ui-components": "~1.0.0-a.1",
78
- "@darajs/ui-notifications": "~1.0.0-a.1",
79
- "@darajs/ui-utils": "~1.0.0-a.1",
76
+ "@darajs/styled-components": "~1.0.0",
77
+ "@darajs/ui-components": "~1.0.0",
78
+ "@darajs/ui-notifications": "~1.0.0",
79
+ "@darajs/ui-utils": "~1.0.0",
80
80
  "@fortawesome/fontawesome-free": "^6.3.0",
81
81
  "@recoiljs/refine": "^0.1.1",
82
82
  "@tanstack/query-core": "^4.0.0",
@@ -113,5 +113,5 @@
113
113
  "publishConfig": {
114
114
  "access": "public"
115
115
  },
116
- "gitHead": "2f46a6d78d2bdf8cbb815ea20cffbb725c6a0886"
116
+ "gitHead": "4524a653baad221d41c98e28aa75f7e951cf6a48"
117
117
  }