@homecode/ui 4.26.10 → 4.27.1

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/esm/index.js CHANGED
@@ -46,6 +46,7 @@ export { default as VirtualizedList } from './src/components/Virtualized/List/Li
46
46
  export { default as VirtualizedListScroll } from './src/components/Virtualized/List/ListScroll.js';
47
47
  import * as Virtualized_types from './src/components/Virtualized/Virtualized.types.js';
48
48
  export { Virtualized_types as VirtualizedTypes };
49
+ export { Toggle } from './src/components/Toggle/Toggle.js';
49
50
  import * as i18n from './src/services/i18n.js';
50
51
  export { i18n };
51
52
  import * as env from './src/tools/env.js';
@@ -83,6 +84,7 @@ import 'react';
83
84
  export { useIsMounted } from './src/hooks/useIsMounted.js';
84
85
  export { useListKeyboardControl } from './src/hooks/useListKeyboardControl.js';
85
86
  export { useResizeObserver } from './src/hooks/useResizeObserver.js';
87
+ export { useToggleState } from './src/hooks/useToggleState.js';
86
88
  import * as Form_types from './src/components/Form/Form.types.js';
87
89
  export { Form_types as FormTypes };
88
90
  export { SubmitButtons } from './src/components/Form/SubmitButtons/SubmitButtons.js';
@@ -59,6 +59,7 @@ import '../Text/Text.js';
59
59
  import '../Virtualized/Virtualized.styl.js';
60
60
  import '../Virtualized/List/List.styl.js';
61
61
  import '../Virtualized/List/ListScroll.styl.js';
62
+ import '../Toggle/Toggle.styl.js';
62
63
 
