@happeouikit/form-elements 2.3.27 → 2.3.29

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.
Files changed (53) hide show
  1. package/dist/Badge.d.ts +21 -0
  2. package/dist/Checkbox.d.ts +27 -0
  3. package/dist/CheckboxGroup.d.ts +90 -0
  4. package/dist/DatePicker.d.ts +54 -0
  5. package/dist/DateTimePicker.d.ts +21 -0
  6. package/dist/Dropdown.d.ts +7 -0
  7. package/dist/Input.d.ts +13 -0
  8. package/dist/Input.types.d.ts +18 -0
  9. package/dist/Link.d.ts +3 -0
  10. package/dist/RadioButton.d.ts +19 -0
  11. package/dist/Switch.d.ts +19 -0
  12. package/dist/Tag.d.ts +15 -0
  13. package/dist/Textarea.d.ts +20 -0
  14. package/dist/Typeahead/Typeahead.d.ts +46 -0
  15. package/dist/Typeahead/TypeaheadDropdown.d.ts +5 -0
  16. package/dist/Typeahead/TypeaheadError.d.ts +2 -0
  17. package/dist/Typeahead/TypeaheadList.d.ts +3 -0
  18. package/dist/Typeahead/TypeaheadLoading.d.ts +4 -0
  19. package/dist/Typeahead/TypeaheadMessage.d.ts +7 -0
  20. package/dist/Typeahead/TypeaheadNoResults.d.ts +4 -0
  21. package/dist/Typeahead/messages.d.ts +37 -0
  22. package/dist/index.cjs.js +780 -0
  23. package/dist/index.cjs.js.map +1 -0
  24. package/dist/{index.js → index.d.ts} +1 -1
  25. package/dist/index.es.js +12478 -0
  26. package/dist/index.es.js.map +1 -0
  27. package/dist/messages.d.ts +91 -0
  28. package/dist/style.css +1 -0
  29. package/dist/utils.d.ts +8 -0
  30. package/messages.json +1 -0
  31. package/package.json +18 -15
  32. package/dist/Badge.js +0 -41
  33. package/dist/Checkbox.js +0 -107
  34. package/dist/CheckboxGroup.js +0 -134
  35. package/dist/DatePicker.js +0 -445
  36. package/dist/DateTimePicker.js +0 -191
  37. package/dist/Dropdown.js +0 -65
  38. package/dist/Input.js +0 -160
  39. package/dist/Link.js +0 -51
  40. package/dist/RadioButton.js +0 -41
  41. package/dist/Switch.js +0 -70
  42. package/dist/Tag.js +0 -59
  43. package/dist/Textarea.js +0 -88
  44. package/dist/Typeahead/Typeahead.js +0 -214
  45. package/dist/Typeahead/TypeaheadDropdown.js +0 -25
  46. package/dist/Typeahead/TypeaheadError.js +0 -14
  47. package/dist/Typeahead/TypeaheadList.js +0 -37
  48. package/dist/Typeahead/TypeaheadLoading.js +0 -23
  49. package/dist/Typeahead/TypeaheadMessage.js +0 -39
  50. package/dist/Typeahead/TypeaheadNoResults.js +0 -17
  51. package/dist/Typeahead/messages.js +0 -29
  52. package/dist/messages.js +0 -63
  53. package/dist/utils.js +0 -51
