@ledvance/base 1.2.82 → 1.2.83

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 (165) hide show
  1. package/.babelrc +31 -31
  2. package/.eslintignore +5 -5
  3. package/.eslintrc.js +27 -27
  4. package/.prettierrc.js +1 -1
  5. package/.versionrc +5 -5
  6. package/localazy.json +848 -848
  7. package/localazy.keys.json +4 -4
  8. package/package.json +74 -74
  9. package/rn-cli.config.js +8 -8
  10. package/src/api/native.d.ts +71 -71
  11. package/src/api/native.ts +423 -423
  12. package/src/api/nativeEventEmitter.d.ts +3 -3
  13. package/src/api/nativeEventEmitter.ts +125 -125
  14. package/src/components/AdvanceCard.d.ts +25 -25
  15. package/src/components/AdvanceCard.tsx +117 -117
  16. package/src/components/AdvanceList.d.ts +9 -9
  17. package/src/components/AdvanceList.tsx +69 -69
  18. package/src/components/ApplyForDeviceItem.d.ts +6 -6
  19. package/src/components/ApplyForDeviceItem.tsx +83 -83
  20. package/src/components/ApplyForDeviceList.d.ts +7 -7
  21. package/src/components/ApplyForDeviceList.tsx +61 -61
  22. package/src/components/ApplyForText.d.ts +6 -6
  23. package/src/components/ApplyForText.tsx +52 -52
  24. package/src/components/Card.d.ts +10 -10
  25. package/src/components/Card.tsx +40 -40
  26. package/src/components/Cell.d.ts +21 -21
  27. package/src/components/Cell.tsx +69 -69
  28. package/src/components/CircularProgress.d.ts +8 -8
  29. package/src/components/CircularProgress.tsx +42 -42
  30. package/src/components/ColorAdjustView.d.ts +12 -12
  31. package/src/components/ColorAdjustView.tsx +64 -64
  32. package/src/components/ColorExtractor.d.ts +73 -73
  33. package/src/components/ColorExtractor.tsx +374 -374
  34. package/src/components/ColorTempAdjustView.d.ts +13 -13
  35. package/src/components/ColorTempAdjustView.tsx +57 -57
  36. package/src/components/ColorsLine.d.ts +7 -7
  37. package/src/components/ColorsLine.tsx +47 -47
  38. package/src/components/CustomListDialog.d.ts +15 -15
  39. package/src/components/CustomListDialog.tsx +66 -65
  40. package/src/components/DeleteButton.d.ts +10 -10
  41. package/src/components/DeleteButton.tsx +40 -40
  42. package/src/components/Dialog.d.ts +10 -10
  43. package/src/components/Dialog.tsx +38 -38
  44. package/src/components/DrawToolView.d.ts +46 -46
  45. package/src/components/DrawToolView.tsx +262 -262
  46. package/src/components/FanAdjustView.d.ts +23 -23
  47. package/src/components/FanAdjustView.tsx +141 -141
  48. package/src/components/InfoText.d.ts +11 -11
  49. package/src/components/InfoText.tsx +45 -45
  50. package/src/components/LampAdjustView.d.ts +10 -10
  51. package/src/components/LampAdjustView.tsx +75 -75
  52. package/src/components/LampAdjustView2.d.ts +24 -24
  53. package/src/components/LampAdjustView2.tsx +104 -104
  54. package/src/components/LinearGradientLine.d.ts +9 -9
  55. package/src/components/LinearGradientLine.tsx +63 -63
  56. package/src/components/LoadingView.tsx +39 -39
  57. package/src/components/MoodColorsLine.d.ts +9 -9
  58. package/src/components/MoodColorsLine.tsx +38 -38
  59. package/src/components/Page.d.ts +21 -21
  60. package/src/components/Page.tsx +104 -104
  61. package/src/components/Popup.d.ts +7 -7
  62. package/src/components/Popup.tsx +71 -71
  63. package/src/components/Segmented.d.ts +14 -14
  64. package/src/components/Segmented.tsx +76 -76
  65. package/src/components/ShowSelect.d.ts +1 -1
  66. package/src/components/ShowSelect.tsx +158 -158
  67. package/src/components/SocketItem.d.ts +13 -13
  68. package/src/components/SocketItem.tsx +87 -87
  69. package/src/components/Spacer.d.ts +7 -7
  70. package/src/components/Spacer.tsx +13 -13
  71. package/src/components/Stepper.d.ts +19 -19
  72. package/src/components/Stepper.tsx +130 -130
  73. package/src/components/StripAdjustView.d.ts +16 -16
  74. package/src/components/StripAdjustView.tsx +129 -129
  75. package/src/components/StripLightView.d.ts +14 -14
  76. package/src/components/StripLightView.tsx +24 -24
  77. package/src/components/Summary.tsx +116 -116
  78. package/src/components/Tag.d.ts +8 -8
  79. package/src/components/Tag.tsx +56 -56
  80. package/src/components/TextButton.d.ts +9 -9
  81. package/src/components/TextButton.tsx +31 -31
  82. package/src/components/TextField.d.ts +9 -9
  83. package/src/components/TextField.tsx +92 -92
  84. package/src/components/TextFieldStyleButton.d.ts +8 -8
  85. package/src/components/TextFieldStyleButton.tsx +85 -85
  86. package/src/components/UATabTitle.d.ts +6 -6
  87. package/src/components/UATabTitle.tsx +31 -31
  88. package/src/components/UATabs.d.ts +12 -12
  89. package/src/components/UATabs.tsx +77 -77
  90. package/src/components/connect.d.ts +10 -10
  91. package/src/components/connect.tsx +20 -20
  92. package/src/components/ldvColorBrightness.d.ts +1 -1
  93. package/src/components/ldvColorBrightness.tsx +18 -18
  94. package/src/components/ldvColorSlider.d.ts +14 -14
  95. package/src/components/ldvColorSlider.tsx +131 -131
  96. package/src/components/ldvItemView.d.ts +12 -12
  97. package/src/components/ldvItemView.tsx +43 -43
  98. package/src/components/ldvPickerView.d.ts +13 -13
  99. package/src/components/ldvPickerView.tsx +97 -97
  100. package/src/components/ldvPresetView.d.ts +2 -2
  101. package/src/components/ldvPresetView.tsx +86 -86
  102. package/src/components/ldvSaturation.d.ts +2 -2
  103. package/src/components/ldvSaturation.tsx +22 -22
  104. package/src/components/ldvSlider.d.ts +15 -15
  105. package/src/components/ldvSlider.tsx +103 -103
  106. package/src/components/ldvSwitch.d.ts +10 -10
  107. package/src/components/ldvSwitch.tsx +52 -52
  108. package/src/components/ldvTemperatureSlider.d.ts +13 -13
  109. package/src/components/ldvTemperatureSlider.tsx +139 -139
  110. package/src/components/ldvTopBar.d.ts +10 -10
  111. package/src/components/ldvTopBar.tsx +76 -76
  112. package/src/components/ldvTopName.d.ts +9 -9
  113. package/src/components/ldvTopName.tsx +63 -63
  114. package/src/components/segmentControl.d.ts +1 -1
  115. package/src/components/segmentControl.tsx +65 -65
  116. package/src/components/weekSelect.d.ts +7 -7
  117. package/src/components/weekSelect.tsx +98 -98
  118. package/src/composeLayout.d.ts +30 -30
  119. package/src/composeLayout.tsx +261 -261
  120. package/src/config/dark-theme.ts +61 -61
  121. package/src/config/light-theme.ts +61 -61
  122. package/src/hooks/Hooks.d.ts +2 -2
  123. package/src/hooks/Hooks.ts +8 -8
  124. package/src/i18n/index.d.ts +16 -16
  125. package/src/i18n/index.ts +37 -37
  126. package/src/i18n/strings.d.ts +15953 -15953
  127. package/src/i18n/strings.ts +23723 -23723
  128. package/src/main.tsx +9 -9
  129. package/src/models/GlobalParams.d.ts +14 -14
  130. package/src/models/GlobalParams.ts +14 -14
  131. package/src/models/TuyaApi.d.ts +29 -29
  132. package/src/models/TuyaApi.ts +92 -92
  133. package/src/models/combine.d.ts +26 -26
  134. package/src/models/combine.ts +17 -17
  135. package/src/models/configureStore.d.ts +9 -9
  136. package/src/models/configureStore.ts +33 -33
  137. package/src/models/index.d.ts +31 -31
  138. package/src/models/index.ts +22 -22
  139. package/src/models/modules/NativePropsSlice.d.ts +61 -61
  140. package/src/models/modules/NativePropsSlice.tsx +467 -467
  141. package/src/models/modules/Result.d.ts +14 -14
  142. package/src/models/modules/Result.ts +15 -15
  143. package/src/models/modules/common.d.ts +44 -44
  144. package/src/models/modules/common.ts +161 -161
  145. package/src/res/index.d.ts +70 -70
  146. package/src/res/index.ts +73 -73
  147. package/src/utils/ColorParser.d.ts +66 -66
  148. package/src/utils/ColorParser.ts +189 -189
  149. package/src/utils/ColorUtils.d.ts +71 -71
  150. package/src/utils/ColorUtils.tsx +448 -448
  151. package/src/utils/Support.d.ts +13 -13
  152. package/src/utils/Support.ts +108 -108
  153. package/src/utils/TypeUtils.d.ts +3 -3
  154. package/src/utils/cctUtils.d.ts +1 -1
  155. package/src/utils/cctUtils.ts +110 -110
  156. package/src/utils/common.d.ts +35 -35
  157. package/src/utils/common.ts +379 -379
  158. package/src/utils/index.d.ts +26 -26
  159. package/src/utils/index.ts +191 -191
  160. package/src/utils/interface.d.ts +6 -6
  161. package/src/utils/interface.ts +50 -11
  162. package/src/utils/loopsCompare.d.ts +1 -1
  163. package/src/utils/loopsCompare.ts +62 -62
  164. package/tsconfig.json +50 -50
  165. package/update-localazy.py +52 -52
