@korsolutions/ui 0.0.30 → 0.0.32
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/babel.config.js +17 -11
- package/bob.config.js +1 -0
- package/dist/module/components/avatar/avatar.js +1 -1
- package/dist/module/components/avatar/avatar.js.map +1 -1
- package/dist/module/components/avatar/variants/default.js +1 -1
- package/dist/module/components/avatar/variants/default.js.map +1 -1
- package/dist/module/components/avatar/variants/index.js.map +1 -1
- package/dist/module/components/badge/badge.js +1 -1
- package/dist/module/components/badge/badge.js.map +1 -1
- package/dist/module/components/badge/variants/default.js +1 -1
- package/dist/module/components/badge/variants/default.js.map +1 -1
- package/dist/module/components/badge/variants/index.js.map +1 -1
- package/dist/module/components/badge/variants/secondary.js +1 -1
- package/dist/module/components/badge/variants/secondary.js.map +1 -1
- package/dist/module/components/button/button.js +1 -1
- package/dist/module/components/button/button.js.map +1 -1
- package/dist/module/components/button/variants/default.js +2 -2
- package/dist/module/components/button/variants/default.js.map +1 -1
- package/dist/module/components/button/variants/index.js.map +1 -1
- package/dist/module/components/button/variants/secondary.js +2 -2
- package/dist/module/components/button/variants/secondary.js.map +1 -1
- package/dist/module/components/calendar/calendar.js +1 -1
- package/dist/module/components/calendar/calendar.js.map +1 -1
- package/dist/module/components/calendar/index.js.map +1 -1
- package/dist/module/components/calendar/variants/default.js +1 -1
- package/dist/module/components/calendar/variants/default.js.map +1 -1
- package/dist/module/components/calendar/variants/index.js.map +1 -1
- package/dist/module/components/card/card.js +1 -1
- package/dist/module/components/card/card.js.map +1 -1
- package/dist/module/components/card/variants/default.js +1 -1
- package/dist/module/components/card/variants/default.js.map +1 -1
- package/dist/module/components/card/variants/index.js.map +1 -1
- package/dist/module/components/dropdown-menu/dropdown-menu.js +1 -1
- package/dist/module/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/module/components/dropdown-menu/variants/default.js +1 -1
- package/dist/module/components/dropdown-menu/variants/default.js.map +1 -1
- package/dist/module/components/dropdown-menu/variants/index.js.map +1 -1
- package/dist/module/components/empty/empty.js +1 -1
- package/dist/module/components/empty/empty.js.map +1 -1
- package/dist/module/components/empty/variants/default.js +1 -1
- package/dist/module/components/empty/variants/default.js.map +1 -1
- package/dist/module/components/empty/variants/index.js.map +1 -1
- package/dist/module/components/field/field.js +1 -1
- package/dist/module/components/field/field.js.map +1 -1
- package/dist/module/components/field/variants/default.js +1 -1
- package/dist/module/components/field/variants/default.js.map +1 -1
- package/dist/module/components/field/variants/index.js.map +1 -1
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/input/index.js.map +1 -1
- package/dist/module/components/input/input.js +1 -1
- package/dist/module/components/input/input.js.map +1 -1
- package/dist/module/components/input/numeric-input.js +1 -1
- package/dist/module/components/input/numeric-input.js.map +1 -1
- package/dist/module/components/input/variants/default.js +1 -1
- package/dist/module/components/input/variants/default.js.map +1 -1
- package/dist/module/components/input/variants/index.js.map +1 -1
- package/dist/module/components/link/link.js.map +1 -1
- package/dist/module/components/link/variants/default.js +1 -1
- package/dist/module/components/link/variants/default.js.map +1 -1
- package/dist/module/components/link/variants/index.js.map +1 -1
- package/dist/module/components/popover/popover.js +1 -1
- package/dist/module/components/popover/popover.js.map +1 -1
- package/dist/module/components/popover/variants/default.js +1 -1
- package/dist/module/components/popover/variants/default.js.map +1 -1
- package/dist/module/components/popover/variants/index.js.map +1 -1
- package/dist/module/components/popover/variants/unstyled.js +1 -1
- package/dist/module/components/popover/variants/unstyled.js.map +1 -1
- package/dist/module/components/select/select.js +1 -1
- package/dist/module/components/select/select.js.map +1 -1
- package/dist/module/components/select/variants/default.js +1 -1
- package/dist/module/components/select/variants/default.js.map +1 -1
- package/dist/module/components/select/variants/index.js.map +1 -1
- package/dist/module/components/textarea/textarea.js +1 -1
- package/dist/module/components/textarea/textarea.js.map +1 -1
- package/dist/module/components/textarea/variants/default.js +1 -1
- package/dist/module/components/textarea/variants/default.js.map +1 -1
- package/dist/module/components/textarea/variants/index.js.map +1 -1
- package/dist/module/components/toast/index.js.map +1 -1
- package/dist/module/components/toast/toast-manager.js +1 -1
- package/dist/module/components/toast/toast-manager.js.map +1 -1
- package/dist/module/components/toast/toast.js +1 -1
- package/dist/module/components/toast/toast.js.map +1 -1
- package/dist/module/components/toast/variants/danger.js +1 -1
- package/dist/module/components/toast/variants/danger.js.map +1 -1
- package/dist/module/components/toast/variants/default.js +1 -1
- package/dist/module/components/toast/variants/default.js.map +1 -1
- package/dist/module/components/toast/variants/index.js.map +1 -1
- package/dist/module/components/toast/variants/success.js +1 -1
- package/dist/module/components/toast/variants/success.js.map +1 -1
- package/dist/module/components/typography/typography.js.map +1 -1
- package/dist/module/components/typography/variants/body-lg.js +1 -1
- package/dist/module/components/typography/variants/body-lg.js.map +1 -1
- package/dist/module/components/typography/variants/body-md.js +1 -1
- package/dist/module/components/typography/variants/body-md.js.map +1 -1
- package/dist/module/components/typography/variants/body-sm.js +1 -1
- package/dist/module/components/typography/variants/body-sm.js.map +1 -1
- package/dist/module/components/typography/variants/heading-lg.js +1 -1
- package/dist/module/components/typography/variants/heading-lg.js.map +1 -1
- package/dist/module/components/typography/variants/heading-md.js +1 -1
- package/dist/module/components/typography/variants/heading-md.js.map +1 -1
- package/dist/module/components/typography/variants/heading-sm.js +1 -1
- package/dist/module/components/typography/variants/heading-sm.js.map +1 -1
- package/dist/module/components/typography/variants/index.js.map +1 -1
- package/dist/module/hooks/index.js.map +1 -1
- package/dist/module/index.js +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/primitives/avatar/avatar-fallback.js.map +1 -1
- package/dist/module/primitives/avatar/avatar-image.js.map +1 -1
- package/dist/module/primitives/avatar/avatar-root.js.map +1 -1
- package/dist/module/primitives/avatar/index.js.map +1 -1
- package/dist/module/primitives/badge/badge-label.js +1 -1
- package/dist/module/primitives/badge/badge-label.js.map +1 -1
- package/dist/module/primitives/badge/badge-root.js +1 -1
- package/dist/module/primitives/badge/badge-root.js.map +1 -1
- package/dist/module/primitives/badge/index.js.map +1 -1
- package/dist/module/primitives/button/button-label.js +1 -1
- package/dist/module/primitives/button/button-label.js.map +1 -1
- package/dist/module/primitives/button/button-root.js.map +1 -1
- package/dist/module/primitives/button/button-spinner.js +1 -1
- package/dist/module/primitives/button/button-spinner.js.map +1 -1
- package/dist/module/primitives/button/index.js.map +1 -1
- package/dist/module/primitives/calendar/calendar-day.js +1 -1
- package/dist/module/primitives/calendar/calendar-day.js.map +1 -1
- package/dist/module/primitives/calendar/calendar-header.js.map +1 -1
- package/dist/module/primitives/calendar/calendar-nav-button.js.map +1 -1
- package/dist/module/primitives/calendar/calendar-root.js.map +1 -1
- package/dist/module/primitives/calendar/calendar-title.js.map +1 -1
- package/dist/module/primitives/calendar/calendar-week-labels.js.map +1 -1
- package/dist/module/primitives/calendar/calendar-weeks.js +1 -1
- package/dist/module/primitives/calendar/calendar-weeks.js.map +1 -1
- package/dist/module/primitives/calendar/index.js.map +1 -1
- package/dist/module/primitives/card/card-body.js +1 -1
- package/dist/module/primitives/card/card-body.js.map +1 -1
- package/dist/module/primitives/card/card-footer.js +1 -1
- package/dist/module/primitives/card/card-footer.js.map +1 -1
- package/dist/module/primitives/card/card-header.js +1 -1
- package/dist/module/primitives/card/card-header.js.map +1 -1
- package/dist/module/primitives/card/card-root.js +1 -1
- package/dist/module/primitives/card/card-root.js.map +1 -1
- package/dist/module/primitives/card/card-title.js +1 -1
- package/dist/module/primitives/card/card-title.js.map +1 -1
- package/dist/module/primitives/card/index.js.map +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-button.js.map +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-content.js +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-content.js.map +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-divider.js.map +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-overlay.js.map +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-portal.js.map +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-root.js +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-root.js.map +1 -1
- package/dist/module/primitives/dropdown-menu/dropdown-menu-trigger.js +23 -9
- package/dist/module/primitives/dropdown-menu/dropdown-menu-trigger.js.map +1 -1
- package/dist/module/primitives/dropdown-menu/index.js.map +1 -1
- package/dist/module/primitives/empty/empty-description.js.map +1 -1
- package/dist/module/primitives/empty/empty-media.js.map +1 -1
- package/dist/module/primitives/empty/empty-root.js.map +1 -1
- package/dist/module/primitives/empty/empty-title.js.map +1 -1
- package/dist/module/primitives/empty/index.js.map +1 -1
- package/dist/module/primitives/field/field-description.js.map +1 -1
- package/dist/module/primitives/field/field-error.js.map +1 -1
- package/dist/module/primitives/field/field-label.js.map +1 -1
- package/dist/module/primitives/field/field-root.js.map +1 -1
- package/dist/module/primitives/field/index.js.map +1 -1
- package/dist/module/primitives/index.js.map +1 -1
- package/dist/module/primitives/input/index.js.map +1 -1
- package/dist/module/primitives/input/input.js.map +1 -1
- package/dist/module/primitives/popover/index.js.map +1 -1
- package/dist/module/primitives/popover/popover-close.js.map +1 -1
- package/dist/module/primitives/popover/popover-content.js +1 -1
- package/dist/module/primitives/popover/popover-content.js.map +1 -1
- package/dist/module/primitives/popover/popover-overlay.js.map +1 -1
- package/dist/module/primitives/popover/popover-portal.js.map +1 -1
- package/dist/module/primitives/popover/popover-root.js +1 -1
- package/dist/module/primitives/popover/popover-root.js.map +1 -1
- package/dist/module/primitives/popover/popover-trigger.js +23 -9
- package/dist/module/primitives/popover/popover-trigger.js.map +1 -1
- package/dist/module/primitives/portal/index.js +1 -1
- package/dist/module/primitives/portal/index.js.map +1 -1
- package/dist/module/primitives/portal/portal.js.map +1 -1
- package/dist/module/primitives/portal/portal.web.js +28 -0
- package/dist/module/primitives/portal/portal.web.js.map +1 -0
- package/dist/module/primitives/select/index.js.map +1 -1
- package/dist/module/primitives/select/select-content.js +1 -1
- package/dist/module/primitives/select/select-content.js.map +1 -1
- package/dist/module/primitives/select/select-option.js +1 -1
- package/dist/module/primitives/select/select-option.js.map +1 -1
- package/dist/module/primitives/select/select-overlay.js +1 -1
- package/dist/module/primitives/select/select-overlay.js.map +1 -1
- package/dist/module/primitives/select/select-portal.js.map +1 -1
- package/dist/module/primitives/select/select-root.js +1 -1
- package/dist/module/primitives/select/select-root.js.map +1 -1
- package/dist/module/primitives/select/select-trigger.js +2 -2
- package/dist/module/primitives/select/select-trigger.js.map +1 -1
- package/dist/module/primitives/select/select-value.js +1 -1
- package/dist/module/primitives/select/select-value.js.map +1 -1
- package/dist/module/primitives/textarea/index.js.map +1 -1
- package/dist/module/primitives/toast/index.js.map +1 -1
- package/dist/module/primitives/toast/toast-description.js.map +1 -1
- package/dist/module/primitives/toast/toast-root.js.map +1 -1
- package/dist/module/primitives/toast/toast-title.js.map +1 -1
- package/dist/module/themes/adapters/index.js.map +1 -1
- package/dist/module/themes/adapters/react-navigation.js.map +1 -1
- package/dist/module/themes/default/index.js.map +1 -1
- package/dist/module/themes/index.js.map +1 -1
- package/dist/module/themes/provider.js.map +1 -1
- package/dist/module/themes/themes.js.map +1 -1
- package/dist/module/utils/use-themed-styles.js +1 -1
- package/dist/module/utils/use-themed-styles.js.map +1 -1
- package/dist/typescript/babel.config.d.ts +9 -8
- package/dist/typescript/babel.config.d.ts.map +1 -1
- package/dist/typescript/bob.config.d.ts +1 -0
- package/dist/typescript/src/components/avatar/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/badge/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/badge/variants/secondary.d.ts +1 -1
- package/dist/typescript/src/components/button/button.d.ts +1 -1
- package/dist/typescript/src/components/button/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/button/variants/secondary.d.ts +1 -1
- package/dist/typescript/src/components/calendar/calendar.d.ts +1 -1
- package/dist/typescript/src/components/calendar/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/card/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/dropdown-menu/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/empty/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/field/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/input/input.d.ts +2 -3
- package/dist/typescript/src/components/input/input.d.ts.map +1 -1
- package/dist/typescript/src/components/input/numeric-input.d.ts +2 -2
- package/dist/typescript/src/components/input/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/popover/popover.d.ts +1 -1
- package/dist/typescript/src/components/popover/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/popover/variants/unstyled.d.ts +1 -1
- package/dist/typescript/src/components/select/select.d.ts +1 -1
- package/dist/typescript/src/components/select/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/textarea/textarea.d.ts +2 -3
- package/dist/typescript/src/components/textarea/textarea.d.ts.map +1 -1
- package/dist/typescript/src/components/textarea/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/toast/variants/danger.d.ts +1 -1
- package/dist/typescript/src/components/toast/variants/default.d.ts +1 -1
- package/dist/typescript/src/components/toast/variants/success.d.ts +1 -1
- package/dist/typescript/src/primitives/dropdown-menu/context.d.ts +1 -1
- package/dist/typescript/src/primitives/dropdown-menu/dropdown-menu-trigger.d.ts +1 -1
- package/dist/typescript/src/primitives/dropdown-menu/dropdown-menu-trigger.d.ts.map +1 -1
- package/dist/typescript/src/primitives/input/input.d.ts +1 -1
- package/dist/typescript/src/primitives/popover/context.d.ts +1 -1
- package/dist/typescript/src/primitives/popover/popover-content.d.ts.map +1 -1
- package/dist/typescript/src/primitives/popover/popover-trigger.d.ts +1 -1
- package/dist/typescript/src/primitives/popover/popover-trigger.d.ts.map +1 -1
- package/dist/typescript/src/primitives/portal/portal.web.d.ts +4 -0
- package/dist/typescript/src/primitives/portal/portal.web.d.ts.map +1 -0
- package/dist/typescript/src/utils/use-themed-styles.d.ts +1 -1
- package/package.json +4 -2
- package/scripts/build.sh +2 -0
- package/src/components/input/input.tsx +1 -1
- package/src/components/textarea/textarea.tsx +1 -1
- package/src/primitives/dropdown-menu/dropdown-menu-trigger.tsx +23 -10
- package/src/primitives/popover/popover-content.tsx +1 -1
- package/src/primitives/popover/popover-trigger.tsx +23 -10
- package/src/primitives/portal/portal.web.tsx +22 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/popover/popover-trigger.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,CAAC;CAC7E;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,cAAc,+
|
|
1
|
+
{"version":3,"file":"popover-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/popover/popover-trigger.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,CAAC;CAC7E;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,cAAc,+FA4CzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal.web.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/portal/portal.web.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE3E,wBAAgB,UAAU,gCAEzB;AAED,wBAAgB,MAAM,CAAC,EAAE,IAAI,EAAE,QAA8B,EAAE,QAAQ,EAAE,EAAE,WAAW,+BAarF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korsolutions/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/react": "^19.2.3",
|
|
40
40
|
"@types/react-dom": "^19.2.3",
|
|
41
|
-
"
|
|
41
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
42
|
+
"react-native-builder-bob": "^0.40.17",
|
|
43
|
+
"tsc-alias": "^1.8.16"
|
|
42
44
|
},
|
|
43
45
|
"peerDependencies": {
|
|
44
46
|
"react": "*",
|
package/scripts/build.sh
ADDED
|
@@ -2,7 +2,7 @@ import { InputPrimitive, type InputPrimitiveBaseProps } from "@/primitives";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { InputVariants } from "./variants";
|
|
4
4
|
|
|
5
|
-
interface InputProps extends InputPrimitiveBaseProps {
|
|
5
|
+
export interface InputProps extends InputPrimitiveBaseProps {
|
|
6
6
|
variant?: keyof typeof InputVariants;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import { TextareaPrimitive, type TextareaPrimitiveBaseProps } from "@/primitives
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { TextareaVariants } from "./variants";
|
|
4
4
|
|
|
5
|
-
interface TextareaProps extends TextareaPrimitiveBaseProps {
|
|
5
|
+
export interface TextareaProps extends TextareaPrimitiveBaseProps {
|
|
6
6
|
variant?: keyof typeof TextareaVariants;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -17,20 +17,33 @@ export const DropdownMenuTrigger = forwardRef<DropdownMenuTriggerRef, DropdownMe
|
|
|
17
17
|
const triggerRef = useRef<ViewRef>(null);
|
|
18
18
|
|
|
19
19
|
const onTriggerPress = async () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (!dropdownMenu.isOpen) {
|
|
21
|
+
triggerRef.current?.measureInWindow((pageX, pageY, width, height) => {
|
|
22
|
+
dropdownMenu.setTriggerPosition({
|
|
23
|
+
height,
|
|
24
|
+
width,
|
|
25
|
+
pageX,
|
|
26
|
+
pageY,
|
|
27
|
+
});
|
|
28
|
+
dropdownMenu.setIsOpen(true);
|
|
26
29
|
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
} else {
|
|
31
|
+
dropdownMenu.setIsOpen(false);
|
|
32
|
+
}
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
useImperativeHandle(ref, () => ({
|
|
33
|
-
open: () =>
|
|
36
|
+
open: () => {
|
|
37
|
+
triggerRef.current?.measureInWindow((pageX, pageY, width, height) => {
|
|
38
|
+
dropdownMenu.setTriggerPosition({
|
|
39
|
+
height,
|
|
40
|
+
width,
|
|
41
|
+
pageX,
|
|
42
|
+
pageY,
|
|
43
|
+
});
|
|
44
|
+
dropdownMenu.setIsOpen(true);
|
|
45
|
+
});
|
|
46
|
+
},
|
|
34
47
|
close: () => dropdownMenu.setIsOpen(false),
|
|
35
48
|
}));
|
|
36
49
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { useRelativePosition } from "@/hooks/use-relative-position";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
3
4
|
import { usePopover } from "./context";
|
|
4
|
-
import { useRelativePosition } from "@/hooks/use-relative-position";
|
|
5
5
|
|
|
6
6
|
export interface PopoverContentProps {
|
|
7
7
|
children?: React.ReactNode;
|
|
@@ -17,20 +17,33 @@ export const PopoverTrigger = forwardRef<PopoverTriggerRef, PopoverTriggerProps>
|
|
|
17
17
|
const triggerRef = useRef<ViewRef>(null);
|
|
18
18
|
|
|
19
19
|
const onTriggerPress = async () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (!popover.isOpen) {
|
|
21
|
+
triggerRef.current?.measureInWindow((pageX, pageY, width, height) => {
|
|
22
|
+
popover.setTriggerPosition({
|
|
23
|
+
height,
|
|
24
|
+
width,
|
|
25
|
+
pageX,
|
|
26
|
+
pageY,
|
|
27
|
+
});
|
|
28
|
+
popover.setIsOpen(true);
|
|
26
29
|
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
} else {
|
|
31
|
+
popover.setIsOpen(false);
|
|
32
|
+
}
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
useImperativeHandle(ref, () => ({
|
|
33
|
-
open: () =>
|
|
36
|
+
open: () => {
|
|
37
|
+
triggerRef.current?.measureInWindow((pageX, pageY, width, height) => {
|
|
38
|
+
popover.setTriggerPosition({
|
|
39
|
+
height,
|
|
40
|
+
width,
|
|
41
|
+
pageX,
|
|
42
|
+
pageY,
|
|
43
|
+
});
|
|
44
|
+
popover.setIsOpen(true);
|
|
45
|
+
});
|
|
46
|
+
},
|
|
34
47
|
close: () => popover.setIsOpen(false),
|
|
35
48
|
}));
|
|
36
49
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { DEFAULT_PORTAL_HOST, type PortalProps } from "./portal.constants";
|
|
4
|
+
|
|
5
|
+
export function PortalHost() {
|
|
6
|
+
return <></>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function Portal({ name, hostName = DEFAULT_PORTAL_HOST, children }: PortalProps) {
|
|
10
|
+
const [container] = useState(() => {
|
|
11
|
+
let container = document.getElementById(hostName);
|
|
12
|
+
|
|
13
|
+
if (!container) {
|
|
14
|
+
container = document.createElement("div");
|
|
15
|
+
container.id = hostName;
|
|
16
|
+
document.body.appendChild(container);
|
|
17
|
+
}
|
|
18
|
+
return container;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return <>{createPortal(children, container, name)}</>;
|
|
22
|
+
}
|