@lynx-js/lynx-ui-button 3.133.0 → 3.135.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.
- package/CHANGELOG.md +19 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.jsx +7 -1
- package/dist/Button.jsx.map +1 -1
- package/package.json +3 -2
- package/src/Button.tsx +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-button
|
|
2
2
|
|
|
3
|
+
## 3.135.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update `@lynx-js/react-use` to 0.2.2. ([#228](https://github.com/lynx-family/lynx-ui/pull/228))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`44c1de6`](https://github.com/lynx-family/lynx-ui/commit/44c1de68cf47e03c5136431a9efea7cbee69e752)]:
|
|
10
|
+
- @lynx-js/lynx-ui-common@3.135.3
|
|
11
|
+
|
|
12
|
+
## 3.133.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Improve Web and desktop touch compatibility by routing `onTouchStart`, ([#200](https://github.com/lynx-family/lynx-ui/pull/200))
|
|
17
|
+
`onTouchMove`, `onTouchEnd`, and `onTouchCancel` through shared touch
|
|
18
|
+
emulation.
|
|
19
|
+
- Updated dependencies [[`3932070`](https://github.com/lynx-family/lynx-ui/commit/393207073522e221a79e65c643df2afb329ec931)]:
|
|
20
|
+
- @lynx-js/lynx-ui-common@3.133.1
|
|
21
|
+
|
|
3
22
|
## 3.133.0
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/Button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,aAAa;YAChB,OAAO;cACL,OAAO;EAIjB,CAAA;AAEF,eAAO,MAAM,gBAAgB;YAPnB,OAAO;cACL,OAAO;CAM4C,CAAA;AAE/D,eAAO,MAAM,MAAM,GAAI,MAAM,WAAW,gCA6DvC,CAAA"}
|
package/dist/Button.jsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo, useState } from "@lynx-js/react";
|
|
2
2
|
import { useMemoizedFn } from "@lynx-js/lynx-ui-common";
|
|
3
|
+
import { useTouchEmulation } from "@lynx-js/react-use";
|
|
3
4
|
import { clsx } from "clsx";
|
|
4
5
|
const ButtonContext = createContext({
|
|
5
6
|
active: false,
|
|
@@ -26,6 +27,11 @@ const Button = (prop)=>{
|
|
|
26
27
|
if (disabled) return;
|
|
27
28
|
onClick?.();
|
|
28
29
|
});
|
|
30
|
+
const touchHandlers = useTouchEmulation({
|
|
31
|
+
onTouchStart: handleTouchStart,
|
|
32
|
+
onTouchEnd: handleTouchEnd,
|
|
33
|
+
onTouchCancel: handleTouchEnd
|
|
34
|
+
});
|
|
29
35
|
const contextValue = useMemo(()=>({
|
|
30
36
|
active: isEffectiveActive,
|
|
31
37
|
disabled
|
|
@@ -34,7 +40,7 @@ const Button = (prop)=>{
|
|
|
34
40
|
disabled
|
|
35
41
|
]);
|
|
36
42
|
return <ButtonContext.Provider value={contextValue}>
|
|
37
|
-
<view bindtap={handleTap}
|
|
43
|
+
<view bindtap={handleTap} {...touchHandlers} event-through={false} style={style} className={clsx(className, {
|
|
38
44
|
'ui-active': isEffectiveActive,
|
|
39
45
|
'ui-disabled': disabled
|
|
40
46
|
})} {...buttonProps}>
|
package/dist/Button.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.jsx","sources":["webpack://@lynx-js/lynx-ui-button/./src/Button.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 { createContext, useContext, useMemo, useState } from '@lynx-js/react'\n\nimport { useMemoizedFn } from '@lynx-js/lynx-ui-common'\nimport { clsx } from 'clsx'\n\nimport type { ButtonProps } from './types'\n\nexport const ButtonContext = createContext<{\n active: boolean\n disabled: boolean\n}>({\n active: false,\n disabled: false,\n})\n\nexport const useButtonContext = () => useContext(ButtonContext)\n\nexport const Button = (prop: ButtonProps) => {\n const {\n children,\n onClick,\n disabled = false,\n style,\n className,\n buttonProps,\n } = prop\n const [active, setActive] = useState(false)\n\n // Only when the button is active and not disabled, the active style will be applied\n const isEffectiveActive = active && !disabled\n\n const renderedChildren = typeof children === 'function'\n ? children({ active: isEffectiveActive, disabled })\n : children\n\n const handleTouchStart = useMemoizedFn(() => {\n if (disabled) return\n setActive(true)\n })\n\n const handleTouchEnd = useMemoizedFn(() => {\n setActive(false)\n if (disabled) return\n })\n\n const handleTap = useMemoizedFn(() => {\n if (disabled) return\n onClick?.()\n })\n\n const contextValue = useMemo(\n () => ({ active: isEffectiveActive, disabled }),\n [isEffectiveActive, disabled],\n )\n\n return (\n <ButtonContext.Provider value={contextValue}>\n <view\n bindtap={handleTap}\n
|
|
1
|
+
{"version":3,"file":"Button.jsx","sources":["webpack://@lynx-js/lynx-ui-button/./src/Button.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 { createContext, useContext, useMemo, useState } from '@lynx-js/react'\n\nimport { useMemoizedFn } from '@lynx-js/lynx-ui-common'\nimport { useTouchEmulation } from '@lynx-js/react-use'\nimport { clsx } from 'clsx'\n\nimport type { ButtonProps } from './types'\n\nexport const ButtonContext = createContext<{\n active: boolean\n disabled: boolean\n}>({\n active: false,\n disabled: false,\n})\n\nexport const useButtonContext = () => useContext(ButtonContext)\n\nexport const Button = (prop: ButtonProps) => {\n const {\n children,\n onClick,\n disabled = false,\n style,\n className,\n buttonProps,\n } = prop\n const [active, setActive] = useState(false)\n\n // Only when the button is active and not disabled, the active style will be applied\n const isEffectiveActive = active && !disabled\n\n const renderedChildren = typeof children === 'function'\n ? children({ active: isEffectiveActive, disabled })\n : children\n\n const handleTouchStart = useMemoizedFn(() => {\n if (disabled) return\n setActive(true)\n })\n\n const handleTouchEnd = useMemoizedFn(() => {\n setActive(false)\n if (disabled) return\n })\n\n const handleTap = useMemoizedFn(() => {\n if (disabled) return\n onClick?.()\n })\n\n const touchHandlers = useTouchEmulation({\n onTouchStart: handleTouchStart,\n onTouchEnd: handleTouchEnd,\n onTouchCancel: handleTouchEnd,\n })\n\n const contextValue = useMemo(\n () => ({ active: isEffectiveActive, disabled }),\n [isEffectiveActive, disabled],\n )\n\n return (\n <ButtonContext.Provider value={contextValue}>\n <view\n bindtap={handleTap}\n {...touchHandlers}\n event-through={false}\n style={style}\n className={clsx(className, {\n 'ui-active': isEffectiveActive,\n 'ui-disabled': disabled,\n })}\n {...buttonProps}\n >\n {renderedChildren}\n </view>\n </ButtonContext.Provider>\n )\n}\n"],"names":["ButtonContext","createContext","useButtonContext","useContext","Button","prop","children","onClick","disabled","style","className","buttonProps","active","setActive","useState","isEffectiveActive","renderedChildren","handleTouchStart","useMemoizedFn","handleTouchEnd","handleTap","touchHandlers","useTouchEmulation","contextValue","useMemo","view","clsx"],"mappings":";;;;AAYO,MAAMA,gBAAgBC,cAG1B;IACD,QAAQ;IACR,UAAU;AACZ;AAEO,MAAMC,mBAAmB,IAAMC,WAAWH;AAE1C,MAAMI,SAAS,CAACC;IACrB,MAAM,EACJC,QAAQ,EACRC,OAAO,EACPC,WAAW,KAAK,EAChBC,KAAK,EACLC,SAAS,EACTC,WAAW,EACZ,GAAGN;IACJ,MAAM,CAACO,QAAQC,UAAU,GAAGC,SAAS;IAGrC,MAAMC,oBAAoBH,UAAU,CAACJ;IAErC,MAAMQ,mBAAmB,AAAoB,cAApB,OAAOV,WAC5BA,SAAS;QAAE,QAAQS;QAAmBP;IAAS,KAC/CF;IAEJ,MAAMW,mBAAmBC,cAAc;QACrC,IAAIV,UAAU;QACdK,UAAU;IACZ;IAEA,MAAMM,iBAAiBD,cAAc;QACnCL,UAAU;QACV,IAAIL,UAAU;IAChB;IAEA,MAAMY,YAAYF,cAAc;QAC9B,IAAIV,UAAU;QACdD;IACF;IAEA,MAAMc,gBAAgBC,kBAAkB;QACtC,cAAcL;QACd,YAAYE;QACZ,eAAeA;IACjB;IAEA,MAAMI,eAAeC,QACnB,IAAO;YAAE,QAAQT;YAAmBP;QAAS,IAC7C;QAACO;QAAmBP;KAAS;IAG/B,QACGR,cAAc,SAAS,OAAOuB,cAAc;MAC3C,CAACE,KACC,SAASL,YACR,GAAGC,aAAa,EACjB,eAAe,OACf,OAAOZ,OACP,WAAWiB,KAAKhB,WAAW;QACzB,aAAaK;QACb,eAAeP;IACjB,KACC,GAAGG,WAAW,EAChB;QACC,CAACK,iBAAiB;MACpB,EAAES,KAAK;IACT,EAAEzB,cAAc;AAEpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-button",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.135.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"dist/**"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@lynx-js/react-use": "0.2.2",
|
|
28
29
|
"clsx": "^2.1.1",
|
|
29
|
-
"@lynx-js/lynx-ui-common": "3.
|
|
30
|
+
"@lynx-js/lynx-ui-common": "3.135.3"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@lynx-js/react": "0.114.0",
|
package/src/Button.tsx
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { createContext, useContext, useMemo, useState } from '@lynx-js/react'
|
|
6
6
|
|
|
7
7
|
import { useMemoizedFn } from '@lynx-js/lynx-ui-common'
|
|
8
|
+
import { useTouchEmulation } from '@lynx-js/react-use'
|
|
8
9
|
import { clsx } from 'clsx'
|
|
9
10
|
|
|
10
11
|
import type { ButtonProps } from './types'
|
|
@@ -52,6 +53,12 @@ export const Button = (prop: ButtonProps) => {
|
|
|
52
53
|
onClick?.()
|
|
53
54
|
})
|
|
54
55
|
|
|
56
|
+
const touchHandlers = useTouchEmulation({
|
|
57
|
+
onTouchStart: handleTouchStart,
|
|
58
|
+
onTouchEnd: handleTouchEnd,
|
|
59
|
+
onTouchCancel: handleTouchEnd,
|
|
60
|
+
})
|
|
61
|
+
|
|
55
62
|
const contextValue = useMemo(
|
|
56
63
|
() => ({ active: isEffectiveActive, disabled }),
|
|
57
64
|
[isEffectiveActive, disabled],
|
|
@@ -61,9 +68,7 @@ export const Button = (prop: ButtonProps) => {
|
|
|
61
68
|
<ButtonContext.Provider value={contextValue}>
|
|
62
69
|
<view
|
|
63
70
|
bindtap={handleTap}
|
|
64
|
-
|
|
65
|
-
bindtouchend={handleTouchEnd}
|
|
66
|
-
bindtouchcancel={handleTouchEnd}
|
|
71
|
+
{...touchHandlers}
|
|
67
72
|
event-through={false}
|
|
68
73
|
style={style}
|
|
69
74
|
className={clsx(className, {
|