@mittwald/flow-react-components 0.2.0-alpha.384 → 0.2.0-alpha.385
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 +6 -0
- package/dist/assets/doc-properties.json +2106 -2106
- package/dist/js/components/src/components/Autocomplete/Autocomplete.mjs +22 -30
- package/dist/js/components/src/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/dist/types/components/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -87,38 +87,30 @@ const Autocomplete = flowComponent("Autocomplete", (props) => {
|
|
|
87
87
|
}
|
|
88
88
|
controller.close();
|
|
89
89
|
};
|
|
90
|
-
return /* @__PURE__ */ jsx(
|
|
91
|
-
|
|
90
|
+
return /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, mergeInParentContext: true, children: /* @__PURE__ */ jsx("div", { ...focusWithin.focusWithinProps, ref: container, children: /* @__PURE__ */ jsx(UNSAFE_PortalProvider, { getContainer: () => container.current, children: /* @__PURE__ */ jsxs(
|
|
91
|
+
Aria.Autocomplete,
|
|
92
92
|
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
isNonModal: true,
|
|
113
|
-
placement: "bottom start",
|
|
114
|
-
children: /* @__PURE__ */ jsx(TunnelExit, { id: "options" })
|
|
115
|
-
}
|
|
116
|
-
)
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
) }) })
|
|
93
|
+
onInputChange: handleOnInputChange,
|
|
94
|
+
filter: contains,
|
|
95
|
+
disableAutoFocusFirst: true,
|
|
96
|
+
...rest,
|
|
97
|
+
children: [
|
|
98
|
+
children,
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
Options,
|
|
101
|
+
{
|
|
102
|
+
onAction: handleOptionAction,
|
|
103
|
+
triggerRef,
|
|
104
|
+
controller,
|
|
105
|
+
renderEmptyState,
|
|
106
|
+
isNonModal: true,
|
|
107
|
+
placement: "bottom start",
|
|
108
|
+
children: /* @__PURE__ */ jsx(TunnelExit, { id: "options" })
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
]
|
|
120
112
|
}
|
|
121
|
-
);
|
|
113
|
+
) }) }) });
|
|
122
114
|
});
|
|
123
115
|
|
|
124
116
|
export { Autocomplete, Autocomplete as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.mjs","sources":["../../../../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import { useRef, type PropsWithChildren } from \"react\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { SearchFieldProps } from \"@/components/SearchField\";\nimport type { TextFieldProps } from \"@/components/TextField\";\nimport Options from \"@/components/Options\";\nimport { TunnelExit } from \"@mittwald/react-tunnel\";\nimport locales from \"./locales/*.locale.json\";\nimport Text from \"@/components/Text\";\nimport styles from \"./Autocomplete.module.scss\";\nimport {\n UNSAFE_PortalProvider,\n useFocusWithin,\n useLocalizedStringFormatter,\n} from \"react-aria\";\nexport interface AutocompleteProps\n extends PropsWithChildren,\n PropsWithClassName,\n FlowComponentProps,\n Omit<Aria.AutocompleteProps, \"children\" | \"onInputChange\" | \"inputValue\"> {}\n\n/** @flr-generate all */\nexport const Autocomplete = flowComponent(\"Autocomplete\", (props) => {\n const { children, ...rest } = props;\n\n const { contains } = Aria.useFilter({ sensitivity: \"base\" });\n const stringFormatter = useLocalizedStringFormatter(locales);\n const container = useRef(null);\n const triggerRef = useRef<HTMLInputElement>(null);\n\n const controller = useOverlayController(\"Popover\", {\n reuseControllerFromContext: false,\n });\n const menuIsOpen = controller.useIsOpen();\n\n const focusWithin = useFocusWithin({\n onBlurWithin: controller.close,\n });\n\n const inputProps: SearchFieldProps & TextFieldProps = {\n onKeyDown: (e) => {\n if (e.key === \"Enter\" && menuIsOpen) {\n e.preventDefault();\n }\n },\n ref: triggerRef,\n };\n\n const renderEmptyState = () => (\n <Text className={styles.empty}>\n {stringFormatter.format(\"autocomplete.empty\")}\n </Text>\n );\n\n const propsContext: PropsContext = {\n ContextMenu: {\n placement: \"bottom start\",\n controller,\n isNonModal: true,\n renderEmptyState: () => (\n <Text className={styles.empty}>\n {stringFormatter.format(\"autocomplete.empty\")}\n </Text>\n ),\n onAction: (key) => {\n const input = triggerRef.current;\n if (input) {\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(input),\n \"value\",\n )?.set;\n nativeInputValueSetter?.call(input, String(key));\n const event = new Event(\"change\", { bubbles: true });\n input.dispatchEvent(event);\n }\n },\n triggerRef,\n },\n SearchField: inputProps,\n TextField: inputProps,\n Option: {\n tunnelId: \"options\",\n },\n Popover: {\n className: styles.popover,\n },\n };\n\n const handleOnInputChange = (value: string) => {\n if (!value) {\n controller.close();\n } else if (!menuIsOpen) {\n controller.open();\n }\n };\n\n const handleOptionAction = (key: Aria.Key) => {\n const inputElement = triggerRef.current;\n if (inputElement) {\n // Set value on input element and trigger change event\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\",\n )?.set;\n nativeInputValueSetter?.call(inputElement, String(key));\n const event = new Event(\"change\", { bubbles: true });\n inputElement.dispatchEvent(event);\n }\n controller.close();\n };\n\n return (\n <PropsContextProvider
|
|
1
|
+
{"version":3,"file":"Autocomplete.mjs","sources":["../../../../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import { useRef, type PropsWithChildren } from \"react\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { SearchFieldProps } from \"@/components/SearchField\";\nimport type { TextFieldProps } from \"@/components/TextField\";\nimport Options from \"@/components/Options\";\nimport { TunnelExit } from \"@mittwald/react-tunnel\";\nimport locales from \"./locales/*.locale.json\";\nimport Text from \"@/components/Text\";\nimport styles from \"./Autocomplete.module.scss\";\nimport {\n UNSAFE_PortalProvider,\n useFocusWithin,\n useLocalizedStringFormatter,\n} from \"react-aria\";\nexport interface AutocompleteProps\n extends PropsWithChildren,\n PropsWithClassName,\n FlowComponentProps,\n Omit<Aria.AutocompleteProps, \"children\" | \"onInputChange\" | \"inputValue\"> {}\n\n/** @flr-generate all */\nexport const Autocomplete = flowComponent(\"Autocomplete\", (props) => {\n const { children, ...rest } = props;\n\n const { contains } = Aria.useFilter({ sensitivity: \"base\" });\n const stringFormatter = useLocalizedStringFormatter(locales);\n const container = useRef(null);\n const triggerRef = useRef<HTMLInputElement>(null);\n\n const controller = useOverlayController(\"Popover\", {\n reuseControllerFromContext: false,\n });\n const menuIsOpen = controller.useIsOpen();\n\n const focusWithin = useFocusWithin({\n onBlurWithin: controller.close,\n });\n\n const inputProps: SearchFieldProps & TextFieldProps = {\n onKeyDown: (e) => {\n if (e.key === \"Enter\" && menuIsOpen) {\n e.preventDefault();\n }\n },\n ref: triggerRef,\n };\n\n const renderEmptyState = () => (\n <Text className={styles.empty}>\n {stringFormatter.format(\"autocomplete.empty\")}\n </Text>\n );\n\n const propsContext: PropsContext = {\n ContextMenu: {\n placement: \"bottom start\",\n controller,\n isNonModal: true,\n renderEmptyState: () => (\n <Text className={styles.empty}>\n {stringFormatter.format(\"autocomplete.empty\")}\n </Text>\n ),\n onAction: (key) => {\n const input = triggerRef.current;\n if (input) {\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(input),\n \"value\",\n )?.set;\n nativeInputValueSetter?.call(input, String(key));\n const event = new Event(\"change\", { bubbles: true });\n input.dispatchEvent(event);\n }\n },\n triggerRef,\n },\n SearchField: inputProps,\n TextField: inputProps,\n Option: {\n tunnelId: \"options\",\n },\n Popover: {\n className: styles.popover,\n },\n };\n\n const handleOnInputChange = (value: string) => {\n if (!value) {\n controller.close();\n } else if (!menuIsOpen) {\n controller.open();\n }\n };\n\n const handleOptionAction = (key: Aria.Key) => {\n const inputElement = triggerRef.current;\n if (inputElement) {\n // Set value on input element and trigger change event\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\",\n )?.set;\n nativeInputValueSetter?.call(inputElement, String(key));\n const event = new Event(\"change\", { bubbles: true });\n inputElement.dispatchEvent(event);\n }\n controller.close();\n };\n\n return (\n <PropsContextProvider props={propsContext} mergeInParentContext>\n <div {...focusWithin.focusWithinProps} ref={container}>\n <UNSAFE_PortalProvider getContainer={() => container.current}>\n <Aria.Autocomplete\n onInputChange={handleOnInputChange}\n filter={contains}\n disableAutoFocusFirst\n {...rest}\n >\n {children}\n <Options\n onAction={handleOptionAction}\n triggerRef={triggerRef}\n controller={controller}\n renderEmptyState={renderEmptyState}\n isNonModal\n placement=\"bottom start\"\n >\n <TunnelExit id=\"options\" />\n </Options>\n </Aria.Autocomplete>\n </UNSAFE_PortalProvider>\n </div>\n </PropsContextProvider>\n );\n});\n\nexport default Autocomplete;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA4BO,MAAM,YAAe,GAAA,aAAA,CAAc,cAAgB,EAAA,CAAC,KAAU,KAAA;AACnE,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,IAAA,EAAS,GAAA,KAAA;AAE9B,EAAM,MAAA,EAAE,UAAa,GAAA,IAAA,CAAK,UAAU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ClB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,eAAe,GAAG,YAAY,CAAC;CAAG;AAEhF,wBAAwB;AACxB,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,sCAAsC,CAAC;AAa9C,MAAM,WAAW,iBACf,SAAQ,iBAAiB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,eAAe,GAAG,YAAY,CAAC;CAAG;AAEhF,wBAAwB;AACxB,eAAO,MAAM,YAAY,sGAmHvB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.385",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@chakra-ui/live-region": "^2.1.0",
|
|
59
59
|
"@internationalized/string-compiler": "^3.2.6",
|
|
60
60
|
"@mittwald/password-tools-js": "3.0.0-alpha.12",
|
|
61
|
-
"@mittwald/react-tunnel": "0.2.0-alpha.
|
|
61
|
+
"@mittwald/react-tunnel": "0.2.0-alpha.385",
|
|
62
62
|
"@mittwald/react-use-promise": "^3.0.4",
|
|
63
63
|
"@react-aria/form": "^3.1.0",
|
|
64
64
|
"@react-aria/utils": "^3.30.0",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@faker-js/faker": "^9.9.0",
|
|
100
100
|
"@internationalized/date": "^3.8.2",
|
|
101
101
|
"@mittwald/flow-core": "",
|
|
102
|
-
"@mittwald/flow-design-tokens": "0.2.0-alpha.
|
|
102
|
+
"@mittwald/flow-design-tokens": "0.2.0-alpha.385",
|
|
103
103
|
"@mittwald/react-use-promise": "^3.0.4",
|
|
104
104
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.3",
|
|
105
105
|
"@mittwald/typescript-config": "",
|
|
@@ -172,5 +172,5 @@
|
|
|
172
172
|
"optional": true
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
|
-
"gitHead": "
|
|
175
|
+
"gitHead": "844fa08ea56b08da8bba18f3c8e7970fae1c35c0"
|
|
176
176
|
}
|