package/dist/Dropdown.js DELETED
@@ -1,65 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["label"];
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import React, { Fragment, forwardRef, useRef, useImperativeHandle } from "react";
7
- import styled, { css } from "styled-components";
8
- import Select, { components } from "react-select";
9
- import { IconArrowDropDown } from "@happeouikit/icons";
10
- import { active, gray01, gray06, gray05, toBgLight, gray04 } from "@happeouikit/colors";
11
- import { BodyUI, sansFamily } from "@happeouikit/typography";
12
- import { screen } from "@happeouikit/theme";
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { jsxs as _jsxs } from "react/jsx-runtime";
15
- var Dropdown = function Dropdown(_ref, ref) {
16
- var label = _ref.label,
17
- props = _objectWithoutProperties(_ref, _excluded);
18
- var dropdownRef = useRef();
19
- useImperativeHandle(ref, function () {
20
- return {
21
- setValue: function setValue(value) {
22
- return dropdownRef.current.select.setValue(value);
23
- }
24
- };
25
- });
26
- return /*#__PURE__*/_jsxs(Fragment, {
27
- children: [!!label && /*#__PURE__*/_jsx(Label, {
28
- children: /*#__PURE__*/_jsx(BodyUI, {
29
- bold: true,
30
- color: gray01,
31
- children: label
32
- })
33
- }), /*#__PURE__*/_jsx(StyledDropdown, _objectSpread({
34
- "data-for": "datepicker-year-dropdown",
35
- classNamePrefix: "dropdown",
36
- components: _objectSpread({
37
- DropdownIndicator: DropdownIndicator
38
- }, props.components),
39
- hideOnMobile: props.hideOnMobile,
40
- ref: dropdownRef
41
- }, props))]
42
- });
43
- };
44
- var DropdownIndicator = function DropdownIndicator(props) {
45
- return components.DropdownIndicator && /*#__PURE__*/_jsx(components.DropdownIndicator, _objectSpread(_objectSpread({}, props), {}, {
46
- children: /*#__PURE__*/_jsx(IconArrowDropDown, {
47
- width: "24px",
48
- height: "24px",
49
- fill: gray06
50
- })
51
- }));
52
- };
53
- export var dropdownStyles = css(["min-width:200px;width:auto;font-family:", ";letter-spacing:-0.3px;font-size:14px;font-weight:normal;:hover{cursor:pointer;}.dropdown{&__indicator-separator{display:none;}&__indicator{padding:7px 8px;}&__control{border:1px solid ", ";box-shadow:none;:hover{border-color:", ";}:active{outline:none;border-color:", ";}:focus{outline:none;border-color:", ";}&--is-focused,&--is-focused:active{outline:none !important;border:1px solid ", " !important;box-shadow:none;}}&__input{input{box-shadow:none !important;}}&__menu{.dropdown__option--is-focused:not(.dropdown__option--is-selected){background:", ";}}&__placeholder{font-family:", ";color:", ";letter-spacing:-0.3px;font-size:14px;font-weight:normal;}}@media ", "{", ";}"], sansFamily, gray06, gray04, active, active, active, toBgLight(active), sansFamily, gray05, screen.onlyXs, function (_ref2) {
54
- var hideOnMobile = _ref2.hideOnMobile;
55
- return hideOnMobile && " display: none;";
56
- });
57
- var StyledDropdown = styled(Select).withConfig({
58
- displayName: "Dropdown__StyledDropdown",
59
- componentId: "sc-pcee56-0"
60
- })(["", ""], dropdownStyles);
61
- var Label = styled.div.withConfig({
62
- displayName: "Dropdown__Label",
63
- componentId: "sc-pcee56-1"
64
- })(["margin:4px 0;"]);
65
- export default /*#__PURE__*/forwardRef(Dropdown);
package/dist/Input.js DELETED
@@ -1,160 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- var _excluded = ["label", "icon", "iconProps", "state", "errorMessage"],
4
- _excluded2 = ["label"];
5
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- import React from "react";
8
- import styled from "styled-components";
9
- import { placeholder } from "polished";
10
- import { gray01, gray04, gray08, gray05, gray06, active, black, success, alert } from "@happeouikit/colors";
11
- import { TinyText, sansFamily, BodyUI } from "@happeouikit/typography";
12
- import { uuidv4 } from "./utils";
13
-
14
- /**
15
- * Map input states to colors
16
- * @type {{default: string, success: string, error: string}}
17
- */
18
- import { jsx as _jsx } from "react/jsx-runtime";
19
- import { jsxs as _jsxs } from "react/jsx-runtime";
20
- var inputStates = {
21
- success: success,
22
- error: alert,
23
- "default": gray06
24
- };
25
-
26
- /**
27
- * HOC for customizing Icon components for input
28
- * @param IconComponent
29
- * @param iconProps
30
- * @returns {function(): *}
31
- */
32
- var IconWrapper = function IconWrapper(IconComponent, iconProps) {
33
- var iconDefaults = {
34
- width: "20px",
35
- height: "20px",
36
- fill: black
37
- };
38
- var style = {
39
- position: "absolute",
40
- top: "10px",
41
- left: "10px",
42
- fontSize: "18px"
43
- };
44
- var props = _objectSpread(_objectSpread({}, iconDefaults), iconProps);
45
- return function () {
46
- return /*#__PURE__*/_jsx(InputIconWrapper, {
47
- children: /*#__PURE__*/_jsx(IconComponent, _objectSpread(_objectSpread({}, props), {}, {
48
- style: style
49
- }))
50
- });
51
- };
52
- };
53
- export var Input = function Input(_ref) {
54
- var label = _ref.label,
55
- icon = _ref.icon,
56
- iconProps = _ref.iconProps,
57
- state = _ref.state,
58
- errorMessage = _ref.errorMessage,
59
- rest = _objectWithoutProperties(_ref, _excluded);
60
- var id = React.useMemo(uuidv4, []);
61
- var accessibility = label ? {
62
- "aria-labelledby": id
63
- } : {};
64
- return /*#__PURE__*/_jsxs(Container, {
65
- children: [!!label && /*#__PURE__*/_jsx(InputLabel, {
66
- id: id,
67
- children: /*#__PURE__*/_jsx(BodyUI, {
68
- bold: true,
69
- color: gray01,
70
- children: label
71
- })
72
- }), icon && IconWrapper(icon, iconProps)(), /*#__PURE__*/_jsx(StyledInput, _objectSpread(_objectSpread({
73
- title: label || "Styled input",
74
- hasIcon: (icon || "").toString(),
75
- state: state || "default"
76
- }, accessibility), rest)), state === "error" && errorMessage && /*#__PURE__*/_jsx(ErrorMessage, {
77
- color: alert,
78
- children: errorMessage
79
- })]
80
- });
81
- };
82
- var ErrorMessage = styled(TinyText).withConfig({
83
- displayName: "Input__ErrorMessage",
84
- componentId: "sc-1izazxd-0"
85
- })(["margin:8px 0;"]);
86
- var Container = styled.div.withConfig({
87
- displayName: "Input__Container",
88
- componentId: "sc-1izazxd-1"
89
- })(["display:flex;flex-direction:column;position:relative;width:100%;"]);
90
- var InputLabel = styled.div.withConfig({
91
- displayName: "Input__InputLabel",
92
- componentId: "sc-1izazxd-2"
93
- })(["margin:4px 0;"]);
94
- export var StyledInput = styled.input.attrs(function (_ref2) {
95
- var type = _ref2.type;
96
- return {
97
- type: type || "text"
98
- };
99
- }).withConfig({
100
- displayName: "Input__StyledInput",
101
- componentId: "sc-1izazxd-3"
102
- })(["", ";font-family:", ";width:100%;height:40px;border-radius:4px;border:solid 1px ", ";box-sizing:border-box;box-shadow:none;font-size:14px;padding:", ";font-weight:normal;font-style:normal;font-stretch:normal;line-height:1.43;letter-spacing:0.3px;color:", ";:hover{border-color:", ";}:active{outline:none;box-shadow:none;border-color:", ";}:focus{outline:none;border-color:", " !important;}:disabled{border:solid 1px ", ";color:", ";", "}border-color:", ";"], placeholder({
103
- "font-family": sansFamily,
104
- color: gray05,
105
- "letter-spacing": "-0.3px",
106
- "font-size": "14px",
107
- "font-weight": "normal"
108
- }), sansFamily, gray06, function (_ref3) {
109
- var hasIcon = _ref3.hasIcon;
110
- return hasIcon ? "10px 12px 10px 38px" : "10px 12px";
111
- }, black, function (_ref4) {
112
- var _ref4$state = _ref4.state,
113
- state = _ref4$state === void 0 ? "default" : _ref4$state;
114
- return state === "default" ? gray04 : inputStates[state];
115
- }, function (_ref5) {
116
- var _ref5$state = _ref5.state,
117
- state = _ref5$state === void 0 ? "default" : _ref5$state;
118
- return state === "default" ? active : inputStates[state];
119
- }, function (_ref6) {
120
- var _ref6$state = _ref6.state,
121
- state = _ref6$state === void 0 ? "default" : _ref6$state;
122
- return state === "default" ? active : inputStates[state];
123
- }, gray08, gray05, placeholder({
124
- color: gray05
125
- }), function (_ref7) {
126
- var _ref7$state = _ref7.state,
127
- state = _ref7$state === void 0 ? "default" : _ref7$state;
128
- return inputStates[state];
129
- });
130
- var InputIconWrapper = styled.span.withConfig({
131
- displayName: "Input__InputIconWrapper",
132
- componentId: "sc-1izazxd-4"
133
- })(["position:relative;"]);
134
-
135
- /**
136
- * Number Input
137
- */
138
- export var InputNumber = function InputNumber(_ref8) {
139
- var label = _ref8.label,
140
- props = _objectWithoutProperties(_ref8, _excluded2);
141
- return /*#__PURE__*/_jsxs(InputNumberContainer, {
142
- children: [/*#__PURE__*/_jsx(StyledInputNumber, _objectSpread(_objectSpread({}, props), {}, {
143
- type: "number"
144
- })), label && /*#__PURE__*/_jsx(InputNumberLabel, {
145
- children: label
146
- })]
147
- });
148
- };
149
- var StyledInputNumber = styled(Input).withConfig({
150
- displayName: "Input__StyledInputNumber",
151
- componentId: "sc-1izazxd-5"
152
- })(["width:60px;text-align:center;font-size:14px;"]);
153
- var InputNumberContainer = styled.div.withConfig({
154
- displayName: "Input__InputNumberContainer",
155
- componentId: "sc-1izazxd-6"
156
- })(["display:flex;align-items:center;", "{width:auto;}"], Container);
157
- var InputNumberLabel = styled(BodyUI).withConfig({
158
- displayName: "Input__InputNumberLabel",
159
- componentId: "sc-1izazxd-7"
160
- })(["color:", ";margin-left:10px;"], gray01);
package/dist/Link.js DELETED
@@ -1,51 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import React from "react";
5
- import PropTypes from "prop-types";
6
- import styled from "styled-components";
7
- import { BodyUI } from "@happeouikit/typography";
8
- import { active } from "@happeouikit/colors";
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- export var Link = /*#__PURE__*/React.forwardRef(function (props, ref) {
11
- return /*#__PURE__*/_jsx(StyledLink, _objectSpread(_objectSpread({
12
- ref: ref,
13
- as: "a"
14
- }, props), {}, {
15
- children: props.children
16
- }));
17
- });
18
- export var LinkExternal = /*#__PURE__*/React.forwardRef(function (props, ref) {
19
- return /*#__PURE__*/_jsx(StyledLink, _objectSpread(_objectSpread({
20
- ref: ref,
21
- as: "a",
22
- target: "_blank",
23
- rel: "nofollow noopener"
24
- }, props), {}, {
25
- children: props.children
26
- }));
27
- });
28
- var StyledLink = styled(BodyUI).withConfig({
29
- displayName: "Link__StyledLink",
30
- componentId: "sc-jezurh-0"
31
- })(["text-decoration:", ";color:", ";:hover{color:", ";text-decoration:underline;}"], function (_ref) {
32
- var underline = _ref.underline;
33
- return underline ? "underline" : "none";
34
- }, function (_ref2) {
35
- var color = _ref2.color;
36
- return color || active;
37
- }, function (_ref3) {
38
- var hoverColor = _ref3.hoverColor;
39
- return hoverColor || active;
40
- });
41
- Link.propTypes = {
42
- color: PropTypes.string,
43
- hoverColor: PropTypes.string,
44
- underline: PropTypes.bool,
45
- children: PropTypes.node
46
- };
47
- Link.defaultProps = {
48
- color: active,
49
- hoverColor: active,
50
- underline: false
51
- };
@@ -1,41 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["label"];
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import React from "react";
7
- import styled from "styled-components";
8
- import PropTypes from "prop-types";
9
- import { white, active, gray06, gray01, gray08 } from "@happeouikit/colors";
10
- import { TextZeta } from "@happeouikit/typography";
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- import { jsxs as _jsxs } from "react/jsx-runtime";
13
- var RadioButton = function RadioButton(_ref) {
14
- var label = _ref.label,
15
- props = _objectWithoutProperties(_ref, _excluded);
16
- return /*#__PURE__*/_jsxs(RadioButtonWrapper, {
17
- children: [/*#__PURE__*/_jsx("input", _objectSpread({
18
- type: "radio"
19
- }, props)), /*#__PURE__*/_jsx(StyledRadioButton, _objectSpread({}, props)), label && /*#__PURE__*/_jsx(Label, {
20
- "data-tip": props["data-tip"],
21
- "data-tip-disable": props["data-tip-disable"],
22
- children: label
23
- })]
24
- });
25
- };
26
- RadioButton.propTypes = {
27
- label: PropTypes.node
28
- };
29
- var StyledRadioButton = styled.span.withConfig({
30
- displayName: "RadioButton__StyledRadioButton",
31
- componentId: "sc-118nqq7-0"
32
- })(["position:absolute;height:12px;width:12px;background-color:", ";border:2px solid ", ";box-shadow:0px 0px 0px 2px ", ";border-radius:50%;"], white, white, gray06);
33
- var Label = styled(TextZeta).withConfig({
34
- displayName: "RadioButton__Label",
35
- componentId: "sc-118nqq7-1"
36
- })(["display:inline-block;margin-left:25px;color:", ";"], gray01);
37
- var RadioButtonWrapper = styled.label.withConfig({
38
- displayName: "RadioButton__RadioButtonWrapper",
39
- componentId: "sc-118nqq7-2"
40
- })(["display:flex;align-items:center;position:relative;cursor:pointer;user-select:none;padding:4px 0;input{display:none;}input:checked ~ ", "{background:", ";box-shadow:0px 0px 0px 2px ", ";}input:disabled + ", "{cursor:not-allowed;box-shadow:0px 0px 0px 2px ", ";}input:disabled ~ ", "{color:", ";cursor:not-allowed;}"], StyledRadioButton, active, active, StyledRadioButton, gray08, Label, gray06);
41
- export default RadioButton;
package/dist/Switch.js DELETED
@@ -1,70 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["label", "tabIndex"];
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import React, { useRef } from "react";
7
- import styled from "styled-components";
8
- import PropTypes from "prop-types";
9
- import { active, gray08, gray01 } from "@happeouikit/colors";
10
- import { BodyUI } from "@happeouikit/typography";
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- import { jsxs as _jsxs } from "react/jsx-runtime";
13
- var Switch = function Switch(_ref) {
14
- var label = _ref.label,
15
- tabIndex = _ref.tabIndex,
16
- props = _objectWithoutProperties(_ref, _excluded);
17
- var checkboxRef = useRef();
18
- var onClick = function onClick(event) {
19
- event.preventDefault();
20
- // Since this component can be used as controlled or uncontrolled
21
- // it should have the ability to change aria-label based on its state
22
- // eslint-disable-next-line no-param-reassign
23
- event.currentTarget.ariaChecked = !checkboxRef.current.checked;
24
- checkboxRef.current.checked = !checkboxRef.current.checked;
25
- props.onChange(event);
26
- };
27
- var onKeyDown = function onKeyDown(event) {
28
- if (typeof props.onChange === "function" && event.key.match(/enter|spacebar|\W{1}/i)) {
29
- onClick(event);
30
- }
31
- };
32
- return /*#__PURE__*/_jsxs(ToggleSwitchWrapper, {
33
- children: [/*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({
34
- ref: checkboxRef,
35
- type: "checkbox"
36
- }, props), {}, {
37
- tabIndex: -1
38
- })), /*#__PURE__*/_jsx(StyledSwitch, _objectSpread({
39
- type: "button",
40
- onKeyDown: onKeyDown,
41
- onClick: onClick,
42
- tabIndex: tabIndex,
43
- role: "switch",
44
- "aria-checked": props.checked || props.defaultChecked
45
- }, props)), label && /*#__PURE__*/_jsx(Label, {
46
- children: label
47
- })]
48
- });
49
- };
50
- Switch.propTypes = {
51
- label: PropTypes.node,
52
- tabIndex: PropTypes.number
53
- };
54
- Switch.defaultProps = {
55
- label: undefined,
56
- tabIndex: 0
57
- };
58
- var StyledSwitch = styled.button.withConfig({
59
- displayName: "Switch__StyledSwitch",
60
- componentId: "sc-1pn4n4-0"
61
- })(["all:unset;position:relative;top:0;left:0;right:0;bottom:0;box-sizing:content-box;width:40px;height:20px;background-color:white;border:2px solid ", ";border-radius:13px;transition:0.4s;:before{position:absolute;content:\"\";height:14px;width:14px;left:3px;bottom:3px;border-radius:50%;background-color:", ";transition:0.4s;}&:focus-visible{outline:0;box-shadow:0 0 0 1px ", ";}&:hover{background-color:transparent;}&:active{background-color:transparent;transform:none;box-shadow:none;}"], gray08, gray08, active);
62
- var ToggleSwitchWrapper = styled.label.withConfig({
63
- displayName: "Switch__ToggleSwitchWrapper",
64
- componentId: "sc-1pn4n4-1"
65
- })(["display:flex;align-items:center;position:relative;cursor:pointer;line-height:33px;padding:8px 0;input{opacity:0;width:0;height:0;}input:checked + ", "{border:2px solid ", ";}input:checked + ", ":before{transform:translateX(20px);background:", ";}input:disabled + ", "{border-color:", ";&:before{background:", ";}}"], StyledSwitch, active, StyledSwitch, active, StyledSwitch, gray08, gray08);
66
- var Label = styled(BodyUI).withConfig({
67
- displayName: "Switch__Label",
68
- componentId: "sc-1pn4n4-2"
69
- })(["margin-left:8px;color:", ";"], gray01);
70
- export default Switch;
package/dist/Tag.js DELETED
@@ -1,59 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["text", "closeCallback", "isUppercase"];
5
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- import React, { useState } from "react";
8
- import styled from "styled-components";
9
- import PropTypes from "prop-types";
10
- import { white, active } from "@happeouikit/colors";
11
- import { IconClose } from "@happeouikit/icons";
12
- import { BodyUI } from "@happeouikit/typography";
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { jsxs as _jsxs } from "react/jsx-runtime";
15
- var Tag = function Tag(_ref) {
16
- var text = _ref.text,
17
- closeCallback = _ref.closeCallback,
18
- isUppercase = _ref.isUppercase,
19
- props = _objectWithoutProperties(_ref, _excluded);
20
- var _useState = useState(true),
21
- _useState2 = _slicedToArray(_useState, 2),
22
- show = _useState2[0],
23
- setShow = _useState2[1];
24
- var onClick = function onClick() {
25
- setShow(false);
26
- closeCallback && closeCallback();
27
- };
28
- return show && /*#__PURE__*/_jsxs(TagWrapper, _objectSpread(_objectSpread({}, props), {}, {
29
- children: [/*#__PURE__*/_jsx(Text, {
30
- bold: true,
31
- uppercase: isUppercase,
32
- children: text
33
- }), /*#__PURE__*/_jsx(IconWrapper, {
34
- onClick: onClick,
35
- children: /*#__PURE__*/_jsx(IconClose, {
36
- width: "16px",
37
- height: "16px"
38
- })
39
- })]
40
- }));
41
- };
42
- Tag.propTypes = {
43
- text: PropTypes.node.isRequired,
44
- closeCallback: PropTypes.func,
45
- isUppercase: PropTypes.bool
46
- };
47
- var TagWrapper = styled.div.withConfig({
48
- displayName: "Tag__TagWrapper",
49
- componentId: "sc-1lpt0c6-0"
50
- })(["display:inline;background:", ";height:24px;width:auto;border-radius:100px;"], active);
51
- var IconWrapper = styled.span.withConfig({
52
- displayName: "Tag__IconWrapper",
53
- componentId: "sc-1lpt0c6-1"
54
- })(["display:inline-block;position:relative;right:5px;fill:", ";cursor:pointer;padding-right:10px;"], white);
55
- var Text = styled(BodyUI).withConfig({
56
- displayName: "Tag__Text",
57
- componentId: "sc-1lpt0c6-2"
58
- })(["display:inline-block;position:relative;padding:2px 11.6px 2px 10px;bottom:3px;color:", ";"], white);
59
- export default Tag;
package/dist/Textarea.js DELETED
@@ -1,88 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["cols", "rows", "label"];
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- /* eslint-disable react/require-default-props */
7
- import React, { useEffect, useRef, useState } from "react";
8
- import styled from "styled-components";
9
- import { active, gray01, gray04, gray06 } from "@happeouikit/colors";
10
- import PropTypes from "prop-types";
11
- import { BodyUI, sansFamily } from "@happeouikit/typography";
12
- import { uuidv4 } from "./utils";
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { Fragment as _Fragment } from "react/jsx-runtime";
15
- import { jsxs as _jsxs } from "react/jsx-runtime";
16
- var Textarea = function Textarea(_ref) {
17
- var cols = _ref.cols,
18
- rows = _ref.rows,
19
- label = _ref.label,
20
- props = _objectWithoutProperties(_ref, _excluded);
21
- var id = useState(uuidv4)[0];
22
- var accessibility = label ? {
23
- "aria-labelledby": id
24
- } : {};
25
- var textareaRef = useRef(null);
26
- useEffect(function () {
27
- var textarea = textareaRef.current;
28
- if (textarea) {
29
- textarea.style.height = "".concat(Math.min(textarea.scrollHeight, props.maxHeight), "px");
30
- }
31
- }, [props.maxHeight]);
32
- var onChange = function onChange(event) {
33
- // Handle auto height
34
- if (props.autoHeight) {
35
- var target = event.target;
36
-
37
- // First set height to inherit to allow textarea to contract
38
- target.style.height = "inherit";
39
- target.style.height = "".concat(target.scrollHeight, "px");
40
- }
41
-
42
- // call props.onChange if exists
43
- if (typeof props.onChange === "function") {
44
- props.onChange(event);
45
- }
46
- };
47
- return /*#__PURE__*/_jsxs(_Fragment, {
48
- children: [!!label && /*#__PURE__*/_jsx(Label, {
49
- id: id,
50
- children: /*#__PURE__*/_jsx(BodyUI, {
51
- bold: true,
52
- color: gray01,
53
- children: label
54
- })
55
- }), /*#__PURE__*/_jsx(StyledTextarea, _objectSpread(_objectSpread(_objectSpread({
56
- ref: textareaRef,
57
- cols: cols,
58
- rows: rows
59
- }, accessibility), props), {}, {
60
- style: _objectSpread(_objectSpread({}, props.style), {}, {
61
- maxHeight: props.maxHeight
62
- }),
63
- onChange: onChange
64
- }))]
65
- });
66
- };
67
- Textarea.propTypes = {
68
- rows: PropTypes.number,
69
- cols: PropTypes.number,
70
- autoHeight: PropTypes.bool,
71
- maxHeight: PropTypes.number
72
- };
73
- Textarea.defaultProps = {
74
- maxHeight: 9999
75
- };
76
- var StyledTextarea = styled.textarea.withConfig({
77
- displayName: "Textarea__StyledTextarea",
78
- componentId: "sc-1qfb7cm-0"
79
- })(["font-family:", ";border-radius:4px;", ";", ";padding:10px 12px;border:solid 1px ", ";box-sizing:border-box;box-shadow:none;font-size:14px;:hover{border-color:", ";}:active{outline:none;border-color:", ";}:focus{outline:none;border-color:", ";}"], sansFamily, function (props) {
80
- return props.cols ? "" : "width: 100%;";
81
- }, function (props) {
82
- return props.rows ? "" : "height: 100%;";
83
- }, gray06, gray04, active, active);
84
- var Label = styled.div.withConfig({
85
- displayName: "Textarea__Label",
86
- componentId: "sc-1qfb7cm-1"
87
- })(["margin:4px 0;"]);
88
- export default Textarea;