@mrshmllw/smores-react 2.1.23 → 2.1.26

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 (89) hide show
  1. package/README.md +2 -1
  2. package/dist/ActionDropdown/ActionDropdown.d.ts +1 -3
  3. package/dist/ActionDropdown/ActionDropdown.js.map +1 -1
  4. package/dist/Button/Button.js +12 -4
  5. package/dist/Button/Button.js.map +1 -1
  6. package/dist/CheckBox/CheckBox.d.ts +1 -1
  7. package/dist/CheckBox/CheckBox.js +10 -6
  8. package/dist/CheckBox/CheckBox.js.map +1 -1
  9. package/dist/CheckBox/index.d.ts +1 -1
  10. package/dist/CheckBox/index.js.map +1 -1
  11. package/dist/ConfirmationRadioButtons/Confirmation.d.ts +2 -1
  12. package/dist/ConfirmationRadioButtons/Confirmation.js +9 -2
  13. package/dist/ConfirmationRadioButtons/Confirmation.js.map +1 -1
  14. package/dist/ConfirmationRadioButtons/Confirmation.stories.d.ts +1 -0
  15. package/dist/ConfirmationRadioButtons/Confirmation.stories.js +8 -0
  16. package/dist/ConfirmationRadioButtons/Confirmation.stories.js.map +1 -1
  17. package/dist/Datepicker/Datepicker.js +2 -3
  18. package/dist/Datepicker/Datepicker.js.map +1 -1
  19. package/dist/Dropdown/Dropdown.d.ts +5 -5
  20. package/dist/Dropdown/Dropdown.js +5 -2
  21. package/dist/Dropdown/Dropdown.js.map +1 -1
  22. package/dist/Dropdown/Dropdown.stories.d.ts +7 -4
  23. package/dist/Dropdown/Dropdown.stories.js +9 -0
  24. package/dist/Dropdown/Dropdown.stories.js.map +1 -1
  25. package/dist/Message/Message.d.ts +3 -0
  26. package/dist/Message/Message.js +14 -5
  27. package/dist/Message/Message.js.map +1 -1
  28. package/dist/Message/Message.stories.js +1 -1
  29. package/dist/Message/Message.stories.js.map +1 -1
  30. package/dist/NumberInput/NumberInput.d.ts +1 -3
  31. package/dist/NumberInput/NumberInput.js +3 -1
  32. package/dist/NumberInput/NumberInput.js.map +1 -1
  33. package/dist/RadioButton/RadioButton.d.ts +1 -1
  34. package/dist/RadioButton/RadioButton.js +9 -5
  35. package/dist/RadioButton/RadioButton.js.map +1 -1
  36. package/dist/SearchInput/SearchInput.d.ts +1 -2
  37. package/dist/SearchInput/SearchInput.js +3 -1
  38. package/dist/SearchInput/SearchInput.js.map +1 -1
  39. package/dist/SupportMessage/Collection.d.ts +2 -0
  40. package/dist/SupportMessage/Collection.js +40 -0
  41. package/dist/SupportMessage/Collection.js.map +1 -0
  42. package/dist/SupportMessage/SupportMessage.d.ts +10 -0
  43. package/dist/SupportMessage/SupportMessage.js +59 -0
  44. package/dist/SupportMessage/SupportMessage.js.map +1 -0
  45. package/dist/SupportMessage/SupportMessage.stories.d.ts +9 -0
  46. package/dist/SupportMessage/SupportMessage.stories.js +17 -0
  47. package/dist/SupportMessage/SupportMessage.stories.js.map +1 -0
  48. package/dist/SupportMessage/SupportMessage.test.d.ts +1 -0
  49. package/dist/SupportMessage/SupportMessage.test.js +30 -0
  50. package/dist/SupportMessage/SupportMessage.test.js.map +1 -0
  51. package/dist/SupportMessage/index.d.ts +1 -0
  52. package/dist/SupportMessage/index.js +2 -0
  53. package/dist/SupportMessage/index.js.map +1 -0
  54. package/dist/Text/Text.stories.d.ts +1 -0
  55. package/dist/Text/Text.stories.js +35 -0
  56. package/dist/Text/Text.stories.js.map +1 -1
  57. package/dist/TextInput/TextInput.d.ts +5 -15
  58. package/dist/TextInput/TextInput.js +5 -2
  59. package/dist/TextInput/TextInput.js.map +1 -1
  60. package/dist/TextInput/TextInput.stories.d.ts +3 -37
  61. package/dist/TextInput/TextInput.stories.js +12 -0
  62. package/dist/TextInput/TextInput.stories.js.map +1 -1
  63. package/dist/Textarea/Textarea.d.ts +3 -3
  64. package/dist/Textarea/Textarea.js +5 -2
  65. package/dist/Textarea/Textarea.js.map +1 -1
  66. package/dist/Textarea/Textarea.stories.d.ts +1 -0
  67. package/dist/Textarea/Textarea.stories.js +10 -0
  68. package/dist/Textarea/Textarea.stories.js.map +1 -1
  69. package/dist/Toggle/Toggle.d.ts +1 -1
  70. package/dist/Toggle/Toggle.stories.d.ts +1 -1
  71. package/dist/index.d.ts +1 -0
  72. package/dist/index.js +1 -0
  73. package/dist/index.js.map +1 -1
  74. package/dist/setupTests.d.ts +1 -0
  75. package/dist/setupTests.js +2 -0
  76. package/dist/setupTests.js.map +1 -0
  77. package/dist/utils/deprecated.d.ts +9 -0
  78. package/dist/utils/deprecated.js +30 -0
  79. package/dist/utils/deprecated.js.map +1 -0
  80. package/dist/utils/id.d.ts +2 -0
  81. package/dist/utils/id.js +13 -0
  82. package/dist/utils/id.js.map +1 -0
  83. package/dist/utils/id.test.d.ts +1 -0
  84. package/dist/utils/id.test.js +30 -0
  85. package/dist/utils/id.test.js.map +1 -0
  86. package/package.json +10 -6
  87. package/dist/CheckBoxGroup/CheckBox.d.ts +0 -9
  88. package/dist/CheckBoxGroup/CheckBox.js +0 -67
  89. package/dist/CheckBoxGroup/CheckBox.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { FC } from 'react';
