@onepercentio/one-ui 0.19.9 → 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.
- package/dist/components/FileInput/FileInput.d.ts +1 -0
- package/dist/components/FileInput/View/Compact/Compact.d.ts +1 -1
- package/dist/components/FileInput/View/Compact/Compact.js +20 -5
- package/dist/components/FileInput/View/Compact/Compact.module.scss +6 -3
- package/dist/components/FileInput/View/View.types.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +2 -1
- package/dist/components/Switch/Switch.js +6 -2
- package/dist/components/Switch/Switch.module.scss +14 -2
- package/dist/hooks/ui/useSnapToViewport.d.ts +5 -0
- package/dist/hooks/ui/useSnapToViewport.js +25 -0
- package/dist/hooks/ui/useSnapToViewport.module.scss +6 -0
- package/package.json +1 -1
|
@@ -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:
|
|
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">;
|
|
@@ -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.
|
|
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
|
-
&.
|
|
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);
|
|
@@ -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.
|
|
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>",
|