@helpdice/ui 2.5.8 → 2.6.0-beta.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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface InputBlockLabelLabel {
3
+ required?: boolean;
3
4
  }
4
5
  declare const InputBlockLabel: React.NamedExoticComponent<React.PropsWithChildren<InputBlockLabelLabel>>;
5
6
  export default InputBlockLabel;
@@ -1,15 +1,22 @@
1
1
  import _JSXStyle from "../styled-jsx.es.js";
2
2
  import React from 'react';
3
3
  import { useTheme } from '@helpdice/theme';
4
+ import useScale from '../use-scale';
4
5
  var InputBlockLabelComponent = function InputBlockLabelComponent(_ref) {
5
- var children = _ref.children;
6
+ var children = _ref.children,
7
+ _ref$required = _ref.required,
8
+ required = _ref$required === void 0 ? false : _ref$required;
6
9
  var theme = useTheme();
10
+ var _useScale = useScale(),
11
+ SCALES = _useScale.SCALES;
7
12
  return /*#__PURE__*/React.createElement("label", {
8
- className: _JSXStyle.dynamic([["1278828862", [theme.palette.accents_6]]])
9
- }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
10
- id: "1278828862",
11
- dynamic: [theme.palette.accents_6]
12
- }, "label.__jsx-style-dynamic-selector{display:block;font-weight:normal;color:".concat(theme.palette.accents_6, ";padding:0 0 0 1px;margin-bottom:0.5em;font-size:1em;line-height:1.5;}label.__jsx-style-dynamic-selector>*:first-child{margin-top:0;}label.__jsx-style-dynamic-selector>*:last-child{margin-bottom:0;}")));
13
+ className: _JSXStyle.dynamic([["588038827", [typeof children === "string" ? 'block' : 'flex', theme.palette.accents_6, theme.palette.errorDark, SCALES.font(1.2)]]])
14
+ }, children, required && /*#__PURE__*/React.createElement("span", {
15
+ className: _JSXStyle.dynamic([["588038827", [typeof children === "string" ? 'block' : 'flex', theme.palette.accents_6, theme.palette.errorDark, SCALES.font(1.2)]]]) + " " + "mark-error"
16
+ }, "*"), /*#__PURE__*/React.createElement(_JSXStyle, {
17
+ id: "588038827",
18
+ dynamic: [typeof children === "string" ? 'block' : 'flex', theme.palette.accents_6, theme.palette.errorDark, SCALES.font(1.2)]
19
+ }, "label.__jsx-style-dynamic-selector{display:".concat(typeof children === "string" ? 'block' : 'flex', ";font-weight:normal;color:").concat(theme.palette.accents_6, ";padding:0 0 0 1px;margin-bottom:0.5em;font-size:1em;line-height:1.5;}label.__jsx-style-dynamic-selector .mark-error.__jsx-style-dynamic-selector{color:").concat(theme.palette.errorDark, ";margin:0px 3px;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;font-size:").concat(SCALES.font(1.2), ";}label.__jsx-style-dynamic-selector>*:first-child{margin-top:0;}label.__jsx-style-dynamic-selector>*:last-child{margin-bottom:0;}")));
13
20
  };
14
21
  InputBlockLabelComponent.displayName = 'InputBlockLabel';
15
22
  var InputBlockLabel = /*#__PURE__*/React.memo(InputBlockLabelComponent);
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
- var _excluded = ["label", "labelRight", "error", "color", "helperText", "type", "icon", "variant", "iconRight", "iconClickable", "onIconClick", "initialValue", "onChange", "readOnly", "value", "onClearClick", "clearable", "className", "onBlur", "onFocus", "onEnter", "autoComplete", "placeholder", "children", "disabled", "fullWidth"];
4
+ var _excluded = ["label", "labelRight", "error", "color", "helperText", "type", "icon", "variant", "iconRight", "iconClickable", "onIconClick", "initialValue", "onChange", "readOnly", "value", "onClearClick", "clearable", "className", "onBlur", "onFocus", "onEnter", "autoComplete", "placeholder", "children", "disabled", "fullWidth", "required"];
5
5
  import _JSXStyle from "../styled-jsx.es.js";
6
6
  /* eslint-disable @typescript-eslint/no-unused-vars */
7
7
  /* eslint-disable react/jsx-no-undef */
@@ -61,6 +61,7 @@ var InputComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
61
61
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
62
62
  _ref$fullWidth = _ref.fullWidth,
63
63
  fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth,
64
+ required = _ref.required,
64
65
  props = _objectWithoutProperties(_ref, _excluded);
65
66
  var theme = useTheme();
66
67
  var _useScale = useScale(),
@@ -145,7 +146,9 @@ var InputComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
145
146
  var defaultWidth = fullWidth ? '100%' : 'initial';
