@onepercentio/one-ui 0.19.8 → 0.20.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.
@@ -22,6 +22,7 @@ export declare type FileInputProps = {
22
22
  file?: File;
23
23
  onFile: (file: File | undefined) => void;
24
24
  progress?: number;
25
+ disabled?: boolean;
25
26
  } & React.HTMLProps<HTMLInputElement>;
26
27
  /**
27
28
  * A component to provide the upload of a file
@@ -2,4 +2,4 @@ import { FileInputViewProps } from "../View.types";
2
2
  /**
3
3
  * Shows the file submission input in a more compact form
4
4
  **/
5
- export default function Compact({ states, file, footer, inputEl, onAction, progress, className, }: FileInputViewProps): JSX.Element;
5
+ export default function Compact({ states, file, footer, inputEl, onAction, progress, className, disabled, }: FileInputViewProps): JSX.Element;
@@ -23,7 +23,8 @@ function Compact(_ref) {
23
23
  inputEl = _ref.inputEl,
24
24
  onAction = _ref.onAction,
25
25
  progress = _ref.progress,
26
- className = _ref.className;
26
+ className = _ref.className,
27
+ disabled = _ref.disabled;
27
28
  const state = states[file ? "fileProvided" : "waitingFile"];
28
29
  const statusClass = progress !== undefined && progress < 100 ? "loading" : file ? "completed" : "waiting";
29
30
  const progressDashArray = (0, _react.useMemo)(function () {
@@ -43,7 +44,8 @@ function Compact(_ref) {
43
44
  }
44
45
  }, [statusClass]);
45
46
  return /*#__PURE__*/_react.default.createElement("div", {
46
- className: "".concat(_CompactModule.default.root, " ").concat(className),
47
+ className: "".concat(_CompactModule.default.root, " ").concat(className, " ").concat(disabled ? _CompactModule.default.disabled : ""),
48
+ onClick: onAction,
47
49
  style: {
48
50
  "--progress-stroke-dasharray": progressDashArray
49
51
  }
@@ -51,8 +53,7 @@ function Compact(_ref) {
51
53
  transitionType: _Transition.TransitionAnimationTypes.COIN_FLIP
52
54
  }, /*#__PURE__*/_react.default.createElement(_Button.default, {
53
55
  variant: "transparent",
54
- key: statusClass,
55
- onClick: onAction
56
+ key: statusClass
56
57
  }, /*#__PURE__*/_react.default.createElement("svg", {
57
58
  viewBox: "0 0 46 47",
58
59
  className: _CompactModule.default[statusClass],
@@ -68,7 +69,21 @@ function Compact(_ref) {
68
69
  "stroke-width": "2",
69
70
  "stroke-linecap": "round",
70
71
  "stroke-linejoin": "round"
71
- }), /*#__PURE__*/_react.default.createElement("g", {
72
+ }), statusClass === "completed" ? /*#__PURE__*/_react.default.createElement("g", {
73
+ transform: "translate(11, 11)"
74
+ }, /*#__PURE__*/_react.default.createElement("path", {
75
+ d: "M22 11.0801V12.0001C21.9988 14.1565 21.3005 16.2548 20.0093 17.9819C18.7182 19.7091 16.9033 20.9726 14.8354 21.584C12.7674 22.1954 10.5573 22.122 8.53447 21.3747C6.51168 20.6274 4.78465 19.2462 3.61096 17.4372C2.43727 15.6281 1.87979 13.4882 2.02168 11.3364C2.16356 9.18467 2.99721 7.13643 4.39828 5.49718C5.79935 3.85793 7.69279 2.71549 9.79619 2.24025C11.8996 1.76502 14.1003 1.98245 16.07 2.86011",
76
+ stroke: "white",
77
+ "stroke-width": "2",
78
+ "stroke-linecap": "round",
79
+ "stroke-linejoin": "round"
80
+ }), /*#__PURE__*/_react.default.createElement("path", {
81
+ d: "M22 4L12 14.01L9 11.01",
82
+ stroke: "white",
83
+ "stroke-width": "2",
84
+ "stroke-linecap": "round",
85
+ "stroke-linejoin": "round"
86
+ })) : /*#__PURE__*/_react.default.createElement("g", {
72
87
  transform: polylines[0]
73
88
  }, /*#__PURE__*/_react.default.createElement("polyline", {
74
89
  points: polylines[1],
@@ -5,6 +5,11 @@
5
5
  background-color: $fileInputBackgroundColor;
6
6
  display: flex;
7
7
  align-items: center;
8
+ cursor: pointer;
9
+ &.disabled {
10
+ pointer-events: none;
11
+ cursor: initial;
12
+ }
8
13
  button {
9
14
  padding: 0px;
10
15
  min-width: initial;
@@ -41,10 +46,8 @@
41
46
  }
42
47
  }
43
48
  &.completed {
44
- --svg-color: #{$successDark};
45
49
  circle {
46
- fill: #{$success};
47
- stroke: #{$successDark};
50
+ fill: var(--svg-color);
48
51
  }
49
52
  polyline {
50
53
  stroke-width: 3;
@@ -5,4 +5,4 @@ export declare type FileInputViewProps = {
5
5
  onAction: () => void;
6
6
  /** A range from 0-100 to indicate some file upload progress */
7
7
  progress?: number;
8
- } & Pick<FileInputProps, "states" | "file" | "footer" | "className">;
8
+ } & Pick<FileInputProps, "states" | "file" | "footer" | "className" | "disabled">;
@@ -62,7 +62,7 @@ function Select(_ref) {
62
62
  if (filter && filterTerm) return items.filter(function (item) {
63
63
  return filter(item, filterTerm);
64
64
  });else return items;
65
- }, [filterTerm]);
65
+ }, [filterTerm, items]);
66
66
  (0, _react.useEffect)(function () {
67
67
  collapsableRef.current.redimension();
68
68
  }, [filteredItems.length]);
@@ -111,13 +111,14 @@ function Select(_ref) {
111
111
  e.stopPropagation();
112
112
  setOpen(false);
113
113
  }
114
- }, filter && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Input.default, {
114
+ }, filter && /*#__PURE__*/_react.default.createElement("div", {
115
+ className: _SelectModule.default.searchInput
116
+ }, /*#__PURE__*/_react.default.createElement(_Input.default, {
115
117
  onChange: function onChange(_ref2) {
116
118
  let value = _ref2.target.value;
117
119
  return setFilterTerm(value);
118
120
  },
119
121
  decoration: /*#__PURE__*/_react.default.createElement("span", null, "\uD83D\uDD0E\xA0"),
120
- className: _SelectModule.default.searchInput,
121
122
  containerProps: {
122
123
  onClick: function onClick(e) {
123
124
  return e.stopPropagation();
@@ -42,7 +42,9 @@
42
42
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.16);
43
43
  }
44
44
  .searchInput {
45
- > span {
45
+ position: sticky;
46
+ top: 0px;
47
+ > * > span {
46
48
  margin-right: 12px;
47
49
  display: flex;
48
50
  align-items: center;
@@ -2,8 +2,9 @@ import { DetailedHTMLProps, HTMLAttributes } from "react";
2
2
  /**
3
3
  * Switchs between states
4
4
  **/
5
- export default function Switch({ enabled, onToggle, size, ...props }: {
5
+ export default function Switch({ enabled, onToggle, size, disabled, ...props }: {
6
6
  enabled: boolean;
7
7
  onToggle: (newState: boolean) => void;
8
8
  size: number;
9
+ disabled?: boolean;
9
10
  } & Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">): JSX.Element;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = Switch;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _SwitchModule = _interopRequireDefault(require("./Switch.module.scss"));
9
- const _excluded = ["enabled", "onToggle", "size"];
9
+ const _excluded = ["enabled", "onToggle", "size", "disabled"];
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
12
12
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
@@ -18,16 +18,20 @@ function Switch(_ref) {
18
18
  let enabled = _ref.enabled,
19
19
  onToggle = _ref.onToggle,
20
20
  size = _ref.size,
21
+ disabled = _ref.disabled,
21
22
  props = _objectWithoutProperties(_ref, _excluded);
22
23
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", _extends({
23
24
  style: {
24
25
  fontSize: "".concat(size, "px")
25
26
  },
26
- className: "".concat(_SwitchModule.default.root, " ").concat(enabled ? _SwitchModule.default.enabled : ""),
27
+ className: "".concat(_SwitchModule.default.root, " ").concat(enabled ? _SwitchModule.default.on : "", " ").concat(disabled ? _SwitchModule.default.disabled : ""),
27
28
  onClick: function onClick() {
28
29
  return onToggle(!enabled);
29
30
  }
30
31
  }, props), /*#__PURE__*/_react.default.createElement("div", {
31
32
  className: _SwitchModule.default.toggler
33
+ }), /*#__PURE__*/_react.default.createElement("input", {
34
+ checked: enabled,
35
+ type: "checkbox"
32
36
  })));
33
37
  }
@@ -8,11 +8,19 @@
8
8
  width: 2em + 0.4em;
9
9
  padding: 0.1em;
10
10
  border-radius: math.div($height, 1);
11
- border: .1em solid $digitalBlue;
11
+ border: 0.1em solid $digitalBlue;
12
12
  background-color: white;
13
13
  transition: background-color $fast linear;
14
14
  cursor: pointer;
15
15
 
16
+ input {
17
+ max-width: 0px;
18
+ max-height: 0px;
19
+ width: 0;
20
+ height: 0;
21
+ opacity: 0;
22
+ }
23
+
16
24
  .toggler {
17
25
  height: 1em;
18
26
  width: 1em;
@@ -21,7 +29,11 @@
21
29
  transition: transform $fast linear;
22
30
  }
23
31
 
24
- &.enabled {
32
+ &.disabled {
33
+ opacity: 0.4;
34
+ cursor: initial;
35
+ }
36
+ &.on {
25
37
  background-color: $digitalBlue;
26
38
  .toggler {
27
39
  transform: translateX(1em);
@@ -16,6 +16,8 @@ const toString = function toString(val) {
16
16
  switch (_typeof(val)) {
17
17
  case "boolean":
18
18
  return !val ? "0" : "1";
19
+ case "string":
20
+ return val;
19
21
  default:
20
22
  throw new Error("Doesn't know how to handle type " + _typeof(val));
21
23
  }
@@ -24,6 +26,8 @@ const fromString = function fromString(type, value) {
24
26
  switch (type) {
25
27
  case "boolean":
26
28
  return value === "1";
29
+ case "string":
30
+ return value;
27
31
  default:
28
32
  throw new Error("Doesn't know how to handle type " + type);
29
33
  }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * This takes a container and applies padding and margin so the content overflow container and goes until it hits the viewport border
4
+ */
5
+ export default function useSnapToViewport(defaultPadding: number): import("react").RefObject<HTMLDivElement>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useSnapToViewport;
7
+ var _react = require("react");
8
+ var _useSnapToViewportModule = _interopRequireDefault(require("./useSnapToViewport.module.scss"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ /**
11
+ * This takes a container and applies padding and margin so the content overflow container and goes until it hits the viewport border
12
+ */
13
+ function useSnapToViewport(defaultPadding) {
14
+ const elRef = (0, _react.useRef)(null);
15
+ (0, _react.useLayoutEffect)(function () {
16
+ const diff = window.visualViewport.width - elRef.current.clientWidth;
17
+ const margin = diff / 2;
18
+ elRef.current.style.setProperty("--overflow-padding", "".concat(margin, "px"));
19
+ elRef.current.style.setProperty("--overflow-margin", "".concat(-margin, "px"));
20
+ elRef.current.style.setProperty("--default-padding", "".concat(defaultPadding, "px"));
21
+ elRef.current.style.setProperty("--default-margin", "".concat(-defaultPadding, "px"));
22
+ elRef.current.classList.add(_useSnapToViewportModule.default.applySpacings);
23
+ }, []);
24
+ return elRef;
25
+ }
@@ -0,0 +1,6 @@
1
+ .applySpacings {
2
+ padding-left: var(--overflow-padding, var(--default-padding));
3
+ padding-right: var(--overflow-padding, var(--default-padding));
4
+ margin-left: var(--overflow-margin, var(--default-margin));
5
+ margin-right: var(--overflow-margin, var(--default-margin));
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onepercentio/one-ui",
3
- "version": "0.19.8",
3
+ "version": "0.20.0",
4
4
  "description": "A set of reusable components created through the development of Onepercent projects",
5
5
  "repository": "git@github.com:onepercentio/one-ui.git",
6
6
  "author": "Murilo Oliveira de Araujo <murilo.araujo@onepercent.io>",