@lynx-js/lynx-ui-switch 3.139.0 → 3.142.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,14 @@
1
1
  # @lynx-js/lynx-ui-switch
2
2
 
3
+ ## 3.142.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Accept React 18 and newer types. ReactLynx still defines the compatible versions for each app. ([#383](https://github.com/lynx-family/lynx-ui/pull/383))
8
+
9
+ - Updated dependencies [[`49cb3c5`](https://github.com/lynx-family/lynx-ui/commit/49cb3c5b20d9346ff0f8b314367b4c8e354d195d)]:
10
+ - @lynx-js/lynx-ui-common@3.142.0
11
+
3
12
  ## 3.139.0
4
13
 
5
14
  ### Patch Changes
@@ -1,7 +1,8 @@
1
1
  import type { ReactNode } from '@lynx-js/react';
2
2
  import type { ComponentBasicProps } from '@lynx-js/lynx-ui-common';
3
3
  import type { ViewProps } from '@lynx-js/types';
4
- /** Props for the Switch component.
4
+ /**
5
+ * Props for the Switch component.
5
6
  * @zh Switch 组件的属性
6
7
  */
7
8
  export interface SwitchProps extends ComponentBasicProps {
@@ -54,7 +55,8 @@ export interface SwitchProps extends ComponentBasicProps {
54
55
  */
55
56
  children?: ReactNode | ((status: SwitchRenderProps) => ReactNode);
56
57
  }
57
- /** Render state props passed to custom Switch content.
58
+ /**
59
+ * Render state props passed to custom Switch content.
58
60
  * @zh Switch 自定义渲染的状态属性
59
61
  */
60
62
  export interface SwitchRenderProps {
@@ -83,7 +85,7 @@ export interface SwitchRenderProps {
83
85
  /**
84
86
  * UI variants applied by Switch based on render state.
85
87
  * Use them as CSS selectors to style different states.
86
- * @zh Switch 根据状态注入的 ui-variants,可用于 CSS selector 按状态定制样式。
88
+ * @zh Switch 根据状态注入的 UI variants,可用于 CSS selector 按状态定制样式。
87
89
  */
88
90
  export interface SwitchUIVariants {
89
91
  /**
@@ -102,6 +104,18 @@ export interface SwitchUIVariants {
102
104
  */
103
105
  'ui-disabled'?: boolean;
104
106
  }
107
+ /**
108
+ * UI variants exposed by SwitchTrack.
109
+ * @zh SwitchTrack 暴露的 UI variants。
110
+ */
111
+ export interface SwitchTrackUIVariants extends SwitchUIVariants {
112
+ }
113
+ /**
114
+ * UI variants exposed by SwitchThumb.
115
+ * @zh SwitchThumb 暴露的 UI variants。
116
+ */
117
+ export interface SwitchThumbUIVariants extends SwitchUIVariants {
118
+ }
105
119
  /**
106
120
  * @deprecated Use `SwitchUIVariants` instead.
107
121
  */
@@ -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;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,mBAAmB;IACtD;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IAExB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAErC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,CAAA;IAEvB;;;;;;OAMG;IACH,QAAQ,CAAC,EACL,SAAS,GACT,CAAC,CACD,MAAM,EAAE,iBAAiB,KACtB,SAAS,CAAC,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAA;IAEhB;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAA;IAEf;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CA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AAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,GAC3E,sBAAsB,CA4BxB"}
1
+ {"version":3,"file":"use-press-tap.d.ts","sourceRoot":"","sources":["../src/use-press-tap.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAKhD,UAAU,sBAAuB,SAAQ,UAAU,CAAC,OAAO,iBAAiB,CAAC;IAC3E,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;CACjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,EAAE,QAAgB,EAAE,KAAK,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,GAC3E,sBAAsB,CA4BxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-press-tap.jsx","sources":["../src/use-press-tap.ts"],"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 { useState } from '@lynx-js/react'\n\nimport { useTouchEmulation } from '@lynx-js/react-use'\nimport type { TouchEvent } from '@lynx-js/types'\n\nimport { useEffectEvent } from './use-effect-event'\n\ninterface UsePressTapReturnValue extends ReturnType<typeof useTouchEmulation> {\n pressed: boolean\n bindtap: (e: TouchEvent) => void\n}\n\n/**\n * usePressTap\n *\n * Hook that provides press/tap interaction state similar to <button>.\n *\n * - When `disabled` is true:\n * - The element cannot become active.\n * - No tap will fire.\n * - If the element becomes disabled during a press:\n * - The active state is cleared immediately.\n */\nexport function usePressTap(\n { disabled = false, onTap }: { disabled?: boolean, onTap?: () => void } = {},\n): UsePressTapReturnValue {\n const [pressed, setPressed] = useState(false)\n\n const press = useEffectEvent(() => {\n if (disabled) return\n setPressed(true)\n })\n\n const reset = useEffectEvent(() => {\n setPressed(false)\n })\n\n const handleTap = useEffectEvent(() => {\n if (disabled) return\n onTap?.()\n })\n\n const touchHandlers = useTouchEmulation({\n onTouchStart: press,\n onTouchEnd: reset,\n onTouchCancel: reset,\n })\n\n return {\n pressed,\n bindtap: handleTap,\n ...touchHandlers,\n }\n}\n"],"names":["usePressTap","disabled","onTap","pressed","setPressed","useState","press","useEffectEvent","reset","handleTap","touchHandlers","useTouchEmulation"],"mappings":";;;AA2BO,SAASA,YACd,EAAEC,WAAW,KAAK,EAAEC,KAAK,EAA8C,GAAG,CAAC,CAAC;IAE5E,MAAM,CAACC,SAASC,WAAW,GAAGC,SAAS;IAEvC,MAAMC,QAAQC,eAAe;QAC3B,IAAIN,UAAU;QACdG,WAAW;IACb;IAEA,MAAMI,QAAQD,eAAe;QAC3BH,WAAW;IACb;IAEA,MAAMK,YAAYF,eAAe;QAC/B,IAAIN,UAAU;QACdC;IACF;IAEA,MAAMQ,gBAAgBC,kBAAkB;QACtC,cAAcL;QACd,YAAYE;QACZ,eAAeA;IACjB;IAEA,OAAO;QACLL;QACA,SAASM;QACT,GAAGC,aAAa;IAClB;AACF"}
1
+ {"version":3,"file":"use-press-tap.jsx","sources":["../src/use-press-tap.ts"],"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 { useState } from '@lynx-js/react'\n\nimport { useTouchEmulation } from '@lynx-js/react-use'\nimport type { TouchEvent } from '@lynx-js/types'\n\n// This local helper is a stable callback, not React's restricted Effect Event.\nimport { useEffectEvent as useStableCallback } from './use-effect-event'\n\ninterface UsePressTapReturnValue extends ReturnType<typeof useTouchEmulation> {\n pressed: boolean\n bindtap: (e: TouchEvent) => void\n}\n\n/**\n * usePressTap\n *\n * Hook that provides press/tap interaction state similar to <button>.\n *\n * - When `disabled` is true:\n * - The element cannot become active.\n * - No tap will fire.\n * - If the element becomes disabled during a press:\n * - The active state is cleared immediately.\n */\nexport function usePressTap(\n { disabled = false, onTap }: { disabled?: boolean, onTap?: () => void } = {},\n): UsePressTapReturnValue {\n const [pressed, setPressed] = useState(false)\n\n const press = useStableCallback(() => {\n if (disabled) return\n setPressed(true)\n })\n\n const reset = useStableCallback(() => {\n setPressed(false)\n })\n\n const handleTap = useStableCallback(() => {\n if (disabled) return\n onTap?.()\n })\n\n const touchHandlers = useTouchEmulation({\n onTouchStart: press,\n onTouchEnd: reset,\n onTouchCancel: reset,\n })\n\n return {\n pressed,\n bindtap: handleTap,\n ...touchHandlers,\n }\n}\n"],"names":["usePressTap","disabled","onTap","pressed","setPressed","useState","press","useStableCallback","reset","handleTap","touchHandlers","useTouchEmulation"],"mappings":";;;AA4BO,SAASA,YACd,EAAEC,WAAW,KAAK,EAAEC,KAAK,EAA8C,GAAG,CAAC,CAAC;IAE5E,MAAM,CAACC,SAASC,WAAW,GAAGC,SAAS;IAEvC,MAAMC,QAAQC,eAAkB;QAC9B,IAAIN,UAAU;QACdG,WAAW;IACb;IAEA,MAAMI,QAAQD,eAAkB;QAC9BH,WAAW;IACb;IAEA,MAAMK,YAAYF,eAAkB;QAClC,IAAIN,UAAU;QACdC;IACF;IAEA,MAAMQ,gBAAgBC,kBAAkB;QACtC,cAAcL;QACd,YAAYE;QACZ,eAAeA;IACjB;IAEA,OAAO;QACLL;QACA,SAASM;QACT,GAAGC,aAAa;IAClB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/lynx-ui-switch",
3
- "version": "3.139.0",
3
+ "version": "3.142.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lynx-family/lynx-ui.git",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@lynx-js/react-use": "0.2.2",
29
29
  "clsx": "^2.1.1",
30
- "@lynx-js/lynx-ui-common": "3.139.0"
30
+ "@lynx-js/lynx-ui-common": "3.142.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@lynx-js/react": "0.123.1",
@@ -39,7 +39,7 @@
39
39
  "peerDependencies": {
40
40
  "@lynx-js/react": ">=0.100.0",
41
41
  "@lynx-js/types": "*",
42
- "@types/react": "^18"
42
+ "@types/react": ">=18"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"
@@ -7,7 +7,8 @@ import type { ReactNode } from '@lynx-js/react'
7
7
  import type { ComponentBasicProps } from '@lynx-js/lynx-ui-common'
8
8
  import type { ViewProps } from '@lynx-js/types'
9
9
 
10
- /** Props for the Switch component.
10
+ /**
11
+ * Props for the Switch component.
11
12
  * @zh Switch 组件的属性
12
13
  */
13
14
  export interface SwitchProps extends ComponentBasicProps {
@@ -69,7 +70,8 @@ export interface SwitchProps extends ComponentBasicProps {
69
70
  ) => ReactNode)
70
71
  }
71
72
 
72
- /** Render state props passed to custom Switch content.
73
+ /**
74
+ * Render state props passed to custom Switch content.
73
75
  * @zh Switch 自定义渲染的状态属性
74
76
  */
75
77
  export interface SwitchRenderProps {
@@ -101,7 +103,7 @@ export interface SwitchRenderProps {
101
103
  /**
102
104
  * UI variants applied by Switch based on render state.
103
105
  * Use them as CSS selectors to style different states.
104
- * @zh Switch 根据状态注入的 ui-variants,可用于 CSS selector 按状态定制样式。
106
+ * @zh Switch 根据状态注入的 UI variants,可用于 CSS selector 按状态定制样式。
105
107
  */
106
108
  export interface SwitchUIVariants {
107
109
  /**
@@ -123,6 +125,18 @@ export interface SwitchUIVariants {
123
125
  'ui-disabled'?: boolean
124
126
  }
125
127
 
128
+ /**
129
+ * UI variants exposed by SwitchTrack.
130
+ * @zh SwitchTrack 暴露的 UI variants。
131
+ */
132
+ export interface SwitchTrackUIVariants extends SwitchUIVariants {}
133
+
134
+ /**
135
+ * UI variants exposed by SwitchThumb.
136
+ * @zh SwitchThumb 暴露的 UI variants。
137
+ */
138
+ export interface SwitchThumbUIVariants extends SwitchUIVariants {}
139
+
126
140
  /**
127
141
  * @deprecated Use `SwitchUIVariants` instead.
128
142
  */
@@ -7,7 +7,8 @@ import { useState } from '@lynx-js/react'
7
7
  import { useTouchEmulation } from '@lynx-js/react-use'
8
8
  import type { TouchEvent } from '@lynx-js/types'
9
9
 
10
- import { useEffectEvent } from './use-effect-event'
10
+ // This local helper is a stable callback, not React's restricted Effect Event.
11
+ import { useEffectEvent as useStableCallback } from './use-effect-event'
11
12
 
12
13
  interface UsePressTapReturnValue extends ReturnType<typeof useTouchEmulation> {
13
14
  pressed: boolean
@@ -30,16 +31,16 @@ export function usePressTap(
30
31
  ): UsePressTapReturnValue {
31
32
  const [pressed, setPressed] = useState(false)
32
33
 
33
- const press = useEffectEvent(() => {
34
+ const press = useStableCallback(() => {
34
35
  if (disabled) return
35
36
  setPressed(true)
36
37
  })
37
38
 
38
- const reset = useEffectEvent(() => {
39
+ const reset = useStableCallback(() => {
39
40
  setPressed(false)
40
41
  })
41
42
 
42
- const handleTap = useEffectEvent(() => {
43
+ const handleTap = useStableCallback(() => {
43
44
  if (disabled) return
44
45
  onTap?.()
45
46
  })