@helpdice/ui 1.7.2 → 1.7.4

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.
@@ -5,6 +5,7 @@ export type InputComponentType = typeof Input & {
5
5
  Textarea: typeof Textarea;
6
6
  Password: typeof InputPassword;
7
7
  };
8
+ export { getColors } from './styles';
8
9
  export type { InputProps } from './input';
9
10
  export type { InputTypes } from './input-props';
10
11
  export type { InputPasswordProps } from './password';
@@ -1653,3 +1653,4 @@ Input.Textarea = Textarea;
1653
1653
  Input.Password = InputPassword;
1654
1654
 
1655
1655
  exports.default = Input;
1656
+ exports.getColors = getColors;
@@ -0,0 +1,2 @@
1
+ import PhoneInput from './phone';
2
+ export default PhoneInput;
@@ -0,0 +1,2 @@
1
+ import PhoneInput from './phone';
2
+ export default PhoneInput;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { InputTypes } from 'components/input';
3
+ type PhoneInputProps = {
4
+ onChange: (data: string) => void;
5
+ value?: string;
6
+ country?: string;
7
+ placeholder?: string;
8
+ color?: InputTypes;
9
+ };
10
+ declare const PhoneInput: ({ onChange, value, country, placeholder, color: _color }: PhoneInputProps) => React.JSX.Element;
11
+ export default PhoneInput;
@@ -0,0 +1,158 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _JSXStyle from "../styled-jsx.es.js";
3
+ import React, { useState, useRef, useEffect, useMemo } from 'react';
4
+ import countries from './countries.json';
5
+ import useTheme from 'components/use-theme';
6
+ import { getColors } from 'components/input/styles';
7
+ var PhoneInput = function PhoneInput(_ref) {
8
+ var onChange = _ref.onChange,
9
+ _ref$value = _ref.value,
10
+ value = _ref$value === void 0 ? '' : _ref$value,
11
+ country = _ref.country,
12
+ _ref$placeholder = _ref.placeholder,
13
+ placeholder = _ref$placeholder === void 0 ? 'Enter phone number' : _ref$placeholder,
14
+ _ref$color = _ref.color,
15
+ _color = _ref$color === void 0 ? 'default' : _ref$color;
16
+ var theme = useTheme();
17
+ var defaultValue = country ? countries.findIndex(function (cn) {
18
+ return cn.code == country;
19
+ }) : 103;
20
+ var _useState = useState(countries[defaultValue]),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ selectedCountry = _useState2[0],
23
+ setSelectedCountry = _useState2[1];
24
+ var _useState3 = useState(value),
25
+ _useState4 = _slicedToArray(_useState3, 2),
26
+ phoneNumber = _useState4[0],
27
+ setPhoneNumber = _useState4[1];
28
+ var _useState5 = useState(false),
29
+ _useState6 = _slicedToArray(_useState5, 2),
30
+ isFocused = _useState6[0],
31
+ setIsFocused = _useState6[1];
32
+ var _useState7 = useState(false),
33
+ _useState8 = _slicedToArray(_useState7, 2),
34
+ dropdownOpen = _useState8[0],
35
+ setDropdownOpen = _useState8[1];
36
+ var _useState9 = useState(''),
37
+ _useState10 = _slicedToArray(_useState9, 2),
38
+ searchTerm = _useState10[0],
39
+ setSearchTerm = _useState10[1];
40
+ var dropdownRef = useRef(null);
41
+ var _useMemo = useMemo(function () {
42
+ return getColors(theme.palette, _color);
43
+ }, [theme.palette]),
44
+ borderColor = _useMemo.borderColor,
45
+ hoverBorder = _useMemo.hoverBorder;
46
+ var handleSelectCountry = function handleSelectCountry(country) {
47
+ setSelectedCountry(country);
48
+ setDropdownOpen(false);
49
+ setSearchTerm('');
50
+ if (onChange) onChange("".concat(country.code, ":").concat(phoneNumber));
51
+ };
52
+ var handlePhoneChange = function handlePhoneChange(e) {
53
+ var value = e.target.value.replace(/[^\d]/g, '');
54
+ setPhoneNumber(value);
55
+ if (onChange) onChange("".concat(selectedCountry.code).concat(value));
56
+ };
57
+ var handleClickOutside = function handleClickOutside(e) {
58
+ if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
59
+ setDropdownOpen(false);
60
+ setSearchTerm('');
61
+ }
62
+ };
63
+ useEffect(function () {
64
+ document.addEventListener('mousedown', handleClickOutside);
65
+ return function () {
66
+ return document.removeEventListener('mousedown', handleClickOutside);
67
+ };
68
+ }, []);
69
+ var filteredCountries = countries.filter(function (c) {
70
+ return "".concat(c.label, " ").concat(c.code, " ").concat(c.phone).toLowerCase().includes(searchTerm.toLowerCase());
71
+ });
72
+ return /*#__PURE__*/React.createElement("div", {
73
+ ref: dropdownRef,
74
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "phone-input-container ".concat(isFocused ? 'focused' : '')
75
+ }, /*#__PURE__*/React.createElement("div", {
76
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "input-wrapper"
77
+ }, /*#__PURE__*/React.createElement("div", {
78
+ onClick: function onClick() {
79
+ return setDropdownOpen(!dropdownOpen);
80
+ },
81
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "dropdown-toggle"
82
+ }, /*#__PURE__*/React.createElement("span", {
83
+ style: {
84
+ display: 'flex',
85
+ alignItems: 'center',
86
+ gap: 5
87
+ },
88
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]])
89
+ }, /*#__PURE__*/React.createElement("img", {
90
+ loading: "lazy",
91
+ width: "23",
92
+ height: "23",
93
+ src: "https://flagcdn.com/w20/".concat(selectedCountry.code.toLowerCase(), ".png"),
94
+ srcSet: "https://flagcdn.com/w40/".concat(selectedCountry.code.toLowerCase(), ".png 2x"),
95
+ alt: "Flag of ".concat(selectedCountry.label),
96
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]])
97
+ }), /*#__PURE__*/React.createElement("span", {
98
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]])
99
+ }, selectedCountry.phone))), /*#__PURE__*/React.createElement("input", {
100
+ type: "tel",
101
+ placeholder: placeholder,
102
+ value: phoneNumber,
103
+ onChange: handlePhoneChange,
104
+ onFocus: function onFocus() {
105
+ return setIsFocused(true);
106
+ },
107
+ onBlur: function onBlur() {
108
+ return setIsFocused(false);
109
+ },
110
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "phone-input"
111
+ })), dropdownOpen && /*#__PURE__*/React.createElement("div", {
112
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "dropdown"
113
+ }, /*#__PURE__*/React.createElement("input", {
114
+ type: "text",
115
+ placeholder: "Search country...",
116
+ value: searchTerm,
117
+ onChange: function onChange(e) {
118
+ return setSearchTerm(e.target.value);
119
+ },
120
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "search-input"
121
+ }), /*#__PURE__*/React.createElement("div", {
122
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "country-list"
123
+ }, filteredCountries.length > 0 ? filteredCountries.map(function (c) {
124
+ return /*#__PURE__*/React.createElement("div", {
125
+ key: c.code,
126
+ onClick: function onClick() {
127
+ return handleSelectCountry(c);
128
+ },
129
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "dropdown-item"
130
+ }, /*#__PURE__*/React.createElement("span", {
131
+ style: {
132
+ display: 'flex',
133
+ alignItems: 'center',
134
+ gap: 5
135
+ },
136
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]])
137
+ }, /*#__PURE__*/React.createElement("img", {
138
+ loading: "lazy",
139
+ width: "23",
140
+ height: "23",
141
+ src: "https://flagcdn.com/w20/".concat(c.code.toLowerCase(), ".png"),
142
+ srcSet: "https://flagcdn.com/w40/".concat(c.code.toLowerCase(), ".png 2x"),
143
+ alt: "Flag of ".concat(c.label),
144
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]])
145
+ }), c.phone, " ", /*#__PURE__*/React.createElement("span", {
146
+ style: {
147
+ color: 'grey'
148
+ },
149
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]])
150
+ }, c.label)));
151
+ }) : /*#__PURE__*/React.createElement("div", {
152
+ className: _JSXStyle.dynamic([["785147617", [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']]]) + " " + "dropdown-item disabled"
153
+ }, "No results"))), /*#__PURE__*/React.createElement(_JSXStyle, {
154
+ id: "785147617",
155
+ dynamic: [hoverBorder, borderColor, borderColor, theme.type == 'dark' ? 'black' : 'white', borderColor, borderColor, theme.type == 'dark' ? '#3a3d3d' : '#efefef']
156
+ }, ".phone-input-container.__jsx-style-dynamic-selector{position:relative;max-width:400px;}.phone-input-container.focused.__jsx-style-dynamic-selector{outline:1px solid ".concat(hoverBorder, ";border-radius:6px;}.input-wrapper.__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;border:1px solid ").concat(borderColor, ";border-radius:6px;overflow:hidden;}.dropdown-toggle.__jsx-style-dynamic-selector{padding:7px 12px;border-radius:6px 0px 0px 6px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-size:14px;border-right:1px solid ").concat(borderColor, ";}.phone-input.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;padding:5px 10px;height:35px;background-color:transparent;font-size:14px;border:none;}.phone-input.__jsx-style-dynamic-selector:focus{outline:none;}.dropdown.__jsx-style-dynamic-selector{position:absolute;top:100%;left:0;width:100%;background:").concat(theme.type == 'dark' ? 'black' : 'white', ";border:1px solid ").concat(borderColor, ";border-radius:6px;margin-top:4px;z-index:999;box-shadow:0 4px 10px rgba(0,0,0,0.1);}.search-input.__jsx-style-dynamic-selector{width:100%;padding:8px 10px;border:none;background-color:transparent;border-bottom:1px solid ").concat(borderColor, ";font-size:14px;}.search-input.__jsx-style-dynamic-selector:focus{outline:none;}.country-list.__jsx-style-dynamic-selector{max-height:200px;overflow-y:auto;}.dropdown-item.__jsx-style-dynamic-selector{padding:10px;cursor:pointer;font-size:14px;}.dropdown-item.__jsx-style-dynamic-selector:hover{background:").concat(theme.type == 'dark' ? '#3a3d3d' : '#efefef', ";}.dropdown-item.disabled.__jsx-style-dynamic-selector{color:#888;cursor:default;}")));
157
+ };
158
+ export default PhoneInput;
@@ -41,11 +41,11 @@ var BadgeComponent = function BadgeComponent(_ref) {
41
41
  dot: dot
42
42
  }, className);