146
147
  return /*#__PURE__*/React.createElement("div", {
147
148
  className: _JSXStyle.dynamic([["1343268165", [SCALES.height(2.25), SCALES.font(0.875), SCALES.width(1, defaultWidth), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.width(1, defaultWidth), variant === 'normal' ? theme.layout.radius : '', variant === 'none' ? '' : variant === 'line' ? "border-bottom: 1px solid ".concat(borderColor) : "border: 1px solid ".concat(borderColor), theme.palette.accents_1, theme.palette.accents_2, hoverBorder, SCALES.font(0.875), color, theme.palette.accents_3, theme.palette.background, color]]]) + " " + "with-label"
148
- }, children && /*#__PURE__*/React.createElement(InputBlockLabel, null, children), /*#__PURE__*/React.createElement("div", {
149
+ }, children && /*#__PURE__*/React.createElement(InputBlockLabel, {
150
+ required: required
151
+ }, children), /*#__PURE__*/React.createElement("div", {
149
152
  className: _JSXStyle.dynamic([["1343268165", [SCALES.height(2.25), SCALES.font(0.875), SCALES.width(1, defaultWidth), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.width(1, defaultWidth), variant === 'normal' ? theme.layout.radius : '', variant === 'none' ? '' : variant === 'line' ? "border-bottom: 1px solid ".concat(borderColor) : "border: 1px solid ".concat(borderColor), theme.palette.accents_1, theme.palette.accents_2, hoverBorder, SCALES.font(0.875), color, theme.palette.accents_3, theme.palette.background, color]]]) + " " + (useClasses('input-container', className) || "")
150
153
  }, label && /*#__PURE__*/React.createElement(InputLabel, null, label), /*#__PURE__*/React.createElement("div", {
151
154
  className: _JSXStyle.dynamic([["1343268165", [SCALES.height(2.25), SCALES.font(0.875), SCALES.width(1, defaultWidth), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.width(1, defaultWidth), variant === 'normal' ? theme.layout.radius : '', variant === 'none' ? '' : variant === 'line' ? "border-bottom: 1px solid ".concat(borderColor) : "border: 1px solid ".concat(borderColor), theme.palette.accents_1, theme.palette.accents_2, hoverBorder, SCALES.font(0.875), color, theme.palette.accents_3, theme.palette.background, color]]]) + " " + (useClasses('input-wrapper', {
@@ -19,6 +19,7 @@ export interface Props {
19
19
  iconClickable?: boolean;
20
20
  className?: string;
21
21
  clearable?: boolean;
22
+ required?: boolean;
22
23
  onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
23
24
  onClearClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
24
25
  onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { CSSProperties } from 'react';
2
2
  import { RowErrorMap, TableDataItemBase, TableOnCellClick, TableOnChange, TableOnRowClick, TableRowClassNameHandler } from './table-types';
3
3
  import { ScaleProps } from '../use-scale';
4
4
  interface Props<TableDataItem extends TableDataItemBase> {
@@ -26,7 +26,7 @@ interface Props<TableDataItem extends TableDataItemBase> {
26
26
  nextCursor?: string;
27
27
  hasMore?: boolean;
28
28
  rowErrors?: RowErrorMap;
29
- containerStyle?: object;
29
+ containerStyle?: CSSProperties;
30
30
  loading?: string;
31
31
  isLoading?: boolean;
32
32
  onNextPage?: (next?: string) => void;
@@ -20,7 +20,7 @@ import Button from '../button';
20
20
  import Tooltip from '../tooltip';
21
21
  import Placeholder from '../placeholder';
22
22
  import { useTheme } from '@helpdice/theme';
23
- import Loading from 'components/loading';
23
+ import Loading from '../loading';
24
24
  function TableComponent(tableProps) {
25
25
  /* eslint-disable @typescript-eslint/no-unused-vars */
26
26
  var _ref = tableProps,
@@ -135,16 +135,16 @@ function TableComponent(tableProps) {
135
135
  borderBottomLeftRadius: '5px',
136
136
  borderBottomRightRadius: '5px'
137
137
  },
138
- className: _JSXStyle.dynamic([["1809040460", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]])
138
+ className: _JSXStyle.dynamic([["638332526", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]])
139
139
  }, /*#__PURE__*/React.createElement("div", {
140
140
  style: _extends({
141
141
  overflow: 'auto'
142
142
  }, containerStyle),
143
- className: _JSXStyle.dynamic([["1809040460", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]])
143
+ className: _JSXStyle.dynamic([["638332526", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]])
144
144
  }, /*#__PURE__*/React.createElement("table", _extends({
145
145
  ref: ref
146
146
  }, props, {
147
- className: _JSXStyle.dynamic([["1809040460", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]]) + " " + (props && props.className != null && props.className || className || "")
147
+ className: _JSXStyle.dynamic([["638332526", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]]) + " " + (props && props.className != null && props.className || className || "")
148
148
  }), /*#__PURE__*/React.createElement(TableHead, {
149
149
  stickyHeader: stickyHeader,
150
150
  onFilters: onFilters,
@@ -165,19 +165,19 @@ function TableComponent(tableProps) {
165
165
  rowDraggable: rowDraggable,
166
166
  readOnly: readOnly,
167
167
  onSelected: onSelected
168
- }), children), loading === "default" && isLoading ? /*#__PURE__*/React.createElement(Loading, null) : data.length == 0 && /*#__PURE__*/React.createElement(Placeholder, {
168
+ }), children), loading === "default" && isLoading ? /*#__PURE__*/React.createElement(Loading, null) : null, data.length == 0 && !isLoading ? /*#__PURE__*/React.createElement(Placeholder, {
169
+ height: "90%",
169
170
  empty: true,
170
171
  textOnly: textPlaceholder,
171
172
  msg: "No Data to show"
172
- })), cursorPagination || viewLength ? /*#__PURE__*/React.createElement("div", {
173
- className: _JSXStyle.dynamic([["1809040460", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]]) + " " + "table-footer"
174
- }, cursorPagination ? /*#__PURE__*/React.createElement("div", {
173
+ }) : null), cursorPagination || viewLength ? /*#__PURE__*/React.createElement("div", {
174
+ className: _JSXStyle.dynamic([["638332526", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]]) + " " + "table-footer"
175
+ }, cursorPagination && /*#__PURE__*/React.createElement("div", {
175
176
  style: {
176
177
  display: 'flex',
177
- gap: 10,
178
- margin: '10px'
178
+ gap: 10
179
179
  },
180
- className: _JSXStyle.dynamic([["1809040460", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]])
180
+ className: _JSXStyle.dynamic([["638332526", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]]])
181
181
  }, /*#__PURE__*/React.createElement(Tooltip.Small, {
182
182
  text: "Previous",
183
183
  type: "dark"
@@ -194,19 +194,21 @@ function TableComponent(tableProps) {
194
194
  text: "Next",
195
195
  type: "dark"
196
196
  }, /*#__PURE__*/React.createElement(Button, {
197
- disabled: !nextCursor,
197
+ disabled: !nextCursor || isLoading,
198
198
  onClick: function onClick() {
199
199
  return onNextPage && onNextPage(nextCursor);
200
200
  },
201
201
  auto: true,
202
202
  px: 0.6,
203
203
  scale: 2 / 3,
204
- iconRight: /*#__PURE__*/React.createElement(ChevronRight, null)
205
- }))) : dataLength && viewLength && onPageChange ? /*#__PURE__*/React.createElement(Pagination, {
204
+ iconRight: isLoading ? /*#__PURE__*/React.createElement(Loading, {
205
+ width: "20px",
206
+ height: "20px"
207
+ }) : /*#__PURE__*/React.createElement(ChevronRight, null)
208
+ }))), dataLength && viewLength && onPageChange ? /*#__PURE__*/React.createElement(Pagination, {
206
209
  style: {
207
210
  marginLeft: '10px',
208
- marginRight: '10px',
209
- marginTop: '10px'
211
+ marginRight: '10px'
210
212
  },
211
213
  onChange: function onChange(pageNumber) {
212
214
  // Get the range for the current page
@@ -218,9 +220,9 @@ function TableComponent(tableProps) {
218
220
  limit: 5,
219
221
  count: Number(dataLength / viewLength)
220
222
  }, /*#__PURE__*/React.createElement(Pagination.Next, null, /*#__PURE__*/React.createElement(ChevronRight, null)), /*#__PURE__*/React.createElement(Pagination.Previous, null, /*#__PURE__*/React.createElement(ChevronLeft, null))) : null) : null, /*#__PURE__*/React.createElement(_JSXStyle, {
221
- id: "1809040460",
223
+ id: "638332526",
222
224
  dynamic: [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.background]
223
- }, "table.__jsx-style-dynamic-selector{border-collapse:separate;border-spacing:0;--table-font-size:".concat(SCALES.font(1), ";font-size:var(--table-font-size);width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, 'auto'), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.table-footer.__jsx-style-dynamic-selector{background-color:").concat(theme.palette.background, ";width:100%;bottom:0;}"))));
225
+ }, "table.__jsx-style-dynamic-selector{border-collapse:separate;border-spacing:0;--table-font-size:".concat(SCALES.font(1), ";font-size:var(--table-font-size);width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, 'auto'), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.table-footer.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:").concat(theme.palette.background, ";width:100%;bottom:0;padding:10px;}"))));
224
226
  }
225
227
  TableComponent.displayName = 'Table';
226
228
  TableComponent.Column = TableColumn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpdice/ui",
3
- "version": "2.5.8",
3
+ "version": "2.6.0-beta.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "unpkg": "dist/index.min.js",