haya-select 1.0.89 → 1.0.91
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/README.md +46 -0
- package/build/select/index.d.ts +17 -1
- package/build/select/index.d.ts.map +1 -1
- package/build/select/index.js +353 -20
- package/build/system-test-helpers.d.ts +39 -0
- package/build/system-test-helpers.d.ts.map +1 -0
- package/build/system-test-helpers.js +108 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -30,6 +30,52 @@ npm install haya-select
|
|
|
30
30
|
|
|
31
31
|
Run `npx pod-install` after installing the npm package.
|
|
32
32
|
|
|
33
|
+
# Usage
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
import {View} from "react-native"
|
|
37
|
+
import React from "react"
|
|
38
|
+
import HayaSelect from "haya-select"
|
|
39
|
+
|
|
40
|
+
export default function ExampleSelect() {
|
|
41
|
+
return (
|
|
42
|
+
<View>
|
|
43
|
+
<HayaSelect
|
|
44
|
+
options={[
|
|
45
|
+
{value: 1, text: "Option 1"},
|
|
46
|
+
{value: 2, text: "Option 2"}
|
|
47
|
+
]}
|
|
48
|
+
/>
|
|
49
|
+
</View>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Async options with pagination
|
|
55
|
+
|
|
56
|
+
When `options` is a callback, it can return either an array of options or an object with pagination metadata.
|
|
57
|
+
|
|
58
|
+
The callback receives the current `searchValue`, `page`, and optional `values` when loading default selections.
|
|
59
|
+
|
|
60
|
+
```jsx
|
|
61
|
+
<HayaSelect
|
|
62
|
+
search
|
|
63
|
+
options={async ({searchValue, page}) => {
|
|
64
|
+
const response = await fetch(`/api/options?query=${searchValue}&page=${page}`)
|
|
65
|
+
const data = await response.json()
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
options: data.options,
|
|
69
|
+
totalCount: data.totalCount,
|
|
70
|
+
page: data.page,
|
|
71
|
+
pageSize: data.pageSize
|
|
72
|
+
}
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If `totalCount` and `page` are provided, the options list shows pagination controls with previous/next buttons, a page range around the current page, and a "Page X of Y" label that can be clicked to enter a page number manually.
|
|
78
|
+
|
|
33
79
|
# Contributing
|
|
34
80
|
|
|
35
81
|
Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing).
|
package/build/select/index.d.ts
CHANGED
|
@@ -12,6 +12,16 @@ export type HayaSelectOption = {
|
|
|
12
12
|
currentContent?: (() => import("react").ReactNode) | undefined;
|
|
13
13
|
disabled?: boolean | undefined;
|
|
14
14
|
html?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Additional option props are allowed; HayaSelect only uses the keys above.
|
|
17
|
+
*/
|
|
18
|
+
right?: import("react").ReactNode;
|
|
19
|
+
};
|
|
20
|
+
export type HayaSelectOptionsResult = {
|
|
21
|
+
options: Array<HayaSelectOption>;
|
|
22
|
+
totalCount?: number | undefined;
|
|
23
|
+
page?: number | undefined;
|
|
24
|
+
pageSize?: number | undefined;
|
|
15
25
|
};
|
|
16
26
|
export type HayaSelectProps = {
|
|
17
27
|
attribute?: string | undefined;
|
|
@@ -30,7 +40,8 @@ export type HayaSelectProps = {
|
|
|
30
40
|
onChangeValue?: ((arg0?: Array<string | number> | undefined) => void) | undefined;
|
|
31
41
|
onFocus?: ((arg0?: import("react").SyntheticEvent | undefined) => void) | undefined;
|
|
32
42
|
onOptionsClosed?: (() => void) | undefined;
|
|
33
|
-
|
|
43
|
+
optionContent?: ((arg0: object) => import("react").ReactNode) | undefined;
|
|
44
|
+
options: Array<HayaSelectOption> | (() => (Array<HayaSelectOption> | HayaSelectOptionsResult));
|
|
34
45
|
optionsAbsolute: boolean;
|
|
35
46
|
optionsPortal: boolean;
|
|
36
47
|
optionsWidth?: number | undefined;
|
|
@@ -42,5 +53,10 @@ export type HayaSelectProps = {
|
|
|
42
53
|
transparent: boolean;
|
|
43
54
|
values?: (string | number)[] | undefined;
|
|
44
55
|
};
|
|
56
|
+
export type PaginationPageButtonProps = {
|
|
57
|
+
active: boolean;
|
|
58
|
+
page: number;
|
|
59
|
+
onPageSelected: (arg0: number) => void;
|
|
60
|
+
};
|
|
45
61
|
import React from "react";
|
|
46
62
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/select/index.jsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/select/index.jsx"],"names":[],"mappings":";;;UA2Bc,MAAM;WACN,MAAM;WACN,MAAM;;;WAKN,MAAM,GAAC,MAAM;WACb,OAAO,OAAO,EAAE,SAAS;qBACb,OAAO,OAAO,EAAE,SAAS;4BACzB,OAAO,OAAO,EAAE,SAAS;;;;;;YAGrC,OAAO,OAAO,EAAE,SAAS;;;aAOzB,KAAK,CAAC,gBAAgB,CAAC;;;;;;;;qBAUvB,MAAM;;;;SAIN,OAAO,OAAO,EAAE,SAAS;YACzB,MAAM;cACN,OAAO;;2BAEK,OAAO,OAAO,EAAE,SAAS;sBAC5B,OAAO,OAAO,EAAE,cAAc,YAAC,KAAG,IAAI;wBACtC,OAAO,OAAO,EAAE,cAAc,YAAC,KAAG,IAAI;6BACtC,KAAK,CAAC,MAAM,GAAC,MAAM,CAAC,YAAC,KAAG,IAAI;uBAC5B,OAAO,OAAO,EAAE,cAAc,YAAC,KAAG,IAAI;6BACnC,IAAI;4BACP,MAAM,KAAG,OAAO,OAAO,EAAE,SAAS;aAC3C,KAAK,CAAC,gBAAgB,CAAC,IAAC,MAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAC,uBAAuB,CAAC,CAAA;qBACrF,OAAO;mBACP,OAAO;;kBAEP,OAAO,OAAO,EAAE,SAAS;YACzB,OAAO;aACP,MAAM;cACN,MAAM;;iBAEN,OAAO;;;;YAmBP,OAAO;UACP,MAAM;oBACN,CAAS,IAAM,EAAN,MAAM,KAAG,IAAI;;kBAlGM,OAAO"}
|