@@ -1,26 +1,26 @@
1
- export declare const getFaultStrings: (faultCode: string, faultValue: number, onlyPrior?: boolean) => string;
2
- export declare const hsv2Rgb: (h: any, s: any, v: any) => {
3
- r: number;
4
- g: number;
5
- b: number;
6
- };
7
- export declare const hex2Hsv: (hex: any) => {
8
- h: number;
9
- s: number;
10
- v: number;
11
- } | null;
12
- export declare const rgb2Hsv: (r: any, g: any, b: any) => {
13
- h: number;
14
- s: number;
15
- v: number;
16
- };
17
- export declare const rgb2Hex: (r: any, g: any, b: any) => string;
18
- export declare const hsv2Hex: (h: any, s: any, v: any) => string;
19
- export declare const getHexByHSV: (hsv: any) => any;
20
- export declare const getHSVByHex: (string: any) => {
21
- h: number;
22
- s: number;
23
- v: number;
24
- };
25
- export declare function mapFloatToRange(value: number, min: number, max: number): number;
26
- export declare function mapValueToRatio(value: number, min: number, max: number): number;
1
+ export declare const getFaultStrings: (faultCode: string, faultValue: number, onlyPrior?: boolean) => string;
2
+ export declare const hsv2Rgb: (h: any, s: any, v: any) => {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ };
7
+ export declare const hex2Hsv: (hex: any) => {
8
+ h: number;
9
+ s: number;
10
+ v: number;
11
+ } | null;
12
+ export declare const rgb2Hsv: (r: any, g: any, b: any) => {
13
+ h: number;
14
+ s: number;
15
+ v: number;
16
+ };
17
+ export declare const rgb2Hex: (r: any, g: any, b: any) => string;
18
+ export declare const hsv2Hex: (h: any, s: any, v: any) => string;
19
+ export declare const getHexByHSV: (hsv: any) => any;
20
+ export declare const getHSVByHex: (string: any) => {
21
+ h: number;
22
+ s: number;
23
+ v: number;
24
+ };
25
+ export declare function mapFloatToRange(value: number, min: number, max: number): number;
26
+ export declare function mapValueToRatio(value: number, min: number, max: number): number;
@@ -1,191 +1,191 @@
1
- /* eslint-disable import/prefer-default-export */
2
- import {Utils} from 'tuya-panel-kit'
3
- import {store} from '../models'
4
- import I18n from '../i18n/index'
5
- import dayjs from "dayjs";
6
-
7
- export const getFaultStrings = (faultCode: string, faultValue: number, onlyPrior = true) => {
8
- const {devInfo} = store.getState()
9
- if (!faultValue) return ''
10
- const {label} = devInfo.schema[faultCode]
11
- const labels: string[] = []
12
- for (let i = 0; i < label!.length; i++) {
13
- const value = label![i]
14
- const isExist = Utils.NumberUtils.getBitValue(faultValue, i)
15
- if (isExist) {
16
- labels.push(I18n.getDpLang(faultCode, value))
17
- if (onlyPrior) break
18
- }
19
- }
20
- return onlyPrior ? labels[0] : labels.join(', ')
21
- }
22
-
23
- const RGB_MAX = 255
24
- const HUE_MAX = 360
25
- const SV_MAX = 100
26
-
27
- export const hsv2Rgb = (h, s, v) => {
28
- if (typeof h === 'object') {
29
- const args = h
30
- h = args.h
31
- s = args.s
32
- v = args.v
33
- }
34
-
35
- h = _normalizeAngle(h)
36
- h = (h === HUE_MAX) ? 1 : (h % HUE_MAX / parseFloat(HUE_MAX.toString()) * 6)
37
- s = (s === SV_MAX) ? 1 : (s % SV_MAX / parseFloat(SV_MAX.toString()))
38
- v = (v === SV_MAX) ? 1 : (v % SV_MAX / parseFloat(SV_MAX.toString()))
39
-
40
- var i = Math.floor(h)
41
- var f = h - i
42
- var p = v * (1 - s)
43
- var q = v * (1 - f * s)
44
- var t = v * (1 - (1 - f) * s)
45
- var mod = i % 6
46
- var r = [v, q, p, p, t, v][mod]
47
- var g = [t, v, v, q, p, p][mod]
48
- var b = [p, p, t, v, v, q][mod]
49
-
50
- return {
51
- r: Math.floor(r * RGB_MAX),
52
- g: Math.floor(g * RGB_MAX),
53
- b: Math.floor(b * RGB_MAX),
54
- }
55
- }
56
-
57
- function _normalizeAngle(degrees) {
58
- return (degrees % 360 + 360) % 360
59
- }
60
-
61
- export const hex2Hsv = function (hex) {
62
- var rgb = hex2Rgb(hex)
63
- if (rgb) {
64
- return rgb2Hsv(rgb.r, rgb.g, rgb.b)
65
- } else {
66
- return null
67
- }
68
-
69
- }
70
-
71
- const hex2Rgb = function (hex) {
72
- var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
73
- return result ? {
74
- r: parseInt(result[1], 16),
75
- g: parseInt(result[2], 16),
76
- b: parseInt(result[3], 16),
77
- } : null
78
- }
79
-
80
- export const rgb2Hsv = function (r, g, b) {
81
- if (typeof r === 'object') {
82
- const args = r
83
- r = args.r
84
- g = args.g
85
- b = args.b
86
- }
87
-
88
- // It converts [0,255] format, to [0,1]
89
- r = (r === RGB_MAX) ? 1 : (r % RGB_MAX / parseFloat(RGB_MAX.toString()))
90
- g = (g === RGB_MAX) ? 1 : (g % RGB_MAX / parseFloat(RGB_MAX.toString()))
91
- b = (b === RGB_MAX) ? 1 : (b % RGB_MAX / parseFloat(RGB_MAX.toString()))
92
-
93
- var max = Math.max(r, g, b)
94
- var min = Math.min(r, g, b)
95
- var h, s, v = max
96
-
97
- var d = max - min
98
-
99
- s = max === 0 ? 0 : d / max
100
-
101
- if (max === min) {
102
- h = 0 // achromatic
103
- } else {
104
- switch (max) {
105
- case r:
106
- h = (g - b) / d + (g < b ? 6 : 0)
107
- break
108
- case g:
109
- h = (b - r) / d + 2
110
- break
111
- case b:
112
- h = (r - g) / d + 4
113
- break
114
- }
115
- h /= 6
116
- }
117
-
118
- return {
119
- h: Math.round(h * HUE_MAX),
120
- s: Math.round(s * SV_MAX),
121
- v: Math.round(v * SV_MAX),
122
- }
123
- }
124
-
125
- export const rgb2Hex = function (r, g, b) {
126
- if (typeof r === 'object') {
127
- const args = r
128
- r = args.r
129
- g = args.g
130
- b = args.b
131
- }
132
- r = Math.round(r).toString(16)
133
- g = Math.round(g).toString(16)
134
- b = Math.round(b).toString(16)
135
-
136
- r = r.length === 1 ? '0' + r : r
137
- g = g.length === 1 ? '0' + g : g
138
- b = b.length === 1 ? '0' + b : b
139
-
140
- return '#' + r + g + b
141
- }
142
-
143
- export const hsv2Hex = function (h, s, v) {
144
- let rgb = hsv2Rgb(h, s, v)
145
- return rgb2Hex(rgb.r, rgb.g, rgb.b)
146
- }
147
-
148
- export const getHexByHSV = (hsv) => {
149
- const hueHex = hsv.h.toString(16).padStart(4, '0')
150
- const satHex = (hsv.s).toString(16).padStart(4, '0')
151
- const colorBrightnessHex = (hsv.v).toString(16).padStart(4, '0')
152
- const allHex = hueHex + satHex + colorBrightnessHex
153
- return allHex
154
- }
155
-
156
- export const getHSVByHex = (string) => {
157
- const h = string.substring(0, 4)
158
- const s = string.substring(4, 8)
159
- const v = string.substring(8, 12)
160
- return {
161
- h: parseInt(h, 16),
162
- s: parseInt(s, 16),
163
- v: parseInt(v, 16),
164
- }
165
- }
166
-
167
- export function mapFloatToRange(value: number, min: number, max: number): number {
168
- // 确保 value 在 [0, 1] 范围内
169
- value = Math.max(0, Math.min(1, value))
170
-
171
- // 计算插值后的值
172
- return min + value * (max - min)
173
- }
174
-
175
- export function mapValueToRatio(value: number, min: number, max: number): number {
176
- return ((value || 0) - min) / (max - min)
177
- }
178
-
179
- export function abbreviateMonths(str: string) {
180
- const monthAbbreviations = {
181
- January: 'Jan', February: 'Feb', March: 'Mar', April: 'Apr',
182
- May: 'May', June: 'Jun', July: 'Jul', August: 'Aug',
183
- September: 'Sep', October: 'Oct', November: 'Nov', December: 'Dec'
184
- };
185
-
186
- return str.replace(/(?:January|February|March|April|May|June|July|August|September|October|November|December)/g, match => monthAbbreviations[match]);
187
- }
188
-
189
- export function overDays(date: string, days: number): boolean {
190
- return dayjs().diff(dayjs(date), 'days') >= days
191
- }
1
+ /* eslint-disable import/prefer-default-export */
2
+ import {Utils} from 'tuya-panel-kit'
3
+ import {store} from '../models'
4
+ import I18n from '../i18n/index'
5
+ import dayjs from "dayjs";
6
+
7
+ export const getFaultStrings = (faultCode: string, faultValue: number, onlyPrior = true) => {
8
+ const {devInfo} = store.getState()
9
+ if (!faultValue) return ''
10
+ const {label} = devInfo.schema[faultCode]
11
+ const labels: string[] = []
12
+ for (let i = 0; i < label!.length; i++) {
13
+ const value = label![i]
14
+ const isExist = Utils.NumberUtils.getBitValue(faultValue, i)
15
+ if (isExist) {
16
+ labels.push(I18n.getDpLang(faultCode, value))
17
+ if (onlyPrior) break
18
+ }
19
+ }
20
+ return onlyPrior ? labels[0] : labels.join(', ')
21
+ }
22
+
23
+ const RGB_MAX = 255
24
+ const HUE_MAX = 360
25
+ const SV_MAX = 100
26
+
27
+ export const hsv2Rgb = (h, s, v) => {
28
+ if (typeof h === 'object') {
29
+ const args = h
30
+ h = args.h
31
+ s = args.s
32
+ v = args.v
33
+ }
34
+
35
+ h = _normalizeAngle(h)
36
+ h = (h === HUE_MAX) ? 1 : (h % HUE_MAX / parseFloat(HUE_MAX.toString()) * 6)
37
+ s = (s === SV_MAX) ? 1 : (s % SV_MAX / parseFloat(SV_MAX.toString()))
38
+ v = (v === SV_MAX) ? 1 : (v % SV_MAX / parseFloat(SV_MAX.toString()))
39
+
40
+ var i = Math.floor(h)
41
+ var f = h - i
42
+ var p = v * (1 - s)
43
+ var q = v * (1 - f * s)
44
+ var t = v * (1 - (1 - f) * s)
45
+ var mod = i % 6
46
+ var r = [v, q, p, p, t, v][mod]
47
+ var g = [t, v, v, q, p, p][mod]
48
+ var b = [p, p, t, v, v, q][mod]
49
+
50
+ return {
51
+ r: Math.floor(r * RGB_MAX),
52
+ g: Math.floor(g * RGB_MAX),
53
+ b: Math.floor(b * RGB_MAX),
54
+ }
55
+ }
56
+
57
+ function _normalizeAngle(degrees) {
58
+ return (degrees % 360 + 360) % 360
59
+ }
60
+
61
+ export const hex2Hsv = function (hex) {
62
+ var rgb = hex2Rgb(hex)
63
+ if (rgb) {
64
+ return rgb2Hsv(rgb.r, rgb.g, rgb.b)
65
+ } else {
66
+ return null
67
+ }
68
+
69
+ }
70
+
71
+ const hex2Rgb = function (hex) {
72
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
73
+ return result ? {
74
+ r: parseInt(result[1], 16),
75
+ g: parseInt(result[2], 16),
76
+ b: parseInt(result[3], 16),
77
+ } : null
78
+ }
79
+
80
+ export const rgb2Hsv = function (r, g, b) {
81
+ if (typeof r === 'object') {
82
+ const args = r
83
+ r = args.r
84
+ g = args.g
85
+ b = args.b
86
+ }
87
+
88
+ // It converts [0,255] format, to [0,1]
89
+ r = (r === RGB_MAX) ? 1 : (r % RGB_MAX / parseFloat(RGB_MAX.toString()))
90
+ g = (g === RGB_MAX) ? 1 : (g % RGB_MAX / parseFloat(RGB_MAX.toString()))
91
+ b = (b === RGB_MAX) ? 1 : (b % RGB_MAX / parseFloat(RGB_MAX.toString()))
92
+
93
+ var max = Math.max(r, g, b)
94
+ var min = Math.min(r, g, b)
95
+ var h, s, v = max
96
+
97
+ var d = max - min
98
+
99
+ s = max === 0 ? 0 : d / max
100
+
101
+ if (max === min) {
102
+ h = 0 // achromatic
103
+ } else {
104
+ switch (max) {
105
+ case r:
106
+ h = (g - b) / d + (g < b ? 6 : 0)
107
+ break
108
+ case g:
109
+ h = (b - r) / d + 2
110
+ break
111
+ case b:
112
+ h = (r - g) / d + 4
113
+ break
114
+ }
115
+ h /= 6
116
+ }
117
+
118
+ return {
119
+ h: Math.round(h * HUE_MAX),
120
+ s: Math.round(s * SV_MAX),
121
+ v: Math.round(v * SV_MAX),
122
+ }
123
+ }
124
+
125
+ export const rgb2Hex = function (r, g, b) {
126
+ if (typeof r === 'object') {
127
+ const args = r
128
+ r = args.r
129
+ g = args.g
130
+ b = args.b
131
+ }
132
+ r = Math.round(r).toString(16)
133
+ g = Math.round(g).toString(16)
134
+ b = Math.round(b).toString(16)
135
+
136
+ r = r.length === 1 ? '0' + r : r
137
+ g = g.length === 1 ? '0' + g : g
138
+ b = b.length === 1 ? '0' + b : b
139
+
140
+ return '#' + r + g + b
141
+ }
142
+
143
+ export const hsv2Hex = function (h, s, v) {
144
+ let rgb = hsv2Rgb(h, s, v)
145
+ return rgb2Hex(rgb.r, rgb.g, rgb.b)
146
+ }
147
+
148
+ export const getHexByHSV = (hsv) => {
149
+ const hueHex = hsv.h.toString(16).padStart(4, '0')
150
+ const satHex = (hsv.s).toString(16).padStart(4, '0')
151
+ const colorBrightnessHex = (hsv.v).toString(16).padStart(4, '0')
152
+ const allHex = hueHex + satHex + colorBrightnessHex
153
+ return allHex
154
+ }
155
+
156
+ export const getHSVByHex = (string) => {
157
+ const h = string.substring(0, 4)
158
+ const s = string.substring(4, 8)
159
+ const v = string.substring(8, 12)
160
+ return {
161
+ h: parseInt(h, 16),
162
+ s: parseInt(s, 16),
163
+ v: parseInt(v, 16),
164
+ }
165
+ }
166
+
167
+ export function mapFloatToRange(value: number, min: number, max: number): number {
168
+ // 确保 value 在 [0, 1] 范围内
169
+ value = Math.max(0, Math.min(1, value))
170
+
171
+ // 计算插值后的值
172
+ return min + value * (max - min)
173
+ }
174
+
175
+ export function mapValueToRatio(value: number, min: number, max: number): number {
176
+ return ((value || 0) - min) / (max - min)
177
+ }
178
+
179
+ export function abbreviateMonths(str: string) {
180
+ const monthAbbreviations = {
181
+ January: 'Jan', February: 'Feb', March: 'Mar', April: 'Apr',
182
+ May: 'May', June: 'Jun', July: 'Jul', August: 'Aug',
183
+ September: 'Sep', October: 'Oct', November: 'Nov', December: 'Dec'
184
+ };
185
+
186
+ return str.replace(/(?:January|February|March|April|May|June|July|August|September|October|November|December)/g, match => monthAbbreviations[match]);
187
+ }
188
+
189
+ export function overDays(date: string, days: number): boolean {
190
+ return dayjs().diff(dayjs(date), 'days') >= days
191
+ }
@@ -1,6 +1,6 @@
1
- export declare enum WorkMode {
2
- White = "white",
3
- Colour = "colour",
4
- Scene = "scene",
5
- Music = "music"
6
- }
1
+ export declare enum WorkMode {
2
+ White = "white",
3
+ Colour = "colour",
4
+ Scene = "scene",
5
+ Music = "music"
6
+ }
@@ -1,11 +1,50 @@
1
- export enum WorkMode {
2
- White = 'white',
3
- Colour = 'colour',
4
- Scene = 'scene',
5
- Music = 'music',
6
- Control = 'control',
7
- Night = 'night',
8
- Disinfect = 'disinfect',
9
- Rhythm = 'rhythm',
10
- Plan = 'plan'
11
- }
1
+ export enum WorkMode {
2
+ White = 'white',
3
+ Colour = 'colour',
4
+ Scene = 'scene',
5
+ Music = 'music',
6
+ Control = 'control',
7
+ Night = 'night',
8
+ Disinfect = 'disinfect',
9
+ Rhythm = 'rhythm',
10
+ Plan = 'plan'
11
+ }
12
+
13
+ export type Category = 'light' | 'socket' | 'fan' | 'mainLight' | 'secondaryLight'
14
+
15
+ export interface ApplyForItem {
16
+ key: string;
17
+ dp: string;
18
+ type: Category;
19
+ enable: boolean;
20
+ }
21
+
22
+ export interface judgmentSupport {
23
+ isSupportColor: boolean;
24
+ isSupportBrightness: boolean;
25
+ isSupportTemperature: boolean;
26
+ isCeilingLight?: boolean;
27
+ isStripLight?: boolean;
28
+ isStringLight?: boolean;
29
+ isMixLight?: boolean;
30
+ }
31
+
32
+ export interface JudgeTimeScheduleProps {
33
+ isDIMLamp?: boolean
34
+ isGARDOT?: boolean
35
+ isGlassRGBWLamp?: boolean
36
+ isOnlyRGBLamp?: boolean
37
+ isRGBLamp?: boolean
38
+ isRGBWLamp?: boolean
39
+ isTWLamp?: boolean
40
+ isSupportColor?: boolean
41
+ isSupportBrightness?: boolean
42
+ isSupportTemperature?: boolean
43
+ isSupportMood?: boolean
44
+ isStringLight?: boolean
45
+ isStripLight?: boolean
46
+ isCeilingLight?: boolean
47
+ isFanLamp?: boolean
48
+ isSupportMode?: boolean
49
+ isMixRGBWLamp?: boolean
50
+ }
@@ -1 +1 @@
1
- export declare function findConflicts(schedule: any, object: any): any;
1
+ export declare function findConflicts(schedule: any, object: any): any;
@@ -1,62 +1,62 @@
1
- import dayjs from 'dayjs';
2
- export function findConflicts(schedule, object) {
3
- const conflicts: any = [];
4
- schedule.forEach(item => {
5
- item.weeks = getLoopsForTheOnceItem(item);
6
- });
7
- object.weeks = getLoopsForTheOnceItem(object);
8
- const objectStart = object.isSleep
9
- ? object.time[0] * 60 + object.time[1]
10
- : object.time[0] * 60 + object.time[1] - object.fade;
11
- const objectEnd = object.isSleep
12
- ? objectStart + object.fade
13
- : object.time[0] * 60 + object.time[1];
14
- for (let i = 0; i < schedule.length; i++) {
15
- const { enable, weeks, time, fade, isSleep } = schedule[i];
16
- if (enable === 0) continue;
17
-
18
- const start = isSleep ? time[0] * 60 + time[1] : time[0] * 60 + time[1] - fade;
19
- const end = isSleep ? start + fade : time[0] * 60 + time[1];
20
-
21
- let conflict = false;
22
- for (let j = 0; j < 7; j++) {
23
- if (weeks[j] && start < 0 && object.weeks[j - 1 < 0 ? 6 : j - 1]) {
24
- if (objectEnd - 24 * 60 > start) {
25
- conflict = true;
26
- break;
27
- }
28
- }
29
- if (object.weeks[j] && weeks[j]) {
30
- if (objectStart < end && objectEnd > start) {
31
- conflict = true;
32
- break;
33
- }
34
- }
35
- if (weeks[j] && end > 24 * 60 && object.weeks[j + 1 > 6 ? 0 : j + 1]) {
36
- if (end - 24 * 60 > objectStart) {
37
- conflict = true;
38
- break;
39
- }
40
- }
41
- }
42
-
43
- if (conflict) {
44
- conflicts.push(schedule[i]);
45
- }
46
- }
47
-
48
- return conflicts;
49
- }
50
- // once
51
- function isLoopsEqualToOnce(loops) {
52
- return loops.every(item => item === 0 || item === '0');
53
- }
54
-
55
- function getLoopsForTheOnceItem(item) {
56
- let newLoops = [...item.loops];
57
- if (isLoopsEqualToOnce(newLoops)) {
58
- const now = dayjs();
59
- newLoops[now.day()] = 1;
60
- }
61
- return newLoops;
62
- }
1
+ import dayjs from 'dayjs';
2
+ export function findConflicts(schedule, object) {
3
+ const conflicts: any = [];
4
+ schedule.forEach(item => {
5
+ item.weeks = getLoopsForTheOnceItem(item);
6
+ });
7
+ object.weeks = getLoopsForTheOnceItem(object);
8
+ const objectStart = object.isSleep
9
+ ? object.time[0] * 60 + object.time[1]
10
+ : object.time[0] * 60 + object.time[1] - object.fade;
11
+ const objectEnd = object.isSleep
12
+ ? objectStart + object.fade
13
+ : object.time[0] * 60 + object.time[1];
14
+ for (let i = 0; i < schedule.length; i++) {
15
+ const { enable, weeks, time, fade, isSleep } = schedule[i];
16
+ if (enable === 0) continue;
17
+
18
+ const start = isSleep ? time[0] * 60 + time[1] : time[0] * 60 + time[1] - fade;
19
+ const end = isSleep ? start + fade : time[0] * 60 + time[1];
20
+
21
+ let conflict = false;
22
+ for (let j = 0; j < 7; j++) {
23
+ if (weeks[j] && start < 0 && object.weeks[j - 1 < 0 ? 6 : j - 1]) {
24
+ if (objectEnd - 24 * 60 > start) {
25
+ conflict = true;
26
+ break;
27
+ }
28
+ }
29
+ if (object.weeks[j] && weeks[j]) {
30
+ if (objectStart < end && objectEnd > start) {
31
+ conflict = true;
32
+ break;
33
+ }
34
+ }
35
+ if (weeks[j] && end > 24 * 60 && object.weeks[j + 1 > 6 ? 0 : j + 1]) {
36
+ if (end - 24 * 60 > objectStart) {
37
+ conflict = true;
38
+ break;
39
+ }
40
+ }
41
+ }
42
+
43
+ if (conflict) {
44
+ conflicts.push(schedule[i]);
45
+ }
46
+ }
47
+
48
+ return conflicts;
49
+ }
50
+ // once
51
+ function isLoopsEqualToOnce(loops) {
52
+ return loops.every(item => item === 0 || item === '0');
53
+ }
54
+
55
+ function getLoopsForTheOnceItem(item) {
56
+ let newLoops = [...item.loops];
57
+ if (isLoopsEqualToOnce(newLoops)) {
58
+ const now = dayjs();
59
+ newLoops[now.day()] = 1;
60
+ }
61
+ return newLoops;
62
+ }