@lynx-js/lynx-ui-checkbox 3.136.0 → 3.139.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @lynx-js/lynx-ui-checkbox
2
2
 
3
+ ## 3.139.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Keep the Checkbox root `ui-checked` variant synchronized with its controlled or uncontrolled checked state. ([#329](https://github.com/lynx-family/lynx-ui/pull/329))
8
+
9
+ - Updated dependencies [[`1a4ad19`](https://github.com/lynx-family/lynx-ui/commit/1a4ad190993d57425b4c377a7dd63882cc65a8d2)]:
10
+ - @lynx-js/lynx-ui-common@3.139.0
11
+ - @lynx-js/lynx-ui-button@3.139.0
12
+
13
+ ## 3.137.0
14
+
15
+ ### Patch Changes
16
+
17
+ - Emit declaration imports with explicit ESM-compatible paths. ([#280](https://github.com/lynx-family/lynx-ui/pull/280))
18
+
19
+ - Updated dependencies [[`064ea4e`](https://github.com/lynx-family/lynx-ui/commit/064ea4e49cd3d0ac5754519cbee43d8ab3040024)]:
20
+ - @lynx-js/lynx-ui-button@3.137.0
21
+ - @lynx-js/lynx-ui-common@3.137.0
22
+
3
23
  ## 3.136.0
4
24
 
5
25
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from '@lynx-js/react';
2
- import type { CheckboxProps } from './types';
3
- export type { CheckboxProps, CheckboxIndicatorProps } from './types';
2
+ import type { CheckboxProps } from './types/index.js';
3
+ export type { CheckboxProps, CheckboxIndicatorProps } from './types/index.js';
4
4
  export declare const Checkbox: (props: CheckboxProps) => ReactNode;
5
5
  //# sourceMappingURL=Checkbox.d.ts.map
package/dist/Checkbox.jsx CHANGED
@@ -26,7 +26,7 @@ const Checkbox = (props)=>{
26
26
  return <CheckboxContext.Provider value={checkboxContextValue}>
27
27
  <Button disabled={disabled} onClick={handleClick} style={style} className={clsx(className, {
28
28
  'ui-indeterminate': indeterminate,
29
- 'ui-checked': checked
29
+ 'ui-checked': actualChecked
30
30
  })} buttonProps={checkboxProps}>
31
31
  {renderContentWithExtraProps({
32
32
  checked: actualChecked,
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.jsx","sources":["../src/Checkbox.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useMemo, useState } from '@lynx-js/react'\nimport type { ReactNode } from '@lynx-js/react'\n\nimport { Button } from '@lynx-js/lynx-ui-button'\nimport {\n renderContentWithExtraProps,\n useMemoizedFn,\n} from '@lynx-js/lynx-ui-common'\nimport { clsx } from 'clsx'\n\nimport { CheckboxContext } from './CheckboxContext'\nimport type { CheckboxProps } from './types'\n\nexport type { CheckboxProps, CheckboxIndicatorProps } from './types'\nexport const Checkbox = (props: CheckboxProps): ReactNode => {\n const {\n style,\n className,\n children,\n onChange,\n checked,\n defaultChecked = false,\n disabled = false,\n indeterminate = false,\n checkboxProps,\n } = props\n const isControlled = checked !== undefined\n const [uncontrolledChecked, setUncontrolledChecked] = useState<boolean>(\n defaultChecked,\n )\n const actualChecked = isControlled ? checked : uncontrolledChecked\n\n const handleValueChange = useMemoizedFn((newChecked: boolean) => {\n if (!isControlled) {\n setUncontrolledChecked(newChecked)\n }\n onChange?.(newChecked)\n })\n\n const handleClick = useMemoizedFn(() => {\n if (indeterminate) {\n handleValueChange(true)\n return\n }\n handleValueChange(!actualChecked)\n })\n\n const checkboxContextValue = useMemo(() => ({\n checked: actualChecked,\n indeterminate,\n }), [actualChecked, indeterminate])\n\n return (\n <CheckboxContext.Provider value={checkboxContextValue}>\n <Button\n disabled={disabled}\n onClick={handleClick}\n style={style}\n className={clsx(className, {\n 'ui-indeterminate': indeterminate,\n 'ui-checked': checked,\n })}\n buttonProps={checkboxProps}\n >\n {renderContentWithExtraProps(\n { checked: actualChecked, indeterminate },\n children,\n )}\n </Button>\n </CheckboxContext.Provider>\n )\n}\n"],"names":["Checkbox","props","style","className","children","onChange","checked","defaultChecked","disabled","indeterminate","checkboxProps","isControlled","undefined","uncontrolledChecked","setUncontrolledChecked","useState","actualChecked","handleValueChange","useMemoizedFn","newChecked","handleClick","checkboxContextValue","useMemo","CheckboxContext","Button","clsx","renderContentWithExtraProps"],"mappings":";;;;;AAkBO,MAAMA,WAAW,CAACC;IACvB,MAAM,EACJC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,iBAAiB,KAAK,EACtBC,WAAW,KAAK,EAChBC,gBAAgB,KAAK,EACrBC,aAAa,EACd,GAAGT;IACJ,MAAMU,eAAeL,AAAYM,WAAZN;IACrB,MAAM,CAACO,qBAAqBC,uBAAuB,GAAGC,SACpDR;IAEF,MAAMS,gBAAgBL,eAAeL,UAAUO;IAE/C,MAAMI,oBAAoBC,cAAc,CAACC;QACvC,IAAI,CAACR,cACHG,uBAAuBK;QAEzBd,WAAWc;IACb;IAEA,MAAMC,cAAcF,cAAc;QAChC,IAAIT,eAAe,YACjBQ,kBAAkB;QAGpBA,kBAAkB,CAACD;IACrB;IAEA,MAAMK,uBAAuBC,QAAQ,IAAO;YAC1C,SAASN;YACTP;QACF,IAAI;QAACO;QAAeP;KAAc;IAElC,QACGc,gBAAgB,SAAS,OAAOF,sBAAsB;MACrD,CAACG,OACC,UAAUhB,UACV,SAASY,aACT,OAAOlB,OACP,WAAWuB,KAAKtB,WAAW;QACzB,oBAAoBM;QACpB,cAAcH;IAChB,IACA,aAAaI,eACd;QACC,CAACgB,4BACC;QAAE,SAASV;QAAeP;IAAc,GACxCL,UACA;MACJ,EAAEoB,OAAO;IACX,EAAED,gBAAgB;AAEtB"}
1
+ {"version":3,"file":"Checkbox.jsx","sources":["../src/Checkbox.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useMemo, useState } from '@lynx-js/react'\nimport type { ReactNode } from '@lynx-js/react'\n\nimport { Button } from '@lynx-js/lynx-ui-button'\nimport {\n renderContentWithExtraProps,\n useMemoizedFn,\n} from '@lynx-js/lynx-ui-common'\nimport { clsx } from 'clsx'\n\nimport { CheckboxContext } from './CheckboxContext'\nimport type { CheckboxProps } from './types'\n\nexport type { CheckboxProps, CheckboxIndicatorProps } from './types'\nexport const Checkbox = (props: CheckboxProps): ReactNode => {\n const {\n style,\n className,\n children,\n onChange,\n checked,\n defaultChecked = false,\n disabled = false,\n indeterminate = false,\n checkboxProps,\n } = props\n const isControlled = checked !== undefined\n const [uncontrolledChecked, setUncontrolledChecked] = useState<boolean>(\n defaultChecked,\n )\n const actualChecked = isControlled ? checked : uncontrolledChecked\n\n const handleValueChange = useMemoizedFn((newChecked: boolean) => {\n if (!isControlled) {\n setUncontrolledChecked(newChecked)\n }\n onChange?.(newChecked)\n })\n\n const handleClick = useMemoizedFn(() => {\n if (indeterminate) {\n handleValueChange(true)\n return\n }\n handleValueChange(!actualChecked)\n })\n\n const checkboxContextValue = useMemo(() => ({\n checked: actualChecked,\n indeterminate,\n }), [actualChecked, indeterminate])\n\n return (\n <CheckboxContext.Provider value={checkboxContextValue}>\n <Button\n disabled={disabled}\n onClick={handleClick}\n style={style}\n className={clsx(className, {\n 'ui-indeterminate': indeterminate,\n 'ui-checked': actualChecked,\n })}\n buttonProps={checkboxProps}\n >\n {renderContentWithExtraProps(\n { checked: actualChecked, indeterminate },\n children,\n )}\n </Button>\n </CheckboxContext.Provider>\n )\n}\n"],"names":["Checkbox","props","style","className","children","onChange","checked","defaultChecked","disabled","indeterminate","checkboxProps","isControlled","undefined","uncontrolledChecked","setUncontrolledChecked","useState","actualChecked","handleValueChange","useMemoizedFn","newChecked","handleClick","checkboxContextValue","useMemo","CheckboxContext","Button","clsx","renderContentWithExtraProps"],"mappings":";;;;;AAkBO,MAAMA,WAAW,CAACC;IACvB,MAAM,EACJC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,iBAAiB,KAAK,EACtBC,WAAW,KAAK,EAChBC,gBAAgB,KAAK,EACrBC,aAAa,EACd,GAAGT;IACJ,MAAMU,eAAeL,AAAYM,WAAZN;IACrB,MAAM,CAACO,qBAAqBC,uBAAuB,GAAGC,SACpDR;IAEF,MAAMS,gBAAgBL,eAAeL,UAAUO;IAE/C,MAAMI,oBAAoBC,cAAc,CAACC;QACvC,IAAI,CAACR,cACHG,uBAAuBK;QAEzBd,WAAWc;IACb;IAEA,MAAMC,cAAcF,cAAc;QAChC,IAAIT,eAAe,YACjBQ,kBAAkB;QAGpBA,kBAAkB,CAACD;IACrB;IAEA,MAAMK,uBAAuBC,QAAQ,IAAO;YAC1C,SAASN;YACTP;QACF,IAAI;QAACO;QAAeP;KAAc;IAElC,QACGc,gBAAgB,SAAS,OAAOF,sBAAsB;MACrD,CAACG,OACC,UAAUhB,UACV,SAASY,aACT,OAAOlB,OACP,WAAWuB,KAAKtB,WAAW;QACzB,oBAAoBM;QACpB,cAAcO;IAChB,IACA,aAAaN,eACd;QACC,CAACgB,4BACC;QAAE,SAASV;QAAeP;IAAc,GACxCL,UACA;MACJ,EAAEoB,OAAO;IACX,EAAED,gBAAgB;AAEtB"}
@@ -1,4 +1,4 @@
1
- export type { CheckboxProps, CheckboxIndicatorProps } from './types';
1
+ export type { CheckboxProps, CheckboxIndicatorProps } from './types/index.js';
2
2
  export declare const CheckboxContext: import("react").Context<{
3
3
  checked: boolean;
4
4
  indeterminate: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from '@lynx-js/react';
2
- import type { CheckboxIndicatorProps } from './types';
3
- export type { CheckboxProps, CheckboxIndicatorProps } from './types';
2
+ import type { CheckboxIndicatorProps } from './types/index.js';
3
+ export type { CheckboxProps, CheckboxIndicatorProps } from './types/index.js';
4
4
  export declare const CheckboxIndicator: (props: CheckboxIndicatorProps) => ReactNode;
5
5
  //# sourceMappingURL=CheckboxIndicator.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Checkbox } from './Checkbox';
2
- export { CheckboxIndicator } from './CheckboxIndicator';
3
- export type { CheckboxProps, CheckboxIndicatorProps } from './types';
1
+ export { Checkbox } from './Checkbox.js';
2
+ export { CheckboxIndicator } from './CheckboxIndicator.js';
3
+ export type { CheckboxProps, CheckboxIndicatorProps } from './types/index.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- export type * from './index.docs';
1
+ export type * from './index.docs.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -109,7 +109,7 @@ export interface CheckboxRenderProps {
109
109
  * Use them as CSS selectors to style different states.
110
110
  * @zh Checkbox 根据交互状态注入的 ui-variants,可用于 CSS selector 按状态定制样式。
111
111
  */
112
- export interface CheckboxUiVariants {
112
+ export interface CheckboxUIVariants {
113
113
  /**
114
114
  * Applied when `status.checked` is true.
115
115
  * @zh 当 status.checked 为 true 时生效,可用于 `.ui-checked { ... }`。
@@ -131,4 +131,8 @@ export interface CheckboxUiVariants {
131
131
  */
132
132
  'ui-disabled'?: boolean;
133
133
  }
134
+ /**
135
+ * @deprecated Use `CheckboxUIVariants` instead.
136
+ */
137
+ export type CheckboxUiVariants = CheckboxUIVariants;
134
138
  //# sourceMappingURL=index.docs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACxD;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;;OAKG;IACH,OAAO,CA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,YAAY,CAAC,EAAE,OAAO,CAAA;IAEtB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAE5B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/lynx-ui-checkbox",
3
- "version": "3.136.0",
3
+ "version": "3.139.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lynx-family/lynx-ui.git",
@@ -26,14 +26,15 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "clsx": "^2.1.1",
29
- "@lynx-js/lynx-ui-button": "3.136.0",
30
- "@lynx-js/lynx-ui-common": "3.136.0"
29
+ "@lynx-js/lynx-ui-button": "3.139.0",
30
+ "@lynx-js/lynx-ui-common": "3.139.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@lynx-js/react": "0.123.1",
34
34
  "@lynx-js/types": "4.1.0",
35
35
  "@rslib/core": "0.23.2",
36
36
  "@types/react": "^18.3.8",
37
+ "jsdom": "^25.0.1",
37
38
  "typescript": "^5.8.0"
38
39
  },
39
40
  "peerDependencies": {
@@ -47,6 +48,7 @@
47
48
  "jsnext:source": "./src/index.tsx",
48
49
  "scripts": {
49
50
  "build": "rslib build",
50
- "build:watch": "rslib build --watch"
51
+ "build:watch": "rslib build --watch",
52
+ "test": "vitest"
51
53
  }
52
54
  }
package/src/Checkbox.tsx CHANGED
@@ -62,7 +62,7 @@ export const Checkbox = (props: CheckboxProps): ReactNode => {
62
62
  style={style}
63
63
  className={clsx(className, {
64
64
  'ui-indeterminate': indeterminate,
65
- 'ui-checked': checked,
65
+ 'ui-checked': actualChecked,
66
66
  })}
67
67
  buttonProps={checkboxProps}
68
68
  >
@@ -125,7 +125,7 @@ export interface CheckboxRenderProps {
125
125
  * Use them as CSS selectors to style different states.
126
126
  * @zh Checkbox 根据交互状态注入的 ui-variants,可用于 CSS selector 按状态定制样式。
127
127
  */
128
- export interface CheckboxUiVariants {
128
+ export interface CheckboxUIVariants {
129
129
  /**
130
130
  * Applied when `status.checked` is true.
131
131
  * @zh 当 status.checked 为 true 时生效,可用于 `.ui-checked { ... }`。
@@ -150,3 +150,8 @@ export interface CheckboxUiVariants {
150
150
  */
151
151
  'ui-disabled'?: boolean
152
152
  }
153
+
154
+ /**
155
+ * @deprecated Use `CheckboxUIVariants` instead.
156
+ */
157
+ export type CheckboxUiVariants = CheckboxUIVariants