2
2
  declare type Props = {
3
3
  /** unique ID */
4
- id: string;
4
+ id?: string;
5
5
  /** checked flag */
6
6
  checked: boolean;
7
7
  /** onToggle listener */
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  component: React.FC<{
5
- id: string;
5
+ id?: string | undefined;
6
6
  checked: boolean;
7
7
  onToggle: () => void;
8
8
  }>;
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export * from './Pagination';
22
22
  export * from './RadioButton';
23
23
  export * from './Row';
24
24
  export * from './SearchInput';
25
+ export * from './SupportMessage';
25
26
  export * from './Tag';
26
27
  export * from './Text';
27
28
  export * from './Textarea';
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ export * from './Pagination';
22
22
  export * from './RadioButton';
23
23
  export * from './Row';
24
24
  export * from './SearchInput';
25
+ export * from './SupportMessage';
25
26
  export * from './Tag';
26
27
  export * from './Text';
27
28
  export * from './Textarea';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA;AACtB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA;AACtB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=setupTests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupTests.js","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAA"}
@@ -0,0 +1,9 @@
1
+ export declare const isLocal: boolean;
2
+ declare type UseDeprecatedWarningParams = {
3
+ enabled?: boolean;
4
+ title: string;
5
+ message: string;
6
+ componentProps?: Record<string, any>;
7
+ };
8
+ export declare const useDeprecatedWarning: ({ enabled, title, message, componentProps, }: UseDeprecatedWarningParams) => void;
9
+ export {};
@@ -0,0 +1,30 @@
1
+ import { useEffect } from 'react';
2
+ const env = process.env.REACT_APP_NODE_ENV || process.env.ENV;
3
+ export const isLocal = env === 'local';
4
+ const stripUndefinedProps = (props) => {
5
+ const propKeys = Object.keys(props);
6
+ return propKeys.reduce((acc, key) => {
7
+ if (props[key] !== undefined) {
8
+ acc[key] = props[key];
9
+ }
10
+ return acc;
11
+ }, {});
12
+ };
13
+ export const useDeprecatedWarning = ({ enabled = true, title, message, componentProps, }) => {
14
+ useEffect(() => {
15
+ if (isLocal && enabled) {
16
+ const logs = [
17
+ `%c[Deprecated] ${title}`,
18
+ 'font-weight:bold;',
19
+ '\n',
20
+ '\n',
21
+ message,
22
+ ];
23
+ if (componentProps) {
24
+ logs.push('\n', '\n', 'Component props:', stripUndefinedProps(componentProps));
25
+ }
26
+ console.warn(...logs);
27
+ }
28
+ }, [enabled]);
29
+ };
30
+ //# sourceMappingURL=deprecated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated.js","sourceRoot":"","sources":["../../src/utils/deprecated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAA;AAE7D,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,KAAK,OAAO,CAAA;AAEtC,MAAM,mBAAmB,GAAG,CAAC,KAA8B,EAAE,EAAE;IAC7D,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAEnC,OAAO,QAAQ,CAAC,MAAM,CAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC3D,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;YAC5B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;SACtB;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AACR,CAAC,CAAA;AASD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACnC,OAAO,GAAG,IAAI,EACd,KAAK,EACL,OAAO,EACP,cAAc,GACa,EAAQ,EAAE;IACrC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,IAAI,OAAO,EAAE;YACtB,MAAM,IAAI,GAAU;gBAClB,kBAAkB,KAAK,EAAE;gBACzB,mBAAmB;gBACnB,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACR,CAAA;YAED,IAAI,cAAc,EAAE;gBAClB,IAAI,CAAC,IAAI,CACP,IAAI,EACJ,IAAI,EACJ,kBAAkB,EAClB,mBAAmB,CAAC,cAAc,CAAC,CACpC,CAAA;aACF;YAED,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;SACtB;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;AACf,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const smoresIdPrefix = "MM_SMORES";
2
+ export declare const useUniqueId: (id?: string) => string;
@@ -0,0 +1,13 @@
1
+ import { useMemo } from 'react';
2
+ let idCount = 0;
3
+ export const smoresIdPrefix = 'MM_SMORES';
4
+ const createId = () => {
5
+ const id = `${smoresIdPrefix}_${idCount}`;
6
+ idCount += 1;
7
+ return id;
8
+ };
9
+ export const useUniqueId = (id) => {
10
+ const returnedId = useMemo(() => id || createId(), [id]);
11
+ return returnedId;
12
+ };
13
+ //# sourceMappingURL=id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/utils/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,IAAI,OAAO,GAAG,CAAC,CAAA;AAEf,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAA;AAEzC,MAAM,QAAQ,GAAG,GAAW,EAAE;IAC5B,MAAM,EAAE,GAAG,GAAG,cAAc,IAAI,OAAO,EAAE,CAAA;IACzC,OAAO,IAAI,CAAC,CAAA;IAEZ,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAW,EAAE,EAAE;IACzC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAExD,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { renderHook } from '@testing-library/react-hooks';
11
+ import { smoresIdPrefix, useUniqueId } from './id';
12
+ describe('useUniqueId', () => {
13
+ it('should persist the same id across render', () => __awaiter(void 0, void 0, void 0, function* () {
14
+ const hook = renderHook(() => useUniqueId());
15
+ expect(hook.result.current).toBe(`${smoresIdPrefix}_0`);
16
+ hook.rerender();
17
+ expect(hook.result.current).toBe(`${smoresIdPrefix}_0`);
18
+ }));
19
+ it('should have different id if called from different instance', () => __awaiter(void 0, void 0, void 0, function* () {
20
+ const hook1 = renderHook(() => useUniqueId());
21
+ const hook2 = renderHook(() => useUniqueId());
22
+ expect(hook1.result.current).not.toBe(hook2.result.current);
23
+ }));
24
+ it('should keep to provided id if present', () => __awaiter(void 0, void 0, void 0, function* () {
25
+ const someRandomId = 'someRandomId';
26
+ const hook = renderHook(() => useUniqueId(someRandomId));
27
+ expect(hook.result.current).toBe(someRandomId);
28
+ }));
29
+ });
30
+ //# sourceMappingURL=id.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id.test.js","sourceRoot":"","sources":["../../src/utils/id.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAEzD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAElD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,0CAA0C,EAAE,GAAS,EAAE;QACxD,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;QAE5C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,cAAc,IAAI,CAAC,CAAA;QACvD,IAAI,CAAC,QAAQ,EAAE,CAAA;QACf,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,cAAc,IAAI,CAAC,CAAA;IACzD,CAAC,CAAA,CAAC,CAAA;IAEF,EAAE,CAAC,4DAA4D,EAAE,GAAS,EAAE;QAC1E,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;QAC7C,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;QAE7C,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC7D,CAAC,CAAA,CAAC,CAAA;IAEF,EAAE,CAAC,uCAAuC,EAAE,GAAS,EAAE;QACrD,MAAM,YAAY,GAAG,cAAc,CAAA;QACnC,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAA;QAExD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAChD,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrshmllw/smores-react",
3
- "version": "2.1.23",
3
+ "version": "2.1.26",
4
4
  "main": "./dist/index.js",
5
5
  "description": "Collection of React components used by Marshmallow Technology",
6
6
  "keywords": [
@@ -39,25 +39,29 @@
39
39
  "@storybook/storybook-deployer": "^2.8.7",
40
40
  "@testing-library/jest-dom": "^5.11.4",
41
41
  "@testing-library/react": "^12.0.0",
42
- "@types/jest": "^26.0.14",
42
+ "@testing-library/react-hooks": "^8.0.0",
43
+ "@types/jest": "^28.1.1",
44
+ "@types/node": "^17.0.35",
43
45
  "@types/react": "^17.0.0",
44
46
  "@types/react-dom": "^17.0.9",
45
47
  "@types/styled-components": "^5.1.3",
46
- "@typescript-eslint/eslint-plugin": "^4.3.0",
47
- "@typescript-eslint/parser": "^4.3.0",
48
+ "@types/testing-library__jest-dom": "^5.14.3",
49
+ "@types/testing-library__react": "^10.2.0",
50
+ "@typescript-eslint/eslint-plugin": "^5.28.0",
51
+ "@typescript-eslint/parser": "^5.28.0",
48
52
  "babel-eslint": "^10.1.0",
49
53
  "babel-jest": "^28.0.3",
50
54
  "babel-loader": "^8.1.0",
51
55
  "eslint": "^7.9.0",
52
56
  "eslint-config-prettier": "^8.2.0",
53
- "eslint-plugin-jest": "^26.0.0",
57
+ "eslint-plugin-jest": "^26.5.3",
54
58
  "eslint-plugin-react": "^7.29.2",
55
59
  "eslint-plugin-react-hooks": "^4.1.2",
56
60
  "husky": "^8.0.1",
57
61
  "jest": "^28.0.3",
58
62
  "jest-environment-jsdom": "^28.1.0",
59
63
  "jest-styled-components": "^7.0.3",
60
- "lint-staged": "^12.0.2",
64
+ "lint-staged": "^13.0.0",
61
65
  "prettier": "^2.1.2",
62
66
  "storybook-addon-performance": "^0.16.1"
63
67
  },
@@ -1,9 +0,0 @@
1
- import { FC, ReactNode } from 'react';
2
- declare type Props = {
3
- id: string;
4
- checked: boolean;
5
- children: ReactNode;
6
- toggle: () => void;
7
- };
8
- export declare const CheckBox: FC<Props>;
9
- export {};
@@ -1,67 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import { Text } from '../Text';
4
- import { theme } from '../theme';
5
- export const CheckBox = ({ id, checked, children, toggle }) => (React.createElement(BoxContainer, { id: id },
6
- React.createElement(Text, { tag: "span", typo: "base" }, children),
7
- React.createElement("input", { type: "checkbox", checked: checked, onChange: toggle }),
8
- React.createElement(Checkmark, null)));
9
- const Checkmark = styled.span `
10
- position: absolute;
11
- left: 0;
12
- width: 24px;
13
- height: 24px;
14
- border: solid 1px ${theme.colors.secondary};
15
- box-sizing: border-box;
16
- border-radius: 1px;
17
-
18
- &:after {
19
- content: '';
20
- position: absolute;
21
- display: none;
22
- top: 3px;
23
- left: 7px;
24
- width: 5px;
25
- height: 12px;
26
- border: solid white;
27
- border-width: 0 2px 2px 0;
28
- -webkit-transform: rotate(45deg);
29
- -ms-transform: rotate(45deg);
30
- transform: rotate(45deg);
31
- }
32
- `;
33
- const BoxContainer = styled.label `
34
- position: relative;
35
- display: flex;
36
- align-items: flex-start;
37
- padding-left: 32px;
38
- user-select: none;
39
- cursor: pointer;
40
-
41
- input {
42
- position: absolute;
43
- opacity: 0;
44
- cursor: pointer;
45
-
46
- &:checked ~ ${Checkmark} {
47
- background-color: ${theme.colors.secondary};
48
- border: solid 1px ${theme.colors.secondary};
49
- }
50
-
51
- &:checked ~ ${Checkmark}:after {
52
- display: block;
53
- }
54
- }
55
-
56
- &:hover {
57
- ${Checkmark} {
58
- background-color: ${theme.colors.background};
59
- border: solid 1px ${theme.colors.secondary};
60
- }
61
- }
62
-
63
- @media (min-width: 768px) {
64
- padding-left: 32px;
65
- }
66
- `;
67
- //# sourceMappingURL=CheckBox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CheckBox.js","sourceRoot":"","sources":["../../src/CheckBoxGroup/CheckBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAA;AAC5C,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAShC,MAAM,CAAC,MAAM,QAAQ,GAAc,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACxE,oBAAC,YAAY,IAAC,EAAE,EAAE,EAAE;IAClB,oBAAC,IAAI,IAAC,GAAG,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,IACzB,QAAQ,CACJ;IAEP,+BAAO,IAAI,EAAC,UAAU,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAI;IAC7D,oBAAC,SAAS,OAAG,CACA,CAChB,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;sBAKP,KAAK,CAAC,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;CAkB3C,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;;;;;;;kBAaf,SAAS;0BACD,KAAK,CAAC,MAAM,CAAC,SAAS;0BACtB,KAAK,CAAC,MAAM,CAAC,SAAS;;;kBAG9B,SAAS;;;;;;MAMrB,SAAS;0BACW,KAAK,CAAC,MAAM,CAAC,UAAU;0BACvB,KAAK,CAAC,MAAM,CAAC,SAAS;;;;;;;CAO/C,CAAA"}