@panneau/field-toggle 4.0.38 → 4.0.40-alpha.3

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 (2) hide show
  1. package/dist/index.js +77 -35
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,50 +1,92 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
1
+ import { c } from 'react/compiler-runtime';
2
2
  import classNames from 'classnames';
3
3
  import Switch from 'rc-switch';
4
- import { useMemo, useCallback } from 'react';
5
4
  import 'rc-switch/assets/index.css';
6
5
  import { jsx } from 'react/jsx-runtime';
7
6
 
8
7
  var styles = {"container":"panneau-field-toggle-container"};
9
8
 
10
- function ToggleField(_ref) {
11
- var _ref$value = _ref.value,
12
- value = _ref$value === void 0 ? null : _ref$value,
13
- _ref$queryValue = _ref.queryValue,
14
- queryValue = _ref$queryValue === void 0 ? null : _ref$queryValue,
15
- _ref$name = _ref.name,
16
- name = _ref$name === void 0 ? null : _ref$name,
17
- _ref$disabled = _ref.disabled,
18
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
19
- _ref$className = _ref.className,
20
- className = _ref$className === void 0 ? null : _ref$className,
21
- _ref$onChange = _ref.onChange,
22
- onChange = _ref$onChange === void 0 ? null : _ref$onChange;
23
- var isTrue = useMemo(function () {
24
- return queryValue !== null ? value === queryValue : value === true || value === 'true' || value === 1 || value === '1';
25
- }, [value, queryValue]);
26
- var finalOnChange = useCallback(function (val) {
27
- if (queryValue !== null) {
28
- if (val === true) {
29
- onChange === null || onChange === void 0 || onChange(queryValue);
9
+ function ToggleField(t0) {
10
+ const $ = c(15);
11
+ const {
12
+ value: t1,
13
+ queryValue: t2,
14
+ name: t3,
15
+ disabled: t4,
16
+ className: t5,
17
+ onChange: t6
18
+ } = t0;
19
+ const value = t1 === undefined ? null : t1;
20
+ const queryValue = t2 === undefined ? null : t2;
21
+ const name = t3 === undefined ? null : t3;
22
+ const disabled = t4 === undefined ? false : t4;
23
+ const className = t5 === undefined ? null : t5;
24
+ const onChange = t6 === undefined ? null : t6;
25
+ const isTrue = queryValue !== null ? value === queryValue : value === true || value === "true" || value === 1 || value === "1";
26
+ let t7;
27
+ if ($[0] !== onChange || $[1] !== queryValue) {
28
+ t7 = val => {
29
+ if (queryValue !== null) {
30
+ if (val === true) {
31
+ onChange?.(queryValue);
32
+ } else {
33
+ onChange?.(null);
34
+ }
30
35
  } else {
31
- onChange === null || onChange === void 0 || onChange(null);
36
+ onChange?.(val);
32
37
  }
33
- } else {
34
- onChange === null || onChange === void 0 || onChange(val);
35
- }
36
- }, [onChange, queryValue]);
37
- return /*#__PURE__*/jsx("div", {
38
- className: classNames([styles.container, _defineProperty({
39
- disabled: disabled
40
- }, className, className !== null)]),
41
- children: /*#__PURE__*/jsx(Switch, {
42
- name: name || undefined,
38
+ };
39
+ $[0] = onChange;
40
+ $[1] = queryValue;
41
+ $[2] = t7;
42
+ } else {
43
+ t7 = $[2];
44
+ }
45
+ const finalOnChange = t7;
46
+ const t8 = className !== null;
47
+ let t9;
48
+ if ($[3] !== className || $[4] !== disabled || $[5] !== t8) {
49
+ t9 = classNames([styles.container, {
50
+ disabled,
51
+ [className]: t8
52
+ }]);
53
+ $[3] = className;
54
+ $[4] = disabled;
55
+ $[5] = t8;
56
+ $[6] = t9;
57
+ } else {
58
+ t9 = $[6];
59
+ }
60
+ const t10 = name || undefined;
61
+ let t11;
62
+ if ($[7] !== disabled || $[8] !== finalOnChange || $[9] !== isTrue || $[10] !== t10) {
63
+ t11 = /*#__PURE__*/jsx(Switch, {
64
+ name: t10,
43
65
  checked: isTrue,
44
66
  onChange: finalOnChange,
45
67
  disabled: disabled
46
- })
47
- });
68
+ });
69
+ $[7] = disabled;
70
+ $[8] = finalOnChange;
71
+ $[9] = isTrue;
72
+ $[10] = t10;
73
+ $[11] = t11;
74
+ } else {
75
+ t11 = $[11];
76
+ }
77
+ let t12;
78
+ if ($[12] !== t11 || $[13] !== t9) {
79
+ t12 = /*#__PURE__*/jsx("div", {
80
+ className: t9,
81
+ children: t11
82
+ });
83
+ $[12] = t11;
84
+ $[13] = t9;
85
+ $[14] = t12;
86
+ } else {
87
+ t12 = $[14];
88
+ }
89
+ return t12;
48
90
  }
49
91
 
50
92
  var definition = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/field-toggle",
3
- "version": "4.0.38",
3
+ "version": "4.0.40-alpha.3",
4
4
  "description": "A toggle field",
5
5
  "keywords": [
6
6
  "javascript"
@@ -64,13 +64,13 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@babel/runtime": "^7.28.6",
67
- "@panneau/core": "^4.0.38",
68
- "@panneau/themes": "^4.0.38",
67
+ "@panneau/core": "^4.0.40-alpha.3",
68
+ "@panneau/themes": "^4.0.40-alpha.3",
69
69
  "classnames": "^2.5.1",
70
70
  "rc-switch": "^4.1.0"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "fa4b9c4ec7fe5c0e360dda5a40f8b5d8c7ada651"
75
+ "gitHead": "1735964a2702ae0480b642225286e4184f36680d"
76
76
  }