@sheinx/hooks 3.9.5 → 3.9.6-beta.1
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/cjs/utils/attribute.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export declare const getDataAttribute: (attrs: Record<string, string | undefined>) => Record<string, string>;
|
|
2
2
|
export declare const getDataAttributeName: (name: string) => string;
|
|
3
|
+
type ExtractType = 'mouse' | 'data-attr';
|
|
4
|
+
/**
|
|
5
|
+
* Extract specific types of props from the props object
|
|
6
|
+
* @param props - The props object to extract from
|
|
7
|
+
* @param type - The type of props to extract ('mouse' for mouse events, 'data-attr' for data-* attributes)
|
|
8
|
+
* @returns An object containing only the extracted props
|
|
9
|
+
*/
|
|
10
|
+
export declare const extractProps: (props: Record<string, any>, type: ExtractType) => Record<string, any>;
|
|
11
|
+
export {};
|
|
3
12
|
//# sourceMappingURL=attribute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["attribute.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,UAAW,OAAO,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,2BAQzE,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,MAAM,WAEhD,CAAC"}
|
|
1
|
+
{"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["attribute.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,UAAW,OAAO,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,2BAQzE,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,MAAM,WAEhD,CAAC;AAEF,KAAK,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,OAAO,MAAM,EAAE,GAAG,CAAC,QAAQ,WAAW,wBAqBzE,CAAC"}
|
package/cjs/utils/attribute.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getDataAttributeName = exports.getDataAttribute = void 0;
|
|
6
|
+
exports.getDataAttributeName = exports.getDataAttribute = exports.extractProps = void 0;
|
|
7
7
|
var getDataAttribute = exports.getDataAttribute = function getDataAttribute(attrs) {
|
|
8
8
|
return Object.keys(attrs).reduce(function (acc, key) {
|
|
9
9
|
var ns = "data-soui-".concat(key);
|
|
@@ -15,4 +15,30 @@ var getDataAttribute = exports.getDataAttribute = function getDataAttribute(attr
|
|
|
15
15
|
};
|
|
16
16
|
var getDataAttributeName = exports.getDataAttributeName = function getDataAttributeName(name) {
|
|
17
17
|
return "data-soui-".concat(name);
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Extract specific types of props from the props object
|
|
21
|
+
* @param props - The props object to extract from
|
|
22
|
+
* @param type - The type of props to extract ('mouse' for mouse events, 'data-attr' for data-* attributes)
|
|
23
|
+
* @returns An object containing only the extracted props
|
|
24
|
+
*/
|
|
25
|
+
var extractProps = exports.extractProps = function extractProps(props, type) {
|
|
26
|
+
var result = {};
|
|
27
|
+
if (type === 'mouse') {
|
|
28
|
+
// Only extract onMouseEnter and onMouseLeave for Tooltip support
|
|
29
|
+
if (props.onMouseEnter && typeof props.onMouseEnter === 'function') {
|
|
30
|
+
result.onMouseEnter = props.onMouseEnter;
|
|
31
|
+
}
|
|
32
|
+
if (props.onMouseLeave && typeof props.onMouseLeave === 'function') {
|
|
33
|
+
result.onMouseLeave = props.onMouseLeave;
|
|
34
|
+
}
|
|
35
|
+
} else if (type === 'data-attr') {
|
|
36
|
+
// Extract all data-* attributes
|
|
37
|
+
Object.keys(props).forEach(function (key) {
|
|
38
|
+
if (key.startsWith('data-')) {
|
|
39
|
+
result[key] = props[key];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
18
44
|
};
|
package/esm/utils/attribute.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export declare const getDataAttribute: (attrs: Record<string, string | undefined>) => Record<string, string>;
|
|
2
2
|
export declare const getDataAttributeName: (name: string) => string;
|
|
3
|
+
type ExtractType = 'mouse' | 'data-attr';
|
|
4
|
+
/**
|
|
5
|
+
* Extract specific types of props from the props object
|
|
6
|
+
* @param props - The props object to extract from
|
|
7
|
+
* @param type - The type of props to extract ('mouse' for mouse events, 'data-attr' for data-* attributes)
|
|
8
|
+
* @returns An object containing only the extracted props
|
|
9
|
+
*/
|
|
10
|
+
export declare const extractProps: (props: Record<string, any>, type: ExtractType) => Record<string, any>;
|
|
11
|
+
export {};
|
|
3
12
|
//# sourceMappingURL=attribute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["attribute.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,UAAW,OAAO,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,2BAQzE,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,MAAM,WAEhD,CAAC"}
|
|
1
|
+
{"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["attribute.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,UAAW,OAAO,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,2BAQzE,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,MAAM,WAEhD,CAAC;AAEF,KAAK,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,OAAO,MAAM,EAAE,GAAG,CAAC,QAAQ,WAAW,wBAqBzE,CAAC"}
|
package/esm/utils/attribute.js
CHANGED
|
@@ -9,4 +9,30 @@ export var getDataAttribute = function getDataAttribute(attrs) {
|
|
|
9
9
|
};
|
|
10
10
|
export var getDataAttributeName = function getDataAttributeName(name) {
|
|
11
11
|
return "data-soui-".concat(name);
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Extract specific types of props from the props object
|
|
15
|
+
* @param props - The props object to extract from
|
|
16
|
+
* @param type - The type of props to extract ('mouse' for mouse events, 'data-attr' for data-* attributes)
|
|
17
|
+
* @returns An object containing only the extracted props
|
|
18
|
+
*/
|
|
19
|
+
export var extractProps = function extractProps(props, type) {
|
|
20
|
+
var result = {};
|
|
21
|
+
if (type === 'mouse') {
|
|
22
|
+
// Only extract onMouseEnter and onMouseLeave for Tooltip support
|
|
23
|
+
if (props.onMouseEnter && typeof props.onMouseEnter === 'function') {
|
|
24
|
+
result.onMouseEnter = props.onMouseEnter;
|
|
25
|
+
}
|
|
26
|
+
if (props.onMouseLeave && typeof props.onMouseLeave === 'function') {
|
|
27
|
+
result.onMouseLeave = props.onMouseLeave;
|
|
28
|
+
}
|
|
29
|
+
} else if (type === 'data-attr') {
|
|
30
|
+
// Extract all data-* attributes
|
|
31
|
+
Object.keys(props).forEach(function (key) {
|
|
32
|
+
if (key.startsWith('data-')) {
|
|
33
|
+
result[key] = props[key];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
12
38
|
};
|