@equinor/fusion-react-searchable-dropdown 0.1.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/README.md +133 -0
- package/dist/Dropdown.d.ts +12 -0
- package/dist/Dropdown.d.ts.map +1 -0
- package/dist/Dropdown.js +6 -0
- package/dist/Dropdown.js.map +1 -0
- package/dist/DropdownProvider.d.ts +5 -0
- package/dist/DropdownProvider.d.ts.map +1 -0
- package/dist/DropdownProvider.js +6 -0
- package/dist/DropdownProvider.js.map +1 -0
- package/dist/SearchableDropdown.d.ts +14 -0
- package/dist/SearchableDropdown.d.ts.map +1 -0
- package/dist/SearchableDropdown.js +10 -0
- package/dist/SearchableDropdown.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/useDropdownProviderRef.d.ts +4 -0
- package/dist/useDropdownProviderRef.d.ts.map +1 -0
- package/dist/useDropdownProviderRef.js +16 -0
- package/dist/useDropdownProviderRef.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<!--prettier-ignore-start-->
|
|
2
|
+
# @equinor/fusion-react-searchable-dropdown
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/@equinor/fusion-react-searchable-dropdown)
|
|
5
|
+
|
|
6
|
+
[Storybook](https://equinor.github.io/fusion-react-components/?path=/docs/data-searchabledropdown)
|
|
7
|
+
|
|
8
|
+
[Fusion Web Component](https://github.com/equinor/fusion-web-components/tree/main/packages/searchable-dropdown)
|
|
9
|
+
|
|
10
|
+
### Installation
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @equinor/fusion-react-searchable-dropdown
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Example Usage
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { SearchableDropdown, SearchableDropdownChangeEvent } from '@equinor/fusion-react-searchable-dropdown';
|
|
20
|
+
const Component = ({value}: ComponentProps) => {
|
|
21
|
+
const [txt, setTxt] = useState(value);
|
|
22
|
+
const onChange = useCallback(
|
|
23
|
+
(e: SearchableDropdownChangeEvent) => setTxt(e.target.value ?? ''),
|
|
24
|
+
[setTxt]
|
|
25
|
+
);
|
|
26
|
+
return (
|
|
27
|
+
<div>
|
|
28
|
+
<SearchableDropdown onChange={onChange} />
|
|
29
|
+
<span>Value: {txt}</span>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Properties/Attributes
|
|
36
|
+
|
|
37
|
+
Name | Type | Description
|
|
38
|
+
------------------------- | ----------------------------- | -----------
|
|
39
|
+
`value` | `string` | The input control's value.
|
|
40
|
+
`type` | `SearchableDropdownType*` | A string specifying the type of control to render.
|
|
41
|
+
`variant` | `SearchableDropdownVariant**` | Input style variant to render.
|
|
42
|
+
`label` | `string` | Sets floating label value.
|
|
43
|
+
`placeholder` | `string` | Sets disappearing input placeholder.
|
|
44
|
+
`prefix` | `string` | Prefix text to display before the input.
|
|
45
|
+
`suffix` | `string` | Suffix text to display after the input.
|
|
46
|
+
`icon` | `IconName***` | Leading icon to display in input. See [`fwc-icon`](https://github.com/equinor/fusion-web-components/tree/main/packages/icon).
|
|
47
|
+
`iconTrailing` | `IconName***` | Trailing icon to display in input. See [`fwc-icon`](https://github.com/equinor/fusion-web-components/tree/main/packages/icon).
|
|
48
|
+
`disabled` | `boolean` | Whether or not the input should be disabled.
|
|
49
|
+
`charCounter` | `boolean | SearchableDropdownCharCounter****`| **Note: requries `maxLength` to be set.** Display character counter with max length.
|
|
50
|
+
`helper` | `string` | Helper text to display below the input. Display default only when focused.
|
|
51
|
+
`helperPersistent` | `boolean` | Always show the helper text despite focus.
|
|
52
|
+
`required` | `boolean` | Displays error state if value is empty and input is blurred.
|
|
53
|
+
`maxLength` | `number` | Maximum length to accept input.
|
|
54
|
+
`validationMessage` | `string` | Message to show in the error color when the searchable-dropdown is invalid. (Helper text will not be visible)
|
|
55
|
+
`pattern` | `string` | [`HTMLInputElement.prototype.pattern`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Validation-related_attributes) (empty string will unset attribute)
|
|
56
|
+
`min` | `number`\|`string` | [`HTMLInputElement.prototype.min`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Validation-related_attributes) (empty string will unset attribute)
|
|
57
|
+
`max` | `number`\|`string` | [`HTMLInputElement.prototype.max`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Validation-related_attributes) (empty string will unset attribute)
|
|
58
|
+
`size` | `number`\|`null` | [`HTMLInputElement.prototype.size`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefsize) (null will unset attribute)
|
|
59
|
+
`step` | `number`\|`null` | [`HTMLInputElement.prototype.step`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Validation-related_attributes) (null will unset attribute)
|
|
60
|
+
`autoValidate` | `boolean` | Reports validity on value change rather than only on blur.
|
|
61
|
+
`validity` | `ValidityState` (readonly) | The [`ValidityState`](https://developer.mozilla.org/en-US/docs/Web/API/ValidityState) of the searchable-dropdown.
|
|
62
|
+
`willValidate` | `boolean` (readonly) | [`HTMLInputElement.prototype.willValidate`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#Properties)
|
|
63
|
+
`validityTransform` | `ValidityTransform*****`\|`null` | Callback called before each validation check. See the [validation section](#Validation) for more details.
|
|
64
|
+
`validateOnInitialRender` | `boolean` | Runs validation check on initial render.
|
|
65
|
+
`name` | `string` | Sets the `name` attribute on the internal input.\*\*\*
|
|
66
|
+
|
|
67
|
+
\* `SearchableDropdownType` is exported by `SearchableDropdown`.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
type SearchableDropdownType = 'text'|'search'|'tel'|'url'|'email'|'password'|
|
|
71
|
+
'date'|'month'|'week'|'time'|'datetime-local'|'number'|'color';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
\*\* `SearchableDropdownVariant` is exported by `SearchableDropdown`.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
export type SearchableDropdownVariant = 'filled' | 'outlined';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
\*\*\* `IconName` is exported by `fwc-icon`.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
type IconName = keyof typeof edsIcons | string;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
\*\*\*\* `SearchableDropdownCharCounter` is exported by `SearchableDropdown`.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
type SearchableDropdownCharCounter = 'external' | 'internal';
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
\*\*\*\*\* `ValidityTransform` is exported by `SearchableDropdown`.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
type ValidityTransform = (value: string, nativeValidity: ValidityState) => Partial<ValidityState>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
\*\*\*\*\*\* The `name` property should only be used for browser autofill as webcomponent form participation does not currently consider the `name` attribute. See [#289](https://github.com/material-components/material-components-web-components/issues/289).
|
|
99
|
+
|
|
100
|
+
### Methods
|
|
101
|
+
|
|
102
|
+
| Name | Description
|
|
103
|
+
| -------- | -------------
|
|
104
|
+
| `checkValidity() => boolean` | Returns `true` if the searchable-dropdown passes validity checks. Returns `false` and fires an [`invalid`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/invalid_event) event on the searchable-dropdown otherwise. <br>**NOTE:** When accessing any property or function that checks validity at searchable-dropdown initial boot up, you may have to await `<SearchableDropdown>.updateComplete`.
|
|
105
|
+
| `reportValidity() => boolean` | Runs `checkValidity()` method, and if it returns false, then it reports to the user that the input is invalid.
|
|
106
|
+
| `setCustomValidity(message:string) => void` | Sets a custom validity message (also overwrites `validationMessage`). If this message is not the empty string, then the element is suffering from a custom validity error and does not validate.
|
|
107
|
+
| `layout() => Promise<void>` | Re-calculate layout. If a searchable-dropdown is styled with `display:none` before it is first rendered, and it has a label that is floating, then you must call `layout()` the first time you remove `display:none`, or else the notch surrounding the label will not render correctly.
|
|
108
|
+
|
|
109
|
+
### Validation
|
|
110
|
+
|
|
111
|
+
`<SearchableDropdown>` follows the basic `<input>` [constraint validation model](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation).
|
|
112
|
+
It exposes:
|
|
113
|
+
|
|
114
|
+
* `required`
|
|
115
|
+
* `maxLength`
|
|
116
|
+
* `pattern`
|
|
117
|
+
* `min`
|
|
118
|
+
* `max`
|
|
119
|
+
* `step`
|
|
120
|
+
* `validity`
|
|
121
|
+
* `willValidate`
|
|
122
|
+
* `checkValidity()`
|
|
123
|
+
* `reportValidity()`
|
|
124
|
+
* `setCustomValidity(message)`
|
|
125
|
+
|
|
126
|
+
Additionally, it implements more features such as:
|
|
127
|
+
|
|
128
|
+
* `validationMessage`
|
|
129
|
+
* `validateOnInitialRender`
|
|
130
|
+
* and `validityTransform`
|
|
131
|
+
|
|
132
|
+
By default, `<SearchableDropdown>` will report validation on `blur`.
|
|
133
|
+
<!--prettier-ignore-end-->
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SearchableDropdownElement } from '@equinor/fusion-wc-searchable-dropdown';
|
|
3
|
+
import { ComponentProps } from '@equinor/fusion-react-utils';
|
|
4
|
+
declare type ElementAttributes = Partial<Pick<SearchableDropdownElement, 'label' | 'placeholder' | 'variant' | 'meta' | 'selected' | 'initialText' | 'trailingIcon'>>;
|
|
5
|
+
declare type ElementEvents = {
|
|
6
|
+
onAction?: (e: Event) => void;
|
|
7
|
+
};
|
|
8
|
+
declare type ElementProps = ElementAttributes & ElementEvents;
|
|
9
|
+
export declare type DropdownProps = ComponentProps<SearchableDropdownElement, ElementProps>;
|
|
10
|
+
export declare const Dropdown: import("react").ForwardRefExoticComponent<import("@equinor/fusion-react-utils").ComponentAttributes<SearchableDropdownElement> & Partial<Pick<SearchableDropdownElement, "label" | "placeholder" | "variant" | "meta" | "selected" | "initialText" | "trailingIcon">> & ElementEvents & import("react").RefAttributes<SearchableDropdownElement>>;
|
|
11
|
+
export default Dropdown;
|
|
12
|
+
//# sourceMappingURL=Dropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../src/Dropdown.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,cAAc,EAAmB,MAAM,6BAA6B,CAAC;AAE9E,aAAK,iBAAiB,GAAG,OAAO,CAC9B,IAAI,CACF,yBAAyB,EACzB,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,CAC3F,CACF,CAAC;AAEF,aAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B,CAAC;AAEF,aAAK,YAAY,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAEtD,oBAAY,aAAa,GAAG,cAAc,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC;AAEpF,eAAO,MAAM,QAAQ,mVAIpB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/dist/Dropdown.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
2
|
+
import { SearchableDropdownElement } from '@equinor/fusion-wc-searchable-dropdown';
|
|
3
|
+
import { createComponent } from '@equinor/fusion-react-utils';
|
|
4
|
+
export const Dropdown = createComponent(SearchableDropdownElement, 'fwc-searchable-dropdown', { events: { onAction: 'action' } });
|
|
5
|
+
export default Dropdown;
|
|
6
|
+
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../src/Dropdown.tsx"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAkB,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAiB9E,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CACrC,yBAAyB,EACzB,yBAAyB,EACzB,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,CACnC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SearchableDropdownProviderElement } from '@equinor/fusion-wc-searchable-dropdown';
|
|
3
|
+
export declare const DropdownProvider: import("react").ForwardRefExoticComponent<Pick<import("@equinor/fusion-react-utils").ComponentAttributes<SearchableDropdownProviderElement> & Record<string, unknown>, string> & import("react").RefAttributes<SearchableDropdownProviderElement>>;
|
|
4
|
+
export default DropdownProvider;
|
|
5
|
+
//# sourceMappingURL=DropdownProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownProvider.d.ts","sourceRoot":"","sources":["../src/DropdownProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAG3F,eAAO,MAAM,gBAAgB,oPAAyF,CAAC;AAEvH,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
2
|
+
import { SearchableDropdownProviderElement } from '@equinor/fusion-wc-searchable-dropdown';
|
|
3
|
+
import { createComponent } from '@equinor/fusion-react-utils';
|
|
4
|
+
export const DropdownProvider = createComponent(SearchableDropdownProviderElement, 'fwc-searchable-dropdown-provider');
|
|
5
|
+
export default DropdownProvider;
|
|
6
|
+
//# sourceMappingURL=DropdownProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownProvider.js","sourceRoot":"","sources":["../src/DropdownProvider.tsx"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC,iCAAiC,EAAE,kCAAkC,CAAC,CAAC;AAEvH,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentProps } from '@equinor/fusion-react-utils';
|
|
2
|
+
import { SearchableDropdownElement, SearchableDropdownResolver } from '@equinor/fusion-wc-searchable-dropdown';
|
|
3
|
+
declare type ElementAttributes = Partial<Pick<SearchableDropdownElement, 'label' | 'placeholder' | 'variant' | 'meta' | 'selected' | 'initialText' | 'trailingIcon'>>;
|
|
4
|
+
declare type ElementEvents = {
|
|
5
|
+
onAction?: (e: Event) => void;
|
|
6
|
+
};
|
|
7
|
+
declare type ElementResolver = {
|
|
8
|
+
resolver?: SearchableDropdownResolver;
|
|
9
|
+
};
|
|
10
|
+
declare type ElementProps = ElementAttributes & ElementEvents & ElementResolver;
|
|
11
|
+
export declare type SearchableDropdownProps = ComponentProps<SearchableDropdownElement, ElementProps>;
|
|
12
|
+
export declare const SearchableDropdown: ({ children, ...props }: React.PropsWithChildren<ElementProps>) => JSX.Element;
|
|
13
|
+
export default SearchableDropdown;
|
|
14
|
+
//# sourceMappingURL=SearchableDropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchableDropdown.d.ts","sourceRoot":"","sources":["../src/SearchableDropdown.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAM/G,aAAK,iBAAiB,GAAG,OAAO,CAC9B,IAAI,CACF,yBAAyB,EACzB,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,CAC3F,CACF,CAAC;AAEF,aAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B,CAAC;AAEF,aAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,EAAE,0BAA0B,CAAC;CACvC,CAAC;AAEF,aAAK,YAAY,GAAG,iBAAiB,GAAG,aAAa,GAAG,eAAe,CAAC;AAExE,oBAAY,uBAAuB,GAAG,cAAc,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC;AAE9F,eAAO,MAAM,kBAAkB,2BAA4B,MAAM,iBAAiB,CAAC,YAAY,CAAC,KAAG,WAOlG,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import DropdownProvider from './DropdownProvider';
|
|
3
|
+
import Dropdown from './Dropdown';
|
|
4
|
+
import { useDropdownProviderRef } from './useDropdownProviderRef';
|
|
5
|
+
export const SearchableDropdown = ({ children, ...props }) => {
|
|
6
|
+
const providerRef = useDropdownProviderRef(props.resolver);
|
|
7
|
+
return (_jsx(DropdownProvider, { ref: providerRef, children: _jsx(Dropdown, { ...props, children: children }) }));
|
|
8
|
+
};
|
|
9
|
+
export default SearchableDropdown;
|
|
10
|
+
//# sourceMappingURL=SearchableDropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchableDropdown.js","sourceRoot":"","sources":["../src/SearchableDropdown.tsx"],"names":[],"mappings":";AAIA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAqBlE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAyC,EAAe,EAAE;IAC/G,MAAM,WAAW,GAAG,sBAAsB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC3D,OAAO,CACL,KAAC,gBAAgB,IAAC,GAAG,EAAE,WAAW,YAChC,KAAC,QAAQ,OAAK,KAAK,YAAG,QAAQ,GAAY,GACzB,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './Dropdown';
|
|
2
|
+
export * from './DropdownProvider';
|
|
3
|
+
export * from './SearchableDropdown';
|
|
4
|
+
export * from './useDropdownProviderRef';
|
|
5
|
+
export { SearchableDropdownElement as HTMLSearchableDropdownCustomElement, SearchableDropdownProviderElement as HTMLSearchableDropdownProviderCustomElement, } from '@equinor/fusion-wc-searchable-dropdown';
|
|
6
|
+
export { SearchableDropdown as default } from './SearchableDropdown';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AAEzC,OAAO,EACL,yBAAyB,IAAI,mCAAmC,EAChE,iCAAiC,IAAI,2CAA2C,GACjF,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,kBAAkB,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './Dropdown';
|
|
2
|
+
export * from './DropdownProvider';
|
|
3
|
+
export * from './SearchableDropdown';
|
|
4
|
+
export * from './useDropdownProviderRef';
|
|
5
|
+
export { SearchableDropdownElement as HTMLSearchableDropdownCustomElement, SearchableDropdownProviderElement as HTMLSearchableDropdownProviderCustomElement, } from '@equinor/fusion-wc-searchable-dropdown';
|
|
6
|
+
export { SearchableDropdown as default } from './SearchableDropdown';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AAEzC,OAAO,EACL,yBAAyB,IAAI,mCAAmC,EAChE,iCAAiC,IAAI,2CAA2C,GACjF,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,kBAAkB,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { SearchableDropdownProviderElement, SearchableDropdownResolver } from '@equinor/fusion-wc-searchable-dropdown';
|
|
3
|
+
export declare const useDropdownProviderRef: (resolver?: SearchableDropdownResolver) => MutableRefObject<SearchableDropdownProviderElement | null>;
|
|
4
|
+
//# sourceMappingURL=useDropdownProviderRef.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDropdownProviderRef.d.ts","sourceRoot":"","sources":["../src/useDropdownProviderRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEvH,eAAO,MAAM,sBAAsB,cACtB,0BAA0B,KACpC,iBAAiB,iCAAiC,GAAG,IAAI,CAc3D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
export const useDropdownProviderRef = (resolver) => {
|
|
3
|
+
const providerRef = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const current = providerRef?.current;
|
|
6
|
+
if (current && resolver) {
|
|
7
|
+
window.addEventListener('action', (e) => console.log('Event', e));
|
|
8
|
+
providerRef.current.setResolver(resolver);
|
|
9
|
+
return () => {
|
|
10
|
+
current.removeResolver();
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}, [providerRef, resolver]);
|
|
14
|
+
return providerRef;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useDropdownProviderRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDropdownProviderRef.js","sourceRoot":"","sources":["../src/useDropdownProviderRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAoB,MAAM,OAAO,CAAC;AAG5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,QAAqC,EACuB,EAAE;IAC9D,MAAM,WAAW,GAAG,MAAM,CAAoC,IAAI,CAAC,CAAC;IACpE,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,WAAW,EAAE,OAAO,CAAC;QACrC,IAAI,OAAO,IAAI,QAAQ,EAAE;YACvB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YAClE,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC1C,OAAO,GAAG,EAAE;gBACV,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5B,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@equinor/fusion-react-searchable-dropdown",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "component for displaying searchable dropdown",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"searchable dropdown",
|
|
7
|
+
"text input",
|
|
8
|
+
"list",
|
|
9
|
+
"react",
|
|
10
|
+
"fusion",
|
|
11
|
+
"equinor"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/equinor/fusion-react-components/tree/master/packages/searchable-dropdown#readme",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"directories": {
|
|
17
|
+
"dist": "dist"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/equinor/fusion-react-components.git"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -b",
|
|
31
|
+
"lint": "eslint --ext .ts,.tsx,.js src/",
|
|
32
|
+
"lint:fix": "eslint --ext .ts,.tsx,.js src/ --fix",
|
|
33
|
+
"prepack": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/equinor/fusion-react-components/issues"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@equinor/fusion-react-utils": "^2.0.3",
|
|
40
|
+
"@equinor/fusion-wc-searchable-dropdown": "^0.2.0"
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "075999bf0259f4edc4319ca85403da529b28fa2b"
|
|
43
|
+
}
|