63
64
  function Autocomplete(props) {
64
65
  const { className, inputWrapperClassName, value, onChange, size = 'm', getOptions, onSelect, debounceDelay = 300, round = false, blur = false, inputProps = {}, popupProps = {}, menuProps = {}, } = props;
@@ -1,48 +1,19 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { Component } from 'react';
3
2
  import cn from 'classnames';
4
- import { createStore } from 'justorm/react';
5
3
  import { Icon } from '../Icon/Icon.js';
6
- import { generateUID } from '../../tools/uid.js';
4
+ import 'react';
5
+ import 'timen';
6
+ import { useToggleState } from '../../hooks/useToggleState.js';
7
7
  import S from './Checkbox.styl.js';
8
8
 
9
- class Checkbox extends Component {
10
- id;
11
- store;
12
- static defaultProps = {
13
- size: 'm',
14
- variant: 'default',
15
- label: '',
16
- checked: false,
17
- };
18
- constructor(props) {
19
- super(props);
20
- this.id = props.id || generateUID();
21
- this.store = createStore(this, { isActive: false, isFocused: false });
22
- }
23
- onMouseDown = () => {
24
- this.store.isActive = true;
25
- };
26
- onMouseUp = () => {
27
- this.store.isActive = false;
28
- };
29
- onFocus = (e) => {
30
- const { onFocus } = this.props;
31
- this.store.isFocused = true;
32
- onFocus?.(e);
33
- };
34
- onBlur = (e) => {
35
- const { onBlur } = this.props;
36
- this.store.isFocused = false;
37
- onBlur?.(e);
38
- };
39
- render() {
40
- const { className, label, size, variant, error, ...props } = this.props;
41
- const { checked, disabled } = props;
42
- const { isActive, isFocused } = this.store;
43
- const classes = cn(S.root, S[`size-${size}`], S[`variant-${variant}`], checked && S.checked, disabled && S.disabled, error && S.hasError, isActive && S.isActive, isFocused && S.isFocused, className);
44
- return (jsxs("label", { className: classes, onMouseDown: this.onMouseDown, onMouseUp: this.onMouseUp, children: [jsxs("div", { className: S.controlWrapper, children: [jsx("input", { className: S.control, ...props, onFocus: this.onFocus, onBlur: this.onBlur, id: this.id, type: "checkbox", tabIndex: 0 }), jsx(Icon, { type: "check", className: S.checkmark, size: size })] }), label] }));
45
- }
46
- }
9
+ const Checkbox = ({ className, label = '', size = 'm', variant = 'default', error, checked = false, disabled, id, onFocus, onBlur, ...props }) => {
10
+ const { id: componentId, isActive, isFocused, handlers, } = useToggleState({
11
+ id,
12
+ onFocus,
13
+ onBlur,
14
+ });
15
+ const classes = cn(S.root, S[`size-${size}`], S[`variant-${variant}`], checked && S.checked, disabled && S.disabled, error && S.hasError, isActive && S.isActive, isFocused && S.isFocused, className);
16
+ return (jsxs("label", { className: classes, onPointerDown: handlers.onPointerDown, onPointerUp: handlers.onPointerUp, children: [jsxs("div", { className: S.controlWrapper, children: [jsx("input", { className: S.control, ...props, onFocus: handlers.onFocus, onBlur: handlers.onBlur, id: componentId, type: "checkbox", checked: checked, disabled: disabled, tabIndex: 0 }), jsx(Icon, { type: "check", className: S.checkmark, size: size })] }), label] }));
17
+ };
47
18
 
48
19
  export { Checkbox };
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+
3
+ var _path;
4
+ 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); }
5
+ var SvgApple = function SvgApple(props) {
6
+ return /*#__PURE__*/React.createElement("svg", _extends({
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ viewBox: "0 0 24 24"
9
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
10
+ fill: "currentColor",
11
+ fillRule: "evenodd",
12
+ d: "M15.649 4c.865-1 1.447-2.395 1.288-3.783-1.246.047-2.753.795-3.646 1.795-.801.888-1.502 2.307-1.313 3.668 1.389.103 2.807-.676 3.67-1.678m3.117 8.81c.035 3.588 3.284 4.782 3.32 4.797-.026.084-.52 1.7-1.712 3.373-1.032 1.443-2.102 2.88-3.79 2.912-1.655.03-2.19-.941-4.084-.941s-2.486.91-4.054.97c-1.628.059-2.868-1.562-3.908-3-2.126-2.944-3.75-8.32-1.57-11.946 1.085-1.8 3.02-2.942 5.124-2.97 1.598-.03 3.107 1.03 4.084 1.03s2.81-1.275 4.739-1.088c.807.032 3.072.312 4.526 2.352-.117.07-2.703 1.512-2.674 4.51"
13
+ })));
14
+ };
15
+
16
+ export { SvgApple as default };
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ 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); }
4
+ var SvgGithub = function SvgGithub(props) {
5
+ return /*#__PURE__*/React.createElement("svg", _extends({
6
+ xmlns: "http://www.w3.org/2000/svg",
7
+ viewBox: "0 0 24 24"
8
+ }, props), /*#__PURE__*/React.createElement("path", {
9
+ fill: "currentColor",
10
+ fillRule: "evenodd",
11
+ d: "M12.085.104A11.957 11.968 0 0 1 23.882 12.23a11.957 11.968 0 0 1-8.09 11.53c-.598.119-.798-.28-.798-.6v-3.31c0-1.157-.398-1.875-.797-2.274 2.63-.28 5.42-1.317 5.42-5.984a4.783 4.787 0 0 0-1.235-3.271 3.986 3.99 0 0 0-.12-3.192s-.996-.319-3.228 1.197a11.957 11.968 0 0 0-5.979 0C6.863 4.811 5.867 5.21 5.867 5.21a3.986 3.99 0 0 0-.12 3.191 4.783 4.787 0 0 0-1.195 3.232c0 4.667 2.75 5.704 5.38 5.984a2.79 2.793 0 0 0-.757 1.635c-.717.32-2.431.838-3.468-1.037 0 0-.637-1.197-1.833-1.237 0 0-1.156 0-.08.719 0 0 .797.398 1.316 1.795 0 0 .677 2.154 3.985 1.436v2.234c0 .319-.199.718-.797.598a11.957 11.968 0 0 1-8.09-11.529A11.957 11.968 0 0 1 12.044.104",
12
+ style: {
13
+ strokeWidth: 39.8753
14
+ }
15
+ }));
16
+ };
17
+
18
+ export { SvgGithub as default };
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+
3
+ 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); }
4
+ var SvgGoogle = function SvgGoogle(props) {
5
+ return /*#__PURE__*/React.createElement("svg", _extends({
6
+ xmlns: "http://www.w3.org/2000/svg",
7
+ width: 24,
8
+ height: 24,
9
+ preserveAspectRatio: "xMidYMid",
10
+ viewBox: "-3 0 7.86 7.86"
11
+ }, props), /*#__PURE__*/React.createElement("path", {
12
+ fill: "#4285f4",
13
+ d: "M12.052 8.96c0-.716-.051-1.239-.162-1.78H4.68v3.23h4.232c-.086.802-.546 2.011-1.57 2.823l-.015.109 2.28 2.001.158.018c1.45-1.518 2.287-3.752 2.287-6.402",
14
+ style: {
15
+ strokeWidth: 0.0626224
16
+ },
17
+ transform: "matrix(.51004 0 0 .44168 -1.376 .066)"
18
+ }), /*#__PURE__*/React.createElement("path", {
19
+ fill: "#34a853",
20
+ d: "M4.68 17.47c2.073 0 3.814-.775 5.085-2.109l-2.423-2.128c-.649.513-1.52.87-2.662.87-2.031 0-3.755-1.517-4.37-3.616l-.09.009-2.37 2.079-.03.098c1.262 2.843 3.856 4.796 6.86 4.796",
21
+ style: {
22
+ strokeWidth: 0.0626224
23
+ },
24
+ transform: "matrix(.51004 0 0 .44168 -1.376 .066)"
25
+ }), /*#__PURE__*/React.createElement("path", {
26
+ fill: "#fbbc05",
27
+ d: "M.31 10.487a6 6 0 0 1-.255-1.721c0-.6.094-1.18.247-1.722L.298 6.93l-2.4-2.112-.079.042A9.7 9.7 0 0 0-3 8.766a9.7 9.7 0 0 0 .82 3.907z",
28
+ style: {
29
+ strokeWidth: 0.0626224
30
+ },
31
+ transform: "matrix(.51004 0 0 .44168 -1.376 .066)"
32
+ }), /*#__PURE__*/React.createElement("path", {
33
+ fill: "#eb4335",
34
+ d: "M4.68 3.428c1.442 0 2.414.706 2.969 1.296l2.167-2.399C8.486.923 6.753.062 4.68.062 1.676.062-.918 2.016-2.18 4.86L.301 7.044C.925 4.946 2.65 3.428 4.68 3.428",
35
+ style: {
36
+ strokeWidth: 0.0626224
37
+ },
38
+ transform: "matrix(.51004 0 0 .44168 -1.376 .066)"
39
+ }));
40
+ };
41
+
42
+ export { SvgGoogle as default };
@@ -1,5 +1,6 @@
1
1
  var ICONS = {
2
2
  attach: () => import('./attach.svg.js'),
3
+ apple: () => import('./apple.svg.js'),
3
4
  arrowRight: () => import('./arrowRight.svg.js'),
4
5
  arrowLeft: () => import('./arrowLeft.svg.js'),
5
6
  arrowUp: () => import('./arrowUp.svg.js'),
@@ -41,7 +42,9 @@ var ICONS = {
41
42
  gear: () => import('./gear.svg.js'),
42
43
  geolocation: () => import('./geolocation.svg.js'),
43
44
  globe: () => import('./globe.svg.js'),
45
+ google: () => import('./google.svg.js'),
44
46
  group: () => import('./group.svg.js'),
47
+ github: () => import('./github.svg.js'),
45
48
  history: () => import('./history.svg.js'),
46
49
  image: () => import('./image.svg.js'),
47
50
  instagram: () => import('./instagram.svg.js'),
@@ -57,6 +57,7 @@ import '../Text/Text.js';
57
57
  import '../Virtualized/Virtualized.styl.js';
58
58
  import '../Virtualized/List/List.styl.js';
59
59
  import '../Virtualized/List/ListScroll.styl.js';
60
+ import '../Toggle/Toggle.styl.js';
60
61
  import '../../services/i18n.js';
61
62
 
62
63
  const SCROLL_OFFSET = {
@@ -0,0 +1,18 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import cn from 'classnames';
3
+ import { useToggleState } from '../../hooks/useToggleState.js';
4
+ import S from './Toggle.styl.js';
5
+
6
+ function Toggle(props) {
7
+ const { className, label, size = 'm', variant = 'default', error, ...inputProps } = props;
8
+ const { checked, disabled } = inputProps;
9
+ const { id, isActive, isFocused, handlers } = useToggleState(props);
10
+ const classes = cn(S.root, S[`size-${size}`], S[`variant-${variant}`], checked && S.checked, disabled && S.disabled,
11
+ // error && S.hasError,
12
+ isActive && S.isActive,
13
+ // isFocused && S.isFocused,
14
+ className);
15
+ return (jsxs("label", { className: classes, onPointerDown: handlers.onPointerDown, onPointerUp: handlers.onPointerUp, children: [jsxs("div", { className: S.toggleWrapper, children: [jsx("input", { className: S.control, ...inputProps, onFocus: handlers.onFocus, onBlur: handlers.onBlur, id: id, type: "checkbox", tabIndex: 0 }), jsx("div", { className: S.track, children: jsx("div", { className: S.thumb }) })] }), label && jsx("span", { className: S.label, children: label })] }));
16
+ }
17
+
18
+ export { Toggle };
@@ -0,0 +1,7 @@
1
+ import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
+
3
+ var css_248z = ".Toggle_root__oTmAc{align-items:center;box-sizing:border-box;color:inherit;cursor:pointer;display:inline-flex;gap:.5em;-webkit-user-select:none;-moz-user-select:none;user-select:none}.Toggle_disabled__tFhaN{opacity:.4;pointer-events:none}.Toggle_toggleWrapper__CAd-a{display:block;position:relative;transition:.2s ease-out;transition-property:opacity,box-shadow}.Toggle_control__umhAB{-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:inset 0 0 0 2px none;box-sizing:border-box;opacity:0;pointer-events:none;position:absolute;transition:.2s ease-out;transition-property:background-color,box-shadow,opacity}.Toggle_control__umhAB:focus,.Toggle_control__umhAB:hover{background-color:var(--active-color-alpha-100)}.Toggle_control__umhAB[disabled]{background-color:var(--accent-color-alpha-100);opacity:.4;pointer-events:none}.Toggle_track__8HXVK{background-color:var(--accent-color-alpha-100);border-radius:100px;cursor:pointer;padding:2px;position:relative;transition:.3s ease-out;transition-property:background-color,border-color}.Toggle_checked__E4mPh .Toggle_track__8HXVK{background-color:var(--active-color)}.Toggle_isActive__Rx-Bv .Toggle_track__8HXVK,.Toggle_isFocused__LIHbP .Toggle_track__8HXVK{background-color:var(--active-color-alpha-500)}.Toggle_thumb__MrfWx{background-color:var(--accent-color-alpha-900);border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2);opacity:.9;transition:.2s ease-out;transition-property:transform,opacity}.Toggle_isActive__Rx-Bv .Toggle_thumb__MrfWx,.Toggle_root__oTmAc:hover .Toggle_thumb__MrfWx{opacity:1}.Toggle_label__eLVN-{font-size:inherit;line-height:inherit}.Toggle_size-s__NZkE5 .Toggle_track__8HXVK{height:30px;width:51px}.Toggle_size-s__NZkE5 .Toggle_thumb__MrfWx{height:26px;width:26px}.Toggle_checked__E4mPh.Toggle_size-s__NZkE5 .Toggle_thumb__MrfWx{transform:translateX(21px)}.Toggle_size-m__c2T-w .Toggle_track__8HXVK{height:40px;width:68px}.Toggle_size-m__c2T-w .Toggle_thumb__MrfWx{height:36px;width:36px}.Toggle_checked__E4mPh.Toggle_size-m__c2T-w .Toggle_thumb__MrfWx{transform:translateX(28px)}.Toggle_size-l__LhLRR .Toggle_track__8HXVK{height:50px;width:85px}.Toggle_size-l__LhLRR .Toggle_thumb__MrfWx{height:46px;width:46px}.Toggle_checked__E4mPh.Toggle_size-l__LhLRR .Toggle_thumb__MrfWx{transform:translateX(35px)}";
4
+ var S = {"root":"Toggle_root__oTmAc","disabled":"Toggle_disabled__tFhaN","toggleWrapper":"Toggle_toggleWrapper__CAd-a","control":"Toggle_control__umhAB","track":"Toggle_track__8HXVK","checked":"Toggle_checked__E4mPh","isActive":"Toggle_isActive__Rx-Bv","isFocused":"Toggle_isFocused__LIHbP","thumb":"Toggle_thumb__MrfWx","label":"Toggle_label__eLVN-","size-s":"Toggle_size-s__NZkE5","size-m":"Toggle_size-m__c2T-w","size-l":"Toggle_size-l__LhLRR"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };
@@ -0,0 +1,35 @@
1
+ import { useState, useCallback } from 'react';
2
+ import { generateUID } from '../tools/uid.js';
3
+
4
+ function useToggleState(props = {}) {
5
+ const id = props.id || generateUID();
6
+ const [isActive, setIsActive] = useState(false);
7
+ const [isFocused, setIsFocused] = useState(false);
8
+ const onPointerDown = useCallback(() => {
9
+ setIsActive(true);
10
+ }, []);
11
+ const onPointerUp = useCallback(() => {
12
+ setIsActive(false);
13
+ }, []);
14
+ const onFocus = useCallback((e) => {
15
+ setIsFocused(true);
16
+ props.onFocus?.(e);
17
+ }, [props.onFocus]);
18
+ const onBlur = useCallback((e) => {
19
+ setIsFocused(false);
20
+ props.onBlur?.(e);
21
+ }, [props.onBlur]);
22
+ return {
23
+ id,
24
+ isActive,
25
+ isFocused,
26
+ handlers: {
27
+ onPointerDown,
28
+ onPointerUp,
29
+ onFocus,
30
+ onBlur,
31
+ },
32
+ };
33
+ }
34
+
35
+ export { useToggleState };
@@ -1,18 +1,3 @@
1
- import { Component } from 'react';
1
+ import { FC } from 'react';
2
2
  import * as T from './Checkbox.types';
3
- export declare class Checkbox extends Component<T.Props> {
4
- id: any;
5
- store: any;
6
- static defaultProps: {
7
- size: string;
8
- variant: string;
9
- label: string;
10
- checked: boolean;
11
- };
12
- constructor(props: any);
13
- onMouseDown: () => void;
14
- onMouseUp: () => void;
15
- onFocus: (e: any) => void;
16
- onBlur: (e: any) => void;
17
- render(): JSX.Element;
18
- }
3
+ export declare const Checkbox: FC<T.Props>;
@@ -1,5 +1,6 @@
1
1
  import * as T from './Icon.types';
2
2
  export declare const icons: {
3
+ attach: () => Promise<any>;
3
4
  arrowRight: () => Promise<any>;
4
5
  arrowLeft: () => Promise<any>;
5
6
  arrowUp: () => Promise<any>;
@@ -49,6 +50,8 @@ export declare const icons: {
49
50
  layers: () => Promise<any>;
50
51
  link: () => Promise<any>;
51
52
  loader: () => Promise<any>;
53
+ lock: () => Promise<any>;
54
+ lockOpen: () => Promise<any>;
52
55
  map: () => Promise<any>;
53
56
  menu: () => Promise<any>;
54
57
  mic: () => Promise<any>;
@@ -73,6 +76,7 @@ export declare const icons: {
73
76
  send: () => Promise<any>;
74
77
  settings: () => Promise<any>;
75
78
  shoppingBag: () => Promise<any>;
79
+ smile: () => Promise<any>;
76
80
  soundWave: () => Promise<any>;
77
81
  sparks: () => Promise<any>;
78
82
  star: () => Promise<any>;
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  attach: () => Promise<any>;
3
+ apple: () => Promise<any>;
3
4
  arrowRight: () => Promise<any>;
4
5
  arrowLeft: () => Promise<any>;
5
6
  arrowUp: () => Promise<any>;
@@ -41,7 +42,9 @@ declare const _default: {
41
42
  gear: () => Promise<any>;
42
43
  geolocation: () => Promise<any>;
43
44
  globe: () => Promise<any>;
45
+ google: () => Promise<any>;
44
46
  group: () => Promise<any>;
47
+ github: () => Promise<any>;
45
48
  history: () => Promise<any>;
46
49
  image: () => Promise<any>;
47
50
  instagram: () => Promise<any>;
@@ -0,0 +1,3 @@
1
+ import * as T from './Toggle.types';
2
+ export type ToggleProps = T.Props;
3
+ export declare function Toggle(props: ToggleProps): JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { ReactNode, HTMLAttributes } from 'react';
2
+ import { Size, ComponentType } from '../../types';
3
+ export type Props = HTMLAttributes<HTMLInputElement> & ComponentType & {
4
+ label?: ReactNode;
5
+ checked?: boolean;
6
+ disabled?: boolean;
7
+ error?: string | boolean;
8
+ size?: Size;
9
+ variant?: 'default' | 'outlined';
10
+ };
@@ -42,3 +42,4 @@ export * from './Text/Text';
42
42
  export * from './Theme/Theme';
43
43
  export * from './VH/VH';
44
44
  export * from './Virtualized';
45
+ export * from './Toggle/Toggle';
@@ -4,3 +4,4 @@ export * from './useEvent';
4
4
  export * from './useIsMounted';
5
5
  export * from './useListKeyboardControl';
6
6
  export * from './useResizeObserver';
7
+ export * from './useToggleState';
@@ -0,0 +1,17 @@
1
+ export interface UseToggleStateProps {
2
+ id?: string;
3
+ onFocus?: (e: any) => void;
4
+ onBlur?: (e: any) => void;
5
+ }
6
+ export interface UseToggleState {
7
+ id: string;
8
+ isActive: boolean;
9
+ isFocused: boolean;
10
+ handlers: {
11
+ onPointerDown: () => void;
12
+ onPointerUp: () => void;
13
+ onFocus: (e: any) => void;
14
+ onBlur: (e: any) => void;
15
+ };
16
+ }
17
+ export declare function useToggleState(props?: UseToggleStateProps): UseToggleState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.26.10",
3
+ "version": "4.27.1",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "tests": "jest",