43
43
  return /*#__PURE__*/React.createElement("span", _extends({}, props, {
44
- className: _JSXStyle.dynamic([["1238256810", [bg, _color, SCALES.font(0.875), SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.pt(0.25), SCALES.pr(0.4375), SCALES.pb(0.25), SCALES.pl(0.4375), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.py(0.25), SCALES.px(0.25)]]]) + " " + (props && props.className != null && props.className || classes || "")
44
+ className: _JSXStyle.dynamic([["120113192", [bg, _color, SCALES.font(0.875), SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.pt(0.25), SCALES.pr(0.5375), SCALES.pb(0.30), SCALES.pl(0.5375), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.py(0.25), SCALES.px(0.25)]]]) + " " + (props && props.className != null && props.className || classes || "")
45
45
  }), !dot && children, /*#__PURE__*/React.createElement(_JSXStyle, {
46
- id: "1238256810",
47
- dynamic: [bg, _color, SCALES.font(0.875), SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.pt(0.25), SCALES.pr(0.4375), SCALES.pb(0.25), SCALES.pl(0.4375), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.py(0.25), SCALES.px(0.25)]
48
- }, ".badge.__jsx-style-dynamic-selector{display:inline-block;border-radius:16px;font-variant:tabular-nums;line-height:1;vertical-align:middle;background-color:".concat(bg, ";color:").concat(_color, ";border:0;font-size:").concat(SCALES.font(0.875), ";width:").concat(SCALES.width(1, 'auto'), ";height:").concat(SCALES.height(1, 'auto'), ";padding:").concat(SCALES.pt(0.25), " ").concat(SCALES.pr(0.4375), " ").concat(SCALES.pb(0.25), " ").concat(SCALES.pl(0.4375), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.dot.__jsx-style-dynamic-selector{padding:").concat(SCALES.py(0.25), " ").concat(SCALES.px(0.25), ";border-radius:50%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}")));
46
+ id: "120113192",
47
+ dynamic: [bg, _color, SCALES.font(0.875), SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.pt(0.25), SCALES.pr(0.5375), SCALES.pb(0.30), SCALES.pl(0.5375), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.py(0.25), SCALES.px(0.25)]
48
+ }, ".badge.__jsx-style-dynamic-selector{display:inline-block;border-radius:16px;font-variant:tabular-nums;line-height:1;vertical-align:middle;background-color:".concat(bg, ";color:").concat(_color, ";border:0;font-size:").concat(SCALES.font(0.875), ";width:").concat(SCALES.width(1, 'auto'), ";height:").concat(SCALES.height(1, 'auto'), ";padding:").concat(SCALES.pt(0.25), " ").concat(SCALES.pr(0.5375), " ").concat(SCALES.pb(0.30), " ").concat(SCALES.pl(0.5375), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.dot.__jsx-style-dynamic-selector{padding:").concat(SCALES.py(0.25), " ").concat(SCALES.px(0.25), ";border-radius:50%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}")));
49
49
  };
50
50
  BadgeComponent.displayName = 'Badge';
51
51
  var Badge = withScale(BadgeComponent);
@@ -2,7 +2,7 @@
2
2
 
3
3
  import * as React from "react";
4
4
  // import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
5
- // import type { SyntaxHighlighterProps } from "react-syntax-highlighter";
5
+
6
6
  import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
7
7
  import { dracula } from "react-syntax-highlighter/dist/cjs/styles/prism";
8
8
  var SyntaxHighlighterAny = SyntaxHighlighter;
package/esm/index.d.ts CHANGED
@@ -44,7 +44,7 @@ export type { GridProps, GridContainerProps } from './grid';
44
44
  export { default as HtmlRenderer } from './html-renderer';
45
45
  export { default as Image } from './image';
46
46
  export type { ImageProps, ImageBrowserProps } from './image';
47
- export { default as Input } from './input';
47
+ export { default as Input, getColors } from './input';
48
48
  export type { InputProps, InputPasswordProps } from './input';
49
49
  export { default as Keyboard } from './keyboard';
50
50
  export type { KeyboardProps } from './keyboard';
@@ -64,6 +64,7 @@ export { default as Popover } from './popover';
64
64
  export type { PopoverProps, PopoverItemProps } from './popover';
65
65
  export { default as List } from './list';
66
66
  export { default as Menu } from './menu';
67
+ export { default as PhoneInput } from './PhoneInput';
67
68
  export { default as Progress } from './progress';
68
69
  export type { ProgressProps } from './progress';
69
70
  export { default as Radio } from './radio';
package/esm/index.js CHANGED
@@ -29,7 +29,7 @@ export { default as Grid } from './grid';
29
29
  export { default as Container } from './grid/grid-container';
30
30
  export { default as HtmlRenderer } from './html-renderer';
31
31
  export { default as Image } from './image';
32
- export { default as Input } from './input';
32
+ export { default as Input, getColors } from './input';
33
33
  export { default as Keyboard } from './keyboard';
34
34
  export { default as Link } from './link';
35
35
  export { default as Loading } from './loading';
@@ -40,6 +40,7 @@ export { default as Pagination } from './pagination';
40
40
  export { default as Popover } from './popover';
41
41
  export { default as List } from './list';
42
42
  export { default as Menu } from './menu';
43
+ export { default as PhoneInput } from './PhoneInput';
43
44
  export { default as Progress } from './progress';
44
45
  export { default as Radio } from './radio';
45
46
  export { default as Rating } from './rating';
@@ -5,6 +5,7 @@ export type InputComponentType = typeof Input & {
5
5
  Textarea: typeof Textarea;
6
6
  Password: typeof InputPassword;
7
7
  };
8
+ export { getColors } from './styles';
8
9
  export type { InputProps } from './input';
9
10
  export type { InputTypes } from './input-props';
10
11
  export type { InputPasswordProps } from './password';
@@ -4,4 +4,5 @@ import Textarea from '../textarea';
4
4
  import InputPassword from './password';
5
5
  Input.Textarea = Textarea;
6
6
  Input.Password = InputPassword;
7
+ export { getColors } from './styles';
7
8
  export default Input;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpdice/ui",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "unpkg": "dist/index.min.js",
@@ -38,8 +38,9 @@
38
38
  },
39
39
  "prettier": "@helpdice/prettier-config",
40
40
  "keywords": [
41
- "iux",
41
+ "flux",
42
42
  "helpdice ui",
43
+ "flux ui",
43
44
  "components",
44
45
  "react components",
45
46
  "react ui"
@@ -56,7 +57,7 @@
56
57
  "@babel/preset-env": "^7.14.7",
57
58
  "@babel/preset-react": "^7.14.5",
58
59
  "@babel/preset-typescript": "^7.14.5",
59
- "@helpdice/pro": "file:../pro/build",
60
+ "@helpdice/pro": "D:\\Github\\pro\\build",
60
61
  "@mapbox/rehype-prism": "^0.9.0",
61
62
  "@mdx-js/loader": "^3.1.0",
62
63
  "@mdx-js/react": "^3.1.0",
@@ -64,6 +65,7 @@
64
65
  "@next/mdx": "^15.1.6",
65
66
  "@rollup/plugin-babel": "^6.0.4",
66
67
  "@rollup/plugin-commonjs": "28.0.2",
68
+ "@rollup/plugin-json": "^6.1.0",
67
69
  "@rollup/plugin-node-resolve": "16.0.0",
68
70
  "@types/enzyme": "^3.10.18",
69
71
  "@types/lodash": "^4.17.15",
@@ -124,8 +126,8 @@
124
126
  "tslib": "^2.8.1"
125
127
  },
126
128
  "peerDependencies": {
127
- "react": "^18.3.1",
128
- "react-dom": "^18.3.1"
129
+ "react": "^18.3.1 || ^19.1.0",
130
+ "react-dom": "^18.3.1 || ^19.1.0"
129
131
  },
130
132
  "jest": {
131
133
  "globals": {