@@ -6,7 +6,7 @@
|
||||
descriptionIds?: string;
|
||||
}
|
||||
|
||||
const DESCRIPTION_CONTEXT_NAME = "DescriptionContext";
|
||||
const DESCRIPTION_CONTEXT_NAME = "headlessui-description-context";
|
||||
export function useDescriptionContext():
|
||||
| Writable<DescriptionContext>
|
||||
| undefined {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
close(): void;
|
||||
}
|
||||
|
||||
const DIALOG_CONTEXT_NAME = "DialogContext";
|
||||
const DIALOG_CONTEXT_NAME = "headlessui-dialog-context";
|
||||
|
||||
export function useDialogContext(
|
||||
component: string
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
close(focusableElement: HTMLElement | HTMLElement | null): void;
|
||||
}
|
||||
|
||||
let DISCLOSURE_CONTEXT_NAME = "DisclosureContext";
|
||||
let DISCLOSURE_CONTEXT_NAME = "headlessui-disclosure-context";
|
||||
|
||||
export function useDisclosureContext(
|
||||
component: string
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" context="module">
|
||||
import { getContext, setContext } from "svelte";
|
||||
let DISCLOSURE_PANEL_CONTEXT_NAME = "DisclosurePanelContext";
|
||||
let DISCLOSURE_PANEL_CONTEXT_NAME = "headlessui-disclosure-panel-context";
|
||||
|
||||
export function usePanelContext(): string | undefined {
|
||||
return getContext(DISCLOSURE_PANEL_CONTEXT_NAME);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
labelIds?: string;
|
||||
}
|
||||
|
||||
const LABEL_CONTEXT_NAME = "LabelContext";
|
||||
const LABEL_CONTEXT_NAME = "headlessui-label-context";
|
||||
export function useLabelContext(): Writable<LabelContext> | undefined {
|
||||
return getContext(LABEL_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
select(value: unknown): void;
|
||||
};
|
||||
|
||||
const LISTBOX_CONTEXT_NAME = "ListboxContext";
|
||||
const LISTBOX_CONTEXT_NAME = "headlessui-listbox-context";
|
||||
export function useListboxContext(
|
||||
component: string
|
||||
): Writable<StateDefinition> {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
unregisterItem(id: string): void;
|
||||
};
|
||||
|
||||
const MENU_CONTEXT_NAME = "MenuContext";
|
||||
const MENU_CONTEXT_NAME = "headlessui-menu-context";
|
||||
|
||||
export function useMenuContext(
|
||||
componentName: string
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
close(): void;
|
||||
}
|
||||
|
||||
const POPOVER_CONTEXT_NAME = "PopoverContext";
|
||||
const POPOVER_CONTEXT_NAME = "headlessui-popover-context";
|
||||
export function usePopoverContext(
|
||||
component: string
|
||||
): Writable<StateDefinition> {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
closeOthers(buttonId: string): void;
|
||||
}
|
||||
|
||||
const POPOVER_GROUP_CONTEXT_NAME = "PopoverGroupContext";
|
||||
const POPOVER_GROUP_CONTEXT_NAME = "headlessui-popover-group-context";
|
||||
export function usePopoverGroupContext(): PopoverGroupContext | undefined {
|
||||
return getContext(POPOVER_GROUP_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" context="module">
|
||||
export type PopoverPanelContext = string | null;
|
||||
|
||||
const POPOVER_PANEL_CONTEXT_NAME = "PopoverPanelContext";
|
||||
const POPOVER_PANEL_CONTEXT_NAME = "headlessui-popover-panel-context";
|
||||
export function usePopoverPanelContext():
|
||||
| StateDefinition["panelId"]
|
||||
| undefined {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
unregisterOption(id: Option["id"]): void;
|
||||
}
|
||||
|
||||
const RADIO_GROUP_CONTEXT_NAME = "RadioGroupContext";
|
||||
const RADIO_GROUP_CONTEXT_NAME = "headlessui-radio-group-context";
|
||||
export function useRadioGroupContext(
|
||||
component: string
|
||||
): Writable<StateDefinition> {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
switchStore: Writable<HTMLButtonElement | null>;
|
||||
}
|
||||
|
||||
const SWITCH_CONTEXT_NAME = "SwitchContext";
|
||||
const SWITCH_CONTEXT_NAME = "headlessui-switch-context";
|
||||
export function useSwitchContext(): Writable<StateDefinition> | undefined {
|
||||
return getContext(SWITCH_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
unregisterPanel(panel: string): void;
|
||||
};
|
||||
|
||||
const TABS_CONTEXT_NAME = "TabsContext";
|
||||
const TABS_CONTEXT_NAME = "headlessui-tabs-context";
|
||||
|
||||
export function useTabsContext(component: string): Writable<StateDefinition> {
|
||||
let context: Writable<StateDefinition> | undefined =
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
appear: boolean;
|
||||
}
|
||||
|
||||
const TRANSITION_CONTEXT_NAME = "TransitionContext";
|
||||
export const NESTING_CONTEXT_NAME = "NestingContext";
|
||||
const TRANSITION_CONTEXT_NAME = "headlessui-transition-context";
|
||||
export const NESTING_CONTEXT_NAME = "headlessui-nesting-context";
|
||||
export function hasTransitionContext() {
|
||||
return getContext(TRANSITION_CONTEXT_NAME) !== undefined;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
Add,
|
||||
Remove,
|
||||
}
|
||||
|
||||
const STACK_CONTEXT_NAME = "headlessui-stack-context";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -14,9 +16,9 @@
|
||||
export let element: HTMLElement | null;
|
||||
|
||||
let parentUpdateStore: Writable<OnUpdate> | undefined =
|
||||
getContext("StackContext");
|
||||
getContext(STACK_CONTEXT_NAME);
|
||||
let notifyStore: Writable<OnUpdate> = writable(() => {});
|
||||
setContext("StackContext", notifyStore);
|
||||
setContext(STACK_CONTEXT_NAME, notifyStore);
|
||||
|
||||
$: notifyStore.set((...args: Parameters<OnUpdate>) => {
|
||||
// Notify our layer
|
||||
|
||||
@@ -6,7 +6,7 @@ export enum State {
|
||||
Closed,
|
||||
}
|
||||
|
||||
const OPEN_CLOSED_CONTEXT_NAME = "OpenClosed";
|
||||
const OPEN_CLOSED_CONTEXT_NAME = "headlessui-open-closed-context";
|
||||
export function hasOpenClosed() {
|
||||
return useOpenClosed() !== undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user