@plasmicpkgs/react-aria 0.0.46 → 0.0.47
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/dist/.tsbuildinfo +1 -1
- package/dist/contexts.d.ts +1 -0
- package/dist/react-aria.esm.js +18 -6
- package/dist/react-aria.esm.js.map +1 -1
- package/dist/react-aria.js +18 -6
- package/dist/react-aria.js.map +1 -1
- package/dist/registerSelect.d.ts +3 -3
- package/package.json +2 -2
- package/skinny/{contexts-3a98471a.cjs.js → contexts-0dec6156.cjs.js} +3 -1
- package/skinny/contexts-0dec6156.cjs.js.map +1 -0
- package/skinny/{contexts-87c261f6.esm.js → contexts-9a8234bf.esm.js} +3 -2
- package/skinny/contexts-9a8234bf.esm.js.map +1 -0
- package/skinny/contexts.d.ts +1 -0
- package/skinny/registerCheckbox.cjs.js +1 -1
- package/skinny/registerCheckbox.esm.js +1 -1
- package/skinny/registerCheckboxGroup.cjs.js +1 -1
- package/skinny/registerCheckboxGroup.esm.js +1 -1
- package/skinny/registerComboBox.cjs.js +2 -2
- package/skinny/registerComboBox.esm.js +2 -2
- package/skinny/registerDialogTrigger.cjs.js +1 -1
- package/skinny/registerDialogTrigger.esm.js +1 -1
- package/skinny/registerHeader.cjs.js +1 -1
- package/skinny/registerHeader.esm.js +1 -1
- package/skinny/registerInput.cjs.js +1 -1
- package/skinny/registerInput.esm.js +1 -1
- package/skinny/{registerListBox-9cef735f.cjs.js → registerListBox-5fcac24c.cjs.js} +2 -2
- package/skinny/{registerListBox-9cef735f.cjs.js.map → registerListBox-5fcac24c.cjs.js.map} +1 -1
- package/skinny/{registerListBox-cd96c7f7.esm.js → registerListBox-7472d398.esm.js} +2 -2
- package/skinny/{registerListBox-cd96c7f7.esm.js.map → registerListBox-7472d398.esm.js.map} +1 -1
- package/skinny/registerListBox.cjs.js +2 -2
- package/skinny/registerListBox.esm.js +2 -2
- package/skinny/registerListBoxItem.cjs.js +1 -1
- package/skinny/registerListBoxItem.esm.js +1 -1
- package/skinny/registerModal.cjs.js +1 -1
- package/skinny/registerModal.esm.js +1 -1
- package/skinny/registerPopover.cjs.js +3 -0
- package/skinny/registerPopover.cjs.js.map +1 -1
- package/skinny/registerPopover.esm.js +3 -0
- package/skinny/registerPopover.esm.js.map +1 -1
- package/skinny/registerRadio.cjs.js +1 -1
- package/skinny/registerRadio.esm.js +1 -1
- package/skinny/registerRadioGroup.cjs.js +1 -1
- package/skinny/registerRadioGroup.esm.js +1 -1
- package/skinny/registerSection.cjs.js +1 -1
- package/skinny/registerSection.esm.js +1 -1
- package/skinny/registerSelect.cjs.js +17 -8
- package/skinny/registerSelect.cjs.js.map +1 -1
- package/skinny/registerSelect.d.ts +3 -3
- package/skinny/registerSelect.esm.js +17 -8
- package/skinny/registerSelect.esm.js.map +1 -1
- package/skinny/registerSlider.cjs.js +1 -1
- package/skinny/registerSlider.esm.js +1 -1
- package/skinny/registerSliderThumb.cjs.js +1 -1
- package/skinny/registerSliderThumb.esm.js +1 -1
- package/skinny/registerSliderTrack.cjs.js +1 -1
- package/skinny/registerSliderTrack.esm.js +1 -1
- package/skinny/registerTextArea.cjs.js +1 -1
- package/skinny/registerTextArea.esm.js +1 -1
- package/skinny/registerTextField.cjs.js +1 -1
- package/skinny/registerTextField.esm.js +1 -1
- package/skinny/contexts-3a98471a.cjs.js.map +0 -1
- package/skinny/contexts-87c261f6.esm.js.map +0 -1
package/dist/registerSelect.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Key, SelectValue } from "react-aria-components";
|
|
2
|
+
import { Key, SelectProps, SelectValue } from "react-aria-components";
|
|
3
3
|
import { HasOptions } from "./option-utils";
|
|
4
|
-
import { Registerable
|
|
4
|
+
import { Registerable } from "./utils";
|
|
5
5
|
export interface BaseSelectValueProps extends React.ComponentProps<typeof SelectValue> {
|
|
6
6
|
customize?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare const BaseSelectValue: (props: BaseSelectValueProps) => React.JSX.Element;
|
|
9
|
-
export interface BaseSelectProps<T extends object> extends HasOptions<T>,
|
|
9
|
+
export interface BaseSelectProps<T extends object> extends HasOptions<T>, SelectProps<T> {
|
|
10
10
|
placeholder?: string;
|
|
11
11
|
isDisabled?: boolean;
|
|
12
12
|
value?: Key;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/react-aria",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"description": "Plasmic registration calls for react-aria based components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "b0157ff053e66b6032bbe9ea4b312686a6aeaeeb"
|
|
78
78
|
}
|
|
@@ -12,6 +12,7 @@ const PlasmicRadioGroupContext = React__default.default.createContext(void 0);
|
|
|
12
12
|
const PlasmicDialogTriggerContext = React__default.default.createContext(void 0);
|
|
13
13
|
const PlasmicSliderContext = React__default.default.createContext(void 0);
|
|
14
14
|
React__default.default.createContext(void 0);
|
|
15
|
+
const PlasmicPopoverContext = React__default.default.createContext(void 0);
|
|
15
16
|
const PlasmicListBoxContext = React__default.default.createContext(void 0);
|
|
16
17
|
const PlasmicItemContext = React__default.default.createContext(void 0);
|
|
17
18
|
const PlasmicSectionContext = React__default.default.createContext(void 0);
|
|
@@ -24,8 +25,9 @@ exports.PlasmicHeaderContext = PlasmicHeaderContext;
|
|
|
24
25
|
exports.PlasmicInputContext = PlasmicInputContext;
|
|
25
26
|
exports.PlasmicItemContext = PlasmicItemContext;
|
|
26
27
|
exports.PlasmicListBoxContext = PlasmicListBoxContext;
|
|
28
|
+
exports.PlasmicPopoverContext = PlasmicPopoverContext;
|
|
27
29
|
exports.PlasmicRadioGroupContext = PlasmicRadioGroupContext;
|
|
28
30
|
exports.PlasmicSectionContext = PlasmicSectionContext;
|
|
29
31
|
exports.PlasmicSliderContext = PlasmicSliderContext;
|
|
30
32
|
exports.PlasmicTextFieldContext = PlasmicTextFieldContext;
|
|
31
|
-
//# sourceMappingURL=contexts-
|
|
33
|
+
//# sourceMappingURL=contexts-0dec6156.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts-0dec6156.cjs.js","sources":["../src/contexts.tsx"],"sourcesContent":["import React from \"react\";\nimport type { StrictItemType } from \"./option-utils\";\nimport { BaseCheckboxGroup } from \"./registerCheckboxGroup\";\nimport { BaseDialogTrigger } from \"./registerDialogTrigger\";\nimport type { BaseHeader } from \"./registerHeader\";\nimport type { BaseInput } from \"./registerInput\";\nimport type { BaseLabel } from \"./registerLabel\";\nimport type { BaseListBoxProps } from \"./registerListBox\";\nimport { BasePopover } from \"./registerPopover\";\nimport { BaseRadioGroup } from \"./registerRadioGroup\";\nimport type { BaseSection } from \"./registerSection\";\nimport { BaseSlider } from \"./registerSlider\";\nimport { BaseTextField } from \"./registerTextField\";\n\n// We pass down context props via our own Plasmic*Context instead of directly\n// using react-aria-component's *Context, because react-aria-component's\n// contexts don't \"merge\" with contexts further up the tree, so if we render\n// a context provider, it will just be overwritten by react-aria-component's\n// context provider. So we do the merging within our own Base* components\n// instead.\n\n// Creating the text field context here because input/textarea inside text field receive a null for the TextFieldContext\nexport const PlasmicTextFieldContext = React.createContext<\n React.ComponentProps<typeof BaseTextField> | undefined\n>(undefined);\n\nexport const PlasmicCheckboxGroupContext = React.createContext<\n React.ComponentProps<typeof BaseCheckboxGroup> | undefined\n>(undefined);\n\nexport const PlasmicRadioGroupContext = React.createContext<\n React.ComponentProps<typeof BaseRadioGroup> | undefined\n>(undefined);\n\nexport const PlasmicDialogTriggerContext = React.createContext<\n React.ComponentProps<typeof BaseDialogTrigger> | undefined\n>(undefined);\n\nexport type PlasmicSliderContextType<T extends number | number[]> =\n | React.ComponentProps<typeof BaseSlider<T>>\n | undefined;\n\nexport const PlasmicSliderContext =\n React.createContext<PlasmicSliderContextType<number | number[]>>(undefined);\n\nexport const PlasmicLabelContext = React.createContext<\n React.ComponentProps<typeof BaseLabel> | undefined\n>(undefined);\n\nexport const PlasmicPopoverContext = React.createContext<\n React.ComponentProps<typeof BasePopover> | undefined\n>(undefined);\n\nexport const PlasmicListBoxContext = React.createContext<\n BaseListBoxProps | undefined\n>(undefined);\n\nexport const PlasmicItemContext = React.createContext<\n StrictItemType | undefined\n>(undefined);\n\nexport const PlasmicSectionContext = React.createContext<\n React.ComponentProps<typeof BaseSection> | undefined\n>(undefined);\n\nexport const PlasmicHeaderContext = React.createContext<\n React.ComponentProps<typeof BaseHeader> | undefined\n>(undefined);\n\nexport const PlasmicInputContext = React.createContext<\n React.ComponentProps<typeof BaseInput> | undefined\n>(undefined);\n"],"names":["React"],"mappings":";;;;;;;;AAsBa,MAAA,uBAAA,GAA0BA,sBAAM,CAAA,aAAA,CAE3C,KAAS,CAAA,EAAA;AAEE,MAAA,2BAAA,GAA8BA,sBAAM,CAAA,aAAA,CAE/C,KAAS,CAAA,EAAA;AAEE,MAAA,wBAAA,GAA2BA,sBAAM,CAAA,aAAA,CAE5C,KAAS,CAAA,EAAA;AAEE,MAAA,2BAAA,GAA8BA,sBAAM,CAAA,aAAA,CAE/C,KAAS,CAAA,EAAA;AAME,MAAA,oBAAA,GACXA,sBAAM,CAAA,aAAA,CAA2D,KAAS,CAAA,EAAA;AAEzCA,sBAAM,CAAA,aAAA,CAEvC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwBA,sBAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwBA,sBAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,kBAAA,GAAqBA,sBAAM,CAAA,aAAA,CAEtC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwBA,sBAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,oBAAA,GAAuBA,sBAAM,CAAA,aAAA,CAExC,KAAS,CAAA,EAAA;AAEE,MAAA,mBAAA,GAAsBA,sBAAM,CAAA,aAAA,CAEvC,KAAS,CAAA;;;;;;;;;;;;;;"}
|
|
@@ -6,11 +6,12 @@ const PlasmicRadioGroupContext = React.createContext(void 0);
|
|
|
6
6
|
const PlasmicDialogTriggerContext = React.createContext(void 0);
|
|
7
7
|
const PlasmicSliderContext = React.createContext(void 0);
|
|
8
8
|
React.createContext(void 0);
|
|
9
|
+
const PlasmicPopoverContext = React.createContext(void 0);
|
|
9
10
|
const PlasmicListBoxContext = React.createContext(void 0);
|
|
10
11
|
const PlasmicItemContext = React.createContext(void 0);
|
|
11
12
|
const PlasmicSectionContext = React.createContext(void 0);
|
|
12
13
|
const PlasmicHeaderContext = React.createContext(void 0);
|
|
13
14
|
const PlasmicInputContext = React.createContext(void 0);
|
|
14
15
|
|
|
15
|
-
export { PlasmicCheckboxGroupContext as P, PlasmicListBoxContext as a, PlasmicInputContext as b, PlasmicDialogTriggerContext as c, PlasmicRadioGroupContext as d,
|
|
16
|
-
//# sourceMappingURL=contexts-
|
|
16
|
+
export { PlasmicCheckboxGroupContext as P, PlasmicListBoxContext as a, PlasmicInputContext as b, PlasmicDialogTriggerContext as c, PlasmicRadioGroupContext as d, PlasmicPopoverContext as e, PlasmicSectionContext as f, PlasmicItemContext as g, PlasmicHeaderContext as h, PlasmicSliderContext as i, PlasmicTextFieldContext as j };
|
|
17
|
+
//# sourceMappingURL=contexts-9a8234bf.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts-9a8234bf.esm.js","sources":["../src/contexts.tsx"],"sourcesContent":["import React from \"react\";\nimport type { StrictItemType } from \"./option-utils\";\nimport { BaseCheckboxGroup } from \"./registerCheckboxGroup\";\nimport { BaseDialogTrigger } from \"./registerDialogTrigger\";\nimport type { BaseHeader } from \"./registerHeader\";\nimport type { BaseInput } from \"./registerInput\";\nimport type { BaseLabel } from \"./registerLabel\";\nimport type { BaseListBoxProps } from \"./registerListBox\";\nimport { BasePopover } from \"./registerPopover\";\nimport { BaseRadioGroup } from \"./registerRadioGroup\";\nimport type { BaseSection } from \"./registerSection\";\nimport { BaseSlider } from \"./registerSlider\";\nimport { BaseTextField } from \"./registerTextField\";\n\n// We pass down context props via our own Plasmic*Context instead of directly\n// using react-aria-component's *Context, because react-aria-component's\n// contexts don't \"merge\" with contexts further up the tree, so if we render\n// a context provider, it will just be overwritten by react-aria-component's\n// context provider. So we do the merging within our own Base* components\n// instead.\n\n// Creating the text field context here because input/textarea inside text field receive a null for the TextFieldContext\nexport const PlasmicTextFieldContext = React.createContext<\n React.ComponentProps<typeof BaseTextField> | undefined\n>(undefined);\n\nexport const PlasmicCheckboxGroupContext = React.createContext<\n React.ComponentProps<typeof BaseCheckboxGroup> | undefined\n>(undefined);\n\nexport const PlasmicRadioGroupContext = React.createContext<\n React.ComponentProps<typeof BaseRadioGroup> | undefined\n>(undefined);\n\nexport const PlasmicDialogTriggerContext = React.createContext<\n React.ComponentProps<typeof BaseDialogTrigger> | undefined\n>(undefined);\n\nexport type PlasmicSliderContextType<T extends number | number[]> =\n | React.ComponentProps<typeof BaseSlider<T>>\n | undefined;\n\nexport const PlasmicSliderContext =\n React.createContext<PlasmicSliderContextType<number | number[]>>(undefined);\n\nexport const PlasmicLabelContext = React.createContext<\n React.ComponentProps<typeof BaseLabel> | undefined\n>(undefined);\n\nexport const PlasmicPopoverContext = React.createContext<\n React.ComponentProps<typeof BasePopover> | undefined\n>(undefined);\n\nexport const PlasmicListBoxContext = React.createContext<\n BaseListBoxProps | undefined\n>(undefined);\n\nexport const PlasmicItemContext = React.createContext<\n StrictItemType | undefined\n>(undefined);\n\nexport const PlasmicSectionContext = React.createContext<\n React.ComponentProps<typeof BaseSection> | undefined\n>(undefined);\n\nexport const PlasmicHeaderContext = React.createContext<\n React.ComponentProps<typeof BaseHeader> | undefined\n>(undefined);\n\nexport const PlasmicInputContext = React.createContext<\n React.ComponentProps<typeof BaseInput> | undefined\n>(undefined);\n"],"names":[],"mappings":";;AAsBa,MAAA,uBAAA,GAA0B,KAAM,CAAA,aAAA,CAE3C,KAAS,CAAA,EAAA;AAEE,MAAA,2BAAA,GAA8B,KAAM,CAAA,aAAA,CAE/C,KAAS,CAAA,EAAA;AAEE,MAAA,wBAAA,GAA2B,KAAM,CAAA,aAAA,CAE5C,KAAS,CAAA,EAAA;AAEE,MAAA,2BAAA,GAA8B,KAAM,CAAA,aAAA,CAE/C,KAAS,CAAA,EAAA;AAME,MAAA,oBAAA,GACX,KAAM,CAAA,aAAA,CAA2D,KAAS,CAAA,EAAA;AAEzC,KAAM,CAAA,aAAA,CAEvC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwB,KAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwB,KAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,kBAAA,GAAqB,KAAM,CAAA,aAAA,CAEtC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwB,KAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,oBAAA,GAAuB,KAAM,CAAA,aAAA,CAExC,KAAS,CAAA,EAAA;AAEE,MAAA,mBAAA,GAAsB,KAAM,CAAA,aAAA,CAEvC,KAAS,CAAA;;;;"}
|
package/skinny/contexts.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const PlasmicDialogTriggerContext: React.Context<import("./regist
|
|
|
9
9
|
export type PlasmicSliderContextType<T extends number | number[]> = React.ComponentProps<typeof BaseSlider<T>> | undefined;
|
|
10
10
|
export declare const PlasmicSliderContext: React.Context<PlasmicSliderContextType<number | number[]>>;
|
|
11
11
|
export declare const PlasmicLabelContext: React.Context<(import("react-aria-components").LabelProps & React.RefAttributes<HTMLLabelElement>) | undefined>;
|
|
12
|
+
export declare const PlasmicPopoverContext: React.Context<import("./registerPopover").BasePopoverProps | undefined>;
|
|
12
13
|
export declare const PlasmicListBoxContext: React.Context<BaseListBoxProps | undefined>;
|
|
13
14
|
export declare const PlasmicItemContext: React.Context<StrictItemType | undefined>;
|
|
14
15
|
export declare const PlasmicSectionContext: React.Context<import("./registerSection").BaseSectionProps | undefined>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var reactAriaComponents = require('react-aria-components');
|
|
5
5
|
var common = require('./common-0e83996a.cjs.js');
|
|
6
|
-
var contexts = require('./contexts-
|
|
6
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
7
7
|
var interactionVariantUtils = require('./interaction-variant-utils-36f1b397.cjs.js');
|
|
8
8
|
var utils = require('./utils-d3708034.cjs.js');
|
|
9
9
|
require('@plasmicapp/host/registerComponent');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Checkbox } from 'react-aria-components';
|
|
3
3
|
import { g as getCommonProps, h as hasParent } from './common-e9d84279.esm.js';
|
|
4
|
-
import { P as PlasmicCheckboxGroupContext } from './contexts-
|
|
4
|
+
import { P as PlasmicCheckboxGroupContext } from './contexts-9a8234bf.esm.js';
|
|
5
5
|
import { p as pickAriaComponentVariants } from './interaction-variant-utils-abd0c319.esm.js';
|
|
6
6
|
import { r as registerComponentHelper, a as makeComponentName } from './utils-a1785802.esm.js';
|
|
7
7
|
import '@plasmicapp/host/registerComponent';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var reactAriaComponents = require('react-aria-components');
|
|
5
5
|
var common = require('./common-0e83996a.cjs.js');
|
|
6
|
-
var contexts = require('./contexts-
|
|
6
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
7
7
|
var interactionVariantUtils = require('./interaction-variant-utils-36f1b397.cjs.js');
|
|
8
8
|
var registerCheckbox = require('./registerCheckbox.cjs.js');
|
|
9
9
|
var registerDescription = require('./registerDescription.cjs.js');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CheckboxGroup } from 'react-aria-components';
|
|
3
3
|
import { g as getCommonProps } from './common-e9d84279.esm.js';
|
|
4
|
-
import { P as PlasmicCheckboxGroupContext } from './contexts-
|
|
4
|
+
import { P as PlasmicCheckboxGroupContext } from './contexts-9a8234bf.esm.js';
|
|
5
5
|
import { p as pickAriaComponentVariants } from './interaction-variant-utils-abd0c319.esm.js';
|
|
6
6
|
import { registerCheckbox, makeDefaultCheckboxChildren } from './registerCheckbox.esm.js';
|
|
7
7
|
import { DESCRIPTION_COMPONENT_NAME } from './registerDescription.esm.js';
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var i18n = require('@react-aria/i18n');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
|
-
var contexts = require('./contexts-
|
|
7
|
-
var registerListBox = require('./registerListBox-
|
|
6
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
7
|
+
var registerListBox = require('./registerListBox-5fcac24c.cjs.js');
|
|
8
8
|
var registerButton = require('./registerButton.cjs.js');
|
|
9
9
|
var registerInput = require('./registerInput.cjs.js');
|
|
10
10
|
var registerLabel = require('./registerLabel.cjs.js');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useFilter } from '@react-aria/i18n';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ComboBox, ComboBoxStateContext } from 'react-aria-components';
|
|
4
|
-
import { a as PlasmicListBoxContext, b as PlasmicInputContext } from './contexts-
|
|
5
|
-
import { u as useStrictOptions, f as flattenOptions, m as makeOptionsPropType, a as makeValuePropType, L as LIST_BOX_COMPONENT_NAME } from './registerListBox-
|
|
4
|
+
import { a as PlasmicListBoxContext, b as PlasmicInputContext } from './contexts-9a8234bf.esm.js';
|
|
5
|
+
import { u as useStrictOptions, f as flattenOptions, m as makeOptionsPropType, a as makeValuePropType, L as LIST_BOX_COMPONENT_NAME } from './registerListBox-7472d398.esm.js';
|
|
6
6
|
import { BUTTON_COMPONENT_NAME } from './registerButton.esm.js';
|
|
7
7
|
import { INPUT_COMPONENT_NAME } from './registerInput.esm.js';
|
|
8
8
|
import { LABEL_COMPONENT_NAME } from './registerLabel.esm.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var reactAriaComponents = require('react-aria-components');
|
|
5
|
-
var contexts = require('./contexts-
|
|
5
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
6
6
|
var registerButton = require('./registerButton.cjs.js');
|
|
7
7
|
var registerModal = require('./registerModal.cjs.js');
|
|
8
8
|
var utils = require('./utils-d3708034.cjs.js');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DialogTrigger } from 'react-aria-components';
|
|
3
|
-
import { c as PlasmicDialogTriggerContext } from './contexts-
|
|
3
|
+
import { c as PlasmicDialogTriggerContext } from './contexts-9a8234bf.esm.js';
|
|
4
4
|
import { BUTTON_COMPONENT_NAME } from './registerButton.esm.js';
|
|
5
5
|
import { MODAL_COMPONENT_NAME } from './registerModal.esm.js';
|
|
6
6
|
import { r as registerComponentHelper, a as makeComponentName } from './utils-a1785802.esm.js';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var utils = require('@react-aria/utils');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
|
-
var contexts = require('./contexts-
|
|
6
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
7
7
|
var utils$1 = require('./utils-d3708034.cjs.js');
|
|
8
8
|
require('@plasmicapp/host/registerComponent');
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeProps } from '@react-aria/utils';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Header } from 'react-aria-components';
|
|
4
|
-
import {
|
|
4
|
+
import { h as PlasmicHeaderContext } from './contexts-9a8234bf.esm.js';
|
|
5
5
|
import { r as registerComponentHelper, a as makeComponentName } from './utils-a1785802.esm.js';
|
|
6
6
|
import '@plasmicapp/host/registerComponent';
|
|
7
7
|
|
|
@@ -4,7 +4,7 @@ var React = require('react');
|
|
|
4
4
|
var reactAria = require('react-aria');
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
6
|
var common = require('./common-0e83996a.cjs.js');
|
|
7
|
-
var contexts = require('./contexts-
|
|
7
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
8
8
|
var interactionVariantUtils = require('./interaction-variant-utils-36f1b397.cjs.js');
|
|
9
9
|
var utils = require('./utils-d3708034.cjs.js');
|
|
10
10
|
require('@plasmicapp/host/registerComponent');
|
|
@@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
|
|
|
2
2
|
import { mergeProps } from 'react-aria';
|
|
3
3
|
import { Input } from 'react-aria-components';
|
|
4
4
|
import { r as resolveAutoComplete, g as getCommonProps } from './common-e9d84279.esm.js';
|
|
5
|
-
import {
|
|
5
|
+
import { j as PlasmicTextFieldContext } from './contexts-9a8234bf.esm.js';
|
|
6
6
|
import { p as pickAriaComponentVariants } from './interaction-variant-utils-abd0c319.esm.js';
|
|
7
7
|
import { a as makeComponentName, r as registerComponentHelper } from './utils-a1785802.esm.js';
|
|
8
8
|
import '@plasmicapp/host/registerComponent';
|
|
@@ -4,7 +4,7 @@ var utils = require('@react-aria/utils');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
6
|
var common = require('./common-0e83996a.cjs.js');
|
|
7
|
-
var contexts = require('./contexts-
|
|
7
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
8
8
|
var registerListBoxItem = require('./registerListBoxItem.cjs.js');
|
|
9
9
|
var registerSection = require('./registerSection.cjs.js');
|
|
10
10
|
var utils$1 = require('./utils-d3708034.cjs.js');
|
|
@@ -308,4 +308,4 @@ exports.makeOptionsPropType = makeOptionsPropType;
|
|
|
308
308
|
exports.makeValuePropType = makeValuePropType;
|
|
309
309
|
exports.registerListBox = registerListBox;
|
|
310
310
|
exports.useStrictOptions = useStrictOptions;
|
|
311
|
-
//# sourceMappingURL=registerListBox-
|
|
311
|
+
//# sourceMappingURL=registerListBox-5fcac24c.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBox-9cef735f.cjs.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport { hasParent } from \"./common\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any>,\n HasControlContextData {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, setControlContextData, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n setControlContextData?.({\n parent: isStandalone ? undefined : {},\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: hasParent,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultValue: {\n type: \"component\",\n name: sectionMeta.name,\n styles: {\n backgroundColor: \"#F4FAFF\",\n },\n },\n },\n },\n },\n overrides\n );\n}\n"],"names":["React","_a","PlasmicListBoxContext","mergeProps","ListBox","PlasmicSectionContext","PlasmicItemContext","makeComponentName","registerListBoxItem","registerSection","registerComponentHelper","hasParent","makeDefaultListBoxItemChildren"],"mappings":";;;;;;;;;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAAA,sBAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1B,CAAA;AAEO,SAAS,oBAAsC,KAAsB,EAAA;AAnD5E,EAAA,IAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAA,IAAI,YAAe,GAAA,CAAA,CAAA;AAEnB,EAAM,MAAA,UAAA,GAAa,CAAC,EAAwD,KAAA;AAvD9E,IAAA,IAAAC,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAwDI,IAAA,IAAI,CAAC,EAAI,EAAA;AACP,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,eACE,OAAO,EAAA,KAAO,QAAY,IAAA,OAAO,OAAO,QAAU,EAAA;AAC3D,MAAA,MAAM,IAAO,GAAA;AAAA,QACX,EAAI,EAAA,EAAA;AAAA,OACN,CAAA;AACA,MAAO,OAAA,IAAA,CAAA;AAAA,eACE,UAAY,EAAA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OAAA;AAAA,OACf;AAAA,MACA,KAAO,EAAA;AAAA,QACL,OAAA,EAAS,aACJ,CAAA,cAAA,CAAA,EAAA,EAAA,mBAAA,EADI,CAAA,EAAA;AAAA,UAEP,WAAa,EAAA,OAAA;AAAA,UACb,MAAQ,EAAAC,gBAAA;AAAA,SACV,CAAA;AAAA,QACA,UAAY,EAAA;AAAA,UACV,IAAM,EAAA,MAAA;AAAA,UACN,WAAa,EAAA,aAAA;AAAA,UACb,gBAAA,EAAkB,CAAC,WAAW,CAAA;AAAA,UAC9B,YAAc,EAAA;AAAA,YACZ,IAAM,EAAA,WAAA;AAAA,YACN,MAAM,eAAgB,CAAA,IAAA;AAAA,YACtB,KAAO,EAAA;AAAA,cACL,QAAU,EAAAC,kDAAA;AAAA,gBACR,wBAAA;AAAA,gBACA,uEAAA;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,aAAe,EAAA;AAAA,UACb,IAAM,EAAA,MAAA;AAAA,UACN,WAAa,EAAA,gBAAA;AAAA,UACb,gBAAA,EAAkB,CAAC,cAAc,CAAA;AAAA,UACjC,YAAc,EAAA;AAAA,YACZ,IAAM,EAAA,WAAA;AAAA,YACN,MAAM,WAAY,CAAA,IAAA;AAAA,YAClB,MAAQ,EAAA;AAAA,cACN,eAAiB,EAAA,SAAA;AAAA,aACnB;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"registerListBox-5fcac24c.cjs.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport { hasParent } from \"./common\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any>,\n HasControlContextData {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, setControlContextData, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n setControlContextData?.({\n parent: isStandalone ? undefined : {},\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: hasParent,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultValue: {\n type: \"component\",\n name: sectionMeta.name,\n styles: {\n backgroundColor: \"#F4FAFF\",\n },\n },\n },\n },\n },\n overrides\n );\n}\n"],"names":["React","_a","PlasmicListBoxContext","mergeProps","ListBox","PlasmicSectionContext","PlasmicItemContext","makeComponentName","registerListBoxItem","registerSection","registerComponentHelper","hasParent","makeDefaultListBoxItemChildren"],"mappings":";;;;;;;;;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAAA,sBAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA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A,gBAAA;AAAA,UACb,gBAAA,EAAkB,CAAC,cAAc,CAAA;AAAA,UACjC,YAAc,EAAA;AAAA,YACZ,IAAM,EAAA,WAAA;AAAA,YACN,MAAM,WAAY,CAAA,IAAA;AAAA,YAClB,MAAQ,EAAA;AAAA,cACN,eAAiB,EAAA,SAAA;AAAA,aACnB;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { mergeProps } from '@react-aria/utils';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ListBox } from 'react-aria-components';
|
|
4
4
|
import { h as hasParent } from './common-e9d84279.esm.js';
|
|
5
|
-
import { a as PlasmicListBoxContext,
|
|
5
|
+
import { a as PlasmicListBoxContext, f as PlasmicSectionContext, g as PlasmicItemContext } from './contexts-9a8234bf.esm.js';
|
|
6
6
|
import { registerListBoxItem, makeDefaultListBoxItemChildren } from './registerListBoxItem.esm.js';
|
|
7
7
|
import { registerSection } from './registerSection.esm.js';
|
|
8
8
|
import { a as makeComponentName, r as registerComponentHelper } from './utils-a1785802.esm.js';
|
|
@@ -296,4 +296,4 @@ function registerListBox(loader, overrides) {
|
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
export { BaseListBox as B, LIST_BOX_COMPONENT_NAME as L, makeValuePropType as a, flattenOptions as f, makeOptionsPropType as m, registerListBox as r, useStrictOptions as u };
|
|
299
|
-
//# sourceMappingURL=registerListBox-
|
|
299
|
+
//# sourceMappingURL=registerListBox-7472d398.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBox-cd96c7f7.esm.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport { hasParent } from \"./common\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any>,\n HasControlContextData {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, setControlContextData, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n setControlContextData?.({\n parent: isStandalone ? undefined : {},\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: hasParent,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultValue: {\n type: \"component\",\n name: sectionMeta.name,\n styles: {\n backgroundColor: \"#F4FAFF\",\n },\n },\n },\n },\n },\n overrides\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAA,KAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1B,CAAA;AAEO,SAAS,oBAAsC,KAA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AAA;AAAA,YACZ,IAAM,EAAA,WAAA;AAAA,YACN,MAAM,WAAY,CAAA,IAAA;AAAA,YAClB,MAAQ,EAAA;AAAA,cACN,eAAiB,EAAA,SAAA;AAAA,aACnB;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"registerListBox-7472d398.esm.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport { hasParent } from \"./common\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any>,\n HasControlContextData {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, setControlContextData, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n setControlContextData?.({\n parent: isStandalone ? undefined : {},\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: hasParent,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultVal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A,UACN,WAAa,EAAA,aAAA;AAAA,UACb,gBAAA,EAAkB,CAAC,WAAW,CAAA;AAAA,UAC9B,YAAc,EAAA;AAAA,YACZ,IAAM,EAAA,WAAA;AAAA,YACN,MAAM,eAAgB,CAAA,IAAA;AAAA,YACtB,KAAO,EAAA;AAAA,cACL,QAAU,EAAA,8BAAA;AAAA,gBACR,wBAAA;AAAA,gBACA,uEAAA;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,aAAe,EAAA;AAAA,UACb,IAAM,EAAA,MAAA;AAAA,UACN,WAAa,EAAA,gBAAA;AAAA,UACb,gBAAA,EAAkB,CAAC,cAAc,CAAA;AAAA,UACjC,YAAc,EAAA;AAAA,YACZ,IAAM,EAAA,WAAA;AAAA,YACN,MAAM,WAAY,CAAA,IAAA;AAAA,YAClB,MAAQ,EAAA;AAAA,cACN,eAAiB,EAAA,SAAA;AAAA,aACnB;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -4,8 +4,8 @@ require('@react-aria/utils');
|
|
|
4
4
|
require('react');
|
|
5
5
|
require('react-aria-components');
|
|
6
6
|
require('./common-0e83996a.cjs.js');
|
|
7
|
-
require('./contexts-
|
|
8
|
-
var registerListBox = require('./registerListBox-
|
|
7
|
+
require('./contexts-0dec6156.cjs.js');
|
|
8
|
+
var registerListBox = require('./registerListBox-5fcac24c.cjs.js');
|
|
9
9
|
require('./registerListBoxItem.cjs.js');
|
|
10
10
|
require('./registerSection.cjs.js');
|
|
11
11
|
require('./utils-d3708034.cjs.js');
|
|
@@ -2,8 +2,8 @@ import '@react-aria/utils';
|
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'react-aria-components';
|
|
4
4
|
import './common-e9d84279.esm.js';
|
|
5
|
-
import './contexts-
|
|
6
|
-
export { B as BaseListBox, L as LIST_BOX_COMPONENT_NAME, r as registerListBox } from './registerListBox-
|
|
5
|
+
import './contexts-9a8234bf.esm.js';
|
|
6
|
+
export { B as BaseListBox, L as LIST_BOX_COMPONENT_NAME, r as registerListBox } from './registerListBox-7472d398.esm.js';
|
|
7
7
|
import './registerListBoxItem.esm.js';
|
|
8
8
|
import './registerSection.esm.js';
|
|
9
9
|
import './utils-a1785802.esm.js';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var utils = require('@react-aria/utils');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
|
-
var contexts = require('./contexts-
|
|
6
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
7
7
|
var ErrorBoundary = require('./ErrorBoundary-e9b86248.cjs.js');
|
|
8
8
|
var registerDescription = require('./registerDescription.cjs.js');
|
|
9
9
|
var registerText = require('./registerText.cjs.js');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeProps } from '@react-aria/utils';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ListBoxItem, ListBox } from 'react-aria-components';
|
|
4
|
-
import {
|
|
4
|
+
import { g as PlasmicItemContext } from './contexts-9a8234bf.esm.js';
|
|
5
5
|
import { E as ErrorBoundary } from './ErrorBoundary-c6b111d3.esm.js';
|
|
6
6
|
import { DESCRIPTION_COMPONENT_NAME } from './registerDescription.esm.js';
|
|
7
7
|
import { TEXT_COMPONENT_NAME } from './registerText.esm.js';
|
|
@@ -5,7 +5,7 @@ var React = require('react');
|
|
|
5
5
|
var reactAria = require('react-aria');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
7
|
var common = require('./common-0e83996a.cjs.js');
|
|
8
|
-
var contexts = require('./contexts-
|
|
8
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
9
9
|
var utils = require('./utils-d3708034.cjs.js');
|
|
10
10
|
require('@plasmicapp/host/registerComponent');
|
|
11
11
|
|
|
@@ -3,7 +3,7 @@ import React, { forwardRef, useImperativeHandle } from 'react';
|
|
|
3
3
|
import { mergeProps } from 'react-aria';
|
|
4
4
|
import { Heading, ModalOverlay, Modal, Dialog } from 'react-aria-components';
|
|
5
5
|
import { h as hasParent } from './common-e9d84279.esm.js';
|
|
6
|
-
import { c as PlasmicDialogTriggerContext } from './contexts-
|
|
6
|
+
import { c as PlasmicDialogTriggerContext } from './contexts-9a8234bf.esm.js';
|
|
7
7
|
import { a as makeComponentName, r as registerComponentHelper } from './utils-a1785802.esm.js';
|
|
8
8
|
import '@plasmicapp/host/registerComponent';
|
|
9
9
|
|
|
@@ -4,6 +4,7 @@ var host = require('@plasmicapp/host');
|
|
|
4
4
|
var utils = require('@react-aria/utils');
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
7
8
|
var utils$1 = require('./utils-d3708034.cjs.js');
|
|
8
9
|
require('@plasmicapp/host/registerComponent');
|
|
9
10
|
|
|
@@ -42,12 +43,14 @@ var __objRest = (source, exclude) => {
|
|
|
42
43
|
function BasePopover(props) {
|
|
43
44
|
const _a = props, { resetClassName, setControlContextData } = _a, restProps = __objRest(_a, ["resetClassName", "setControlContextData"]);
|
|
44
45
|
const isStandalone = !React__default.default.useContext(reactAriaComponents.PopoverContext);
|
|
46
|
+
const context = React__default.default.useContext(contexts.PlasmicPopoverContext);
|
|
45
47
|
const isInsideSelect = !!React__default.default.useContext(reactAriaComponents.SelectContext);
|
|
46
48
|
const triggerRef = React__default.default.useRef(null);
|
|
47
49
|
const isEditMode = !!host.usePlasmicCanvasContext();
|
|
48
50
|
const defaultShouldFlip = isInsideSelect ? false : true;
|
|
49
51
|
const mergedProps = utils.mergeProps(
|
|
50
52
|
{ shouldFlip: defaultShouldFlip },
|
|
53
|
+
context,
|
|
51
54
|
/**
|
|
52
55
|
* isNonModal: Whether the popover is non-modal, i.e. elements outside the popover may be interacted with by assistive technologies. *
|
|
53
56
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerPopover.cjs.js","sources":["../src/registerPopover.tsx"],"sourcesContent":["import { PlasmicElement, usePlasmicCanvasContext } from \"@plasmicapp/host\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { Popover, PopoverContext, SelectContext } from \"react-aria-components\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface PopoverControlContextData {\n defaultShouldFlip?: boolean;\n}\n\nexport interface BasePopoverProps\n extends React.ComponentProps<typeof Popover>,\n HasControlContextData<PopoverControlContextData> {\n className?: string;\n resetClassName?: string;\n}\n\nexport function BasePopover(props: BasePopoverProps) {\n const { resetClassName, setControlContextData, ...restProps } = props;\n const isStandalone = !React.useContext(PopoverContext);\n const isInsideSelect = !!React.useContext(SelectContext);\n const triggerRef = React.useRef<any>(null);\n const isEditMode = !!usePlasmicCanvasContext();\n\n // Select/Combobox popovers should not flip by default\n const defaultShouldFlip = isInsideSelect ? false : true;\n\n const mergedProps = mergeProps(\n { shouldFlip: defaultShouldFlip },\n /**\n * isNonModal: Whether the popover is non-modal, i.e. elements outside the popover may be interacted with by assistive technologies. *\n *\n * Setting isNonModal to true in edit mode (canvas) means that the popover will not prevent the user from interacting with the canvas while the popover is open.\n */\n isEditMode ? { isNonModal: true } : null,\n restProps,\n { className: `${resetClassName}` },\n // Override some props if the popover is standalone\n isStandalone\n ? {\n triggerRef,\n isNonModal: true,\n isOpen: true,\n }\n : null\n );\n\n setControlContextData?.({\n defaultShouldFlip,\n });\n\n return (\n <>\n {isStandalone && <div ref={triggerRef} />}\n <Popover {...mergedProps} />\n </>\n );\n}\n\nexport const POPOVER_COMPONENT_NAME = makeComponentName(\"popover\");\nexport const POPOVER_ARROW_IMG: PlasmicElement = {\n type: \"img\",\n // TODO: Replace with the image of an arrow pointing up, like: https://icon-sets.iconify.design/mdi/triangle/\n src: \"https://static1.plasmic.app/arrow-up.svg\",\n styles: {\n position: \"absolute\",\n top: \"-14px\",\n // center the arrow horizontally on the popover\n left: \"50%\",\n transform: \"translateX(-50%)\",\n width: \"15px\",\n },\n};\n\nexport function registerPopover(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BasePopover>\n) {\n registerComponentHelper(\n loader,\n BasePopover,\n {\n name: POPOVER_COMPONENT_NAME,\n displayName: \"Aria Popover\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerPopover\",\n importName: \"BasePopover\",\n defaultStyles: {\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n padding: \"20px\",\n width: \"300px\",\n backgroundColor: \"#FDE3C3\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: [\n POPOVER_ARROW_IMG,\n {\n type: \"vbox\",\n styles: {\n width: \"stretch\",\n padding: 0,\n gap: \"10px\",\n },\n children: [\n {\n type: \"text\",\n value: \"This is a Popover!\",\n },\n {\n type: \"text\",\n value: \"You can put anything you can imagine here!\",\n styles: {\n fontWeight: 500,\n },\n },\n {\n type: \"text\",\n value:\n \"Use it in a `Aria Dialog Trigger` component to trigger it on a button click!\",\n },\n ],\n },\n ],\n },\n offset: {\n type: \"number\",\n displayName: \"Offset\",\n description:\n \"Additional offset applied vertically between the popover and its trigger\",\n defaultValueHint: 0,\n },\n shouldFlip: {\n type: \"boolean\",\n description:\n \"Whether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.\",\n defaultValueHint: (\n _ps: BasePopoverProps,\n ctx: PopoverControlContextData | null\n ) => ctx?.defaultShouldFlip ?? true,\n },\n placement: {\n type: \"choice\",\n description:\n \"Default placement of the popover relative to the trigger, if there is enough space\",\n defaultValueHint: \"bottom\",\n options: [\n \"bottom\",\n \"bottom left\",\n \"bottom right\",\n \"top\",\n \"top left\",\n \"top right\",\n ],\n },\n resetClassName: {\n type: \"themeResetClass\",\n },\n },\n styleSections: true,\n },\n overrides\n );\n}\n"],"names":["React","PopoverContext","SelectContext","usePlasmicCanvasContext","mergeProps","Popover","makeComponentName","registerComponentHelper"],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerPopover.cjs.js","sources":["../src/registerPopover.tsx"],"sourcesContent":["import { PlasmicElement, usePlasmicCanvasContext } from \"@plasmicapp/host\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { Popover, PopoverContext, SelectContext } from \"react-aria-components\";\nimport { PlasmicPopoverContext } from \"./contexts\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface PopoverControlContextData {\n defaultShouldFlip?: boolean;\n}\n\nexport interface BasePopoverProps\n extends React.ComponentProps<typeof Popover>,\n HasControlContextData<PopoverControlContextData> {\n className?: string;\n resetClassName?: string;\n}\n\nexport function BasePopover(props: BasePopoverProps) {\n const { resetClassName, setControlContextData, ...restProps } = props;\n const isStandalone = !React.useContext(PopoverContext);\n const context = React.useContext(PlasmicPopoverContext);\n const isInsideSelect = !!React.useContext(SelectContext);\n const triggerRef = React.useRef<any>(null);\n const isEditMode = !!usePlasmicCanvasContext();\n\n // Select/Combobox popovers should not flip by default\n const defaultShouldFlip = isInsideSelect ? false : true;\n\n const mergedProps = mergeProps(\n { shouldFlip: defaultShouldFlip },\n context,\n /**\n * isNonModal: Whether the popover is non-modal, i.e. elements outside the popover may be interacted with by assistive technologies. *\n *\n * Setting isNonModal to true in edit mode (canvas) means that the popover will not prevent the user from interacting with the canvas while the popover is open.\n */\n isEditMode ? { isNonModal: true } : null,\n restProps,\n { className: `${resetClassName}` },\n // Override some props if the popover is standalone\n isStandalone\n ? {\n triggerRef,\n isNonModal: true,\n isOpen: true,\n }\n : null\n );\n\n setControlContextData?.({\n defaultShouldFlip,\n });\n\n return (\n <>\n {isStandalone && <div ref={triggerRef} />}\n <Popover {...mergedProps} />\n </>\n );\n}\n\nexport const POPOVER_COMPONENT_NAME = makeComponentName(\"popover\");\nexport const POPOVER_ARROW_IMG: PlasmicElement = {\n type: \"img\",\n // TODO: Replace with the image of an arrow pointing up, like: https://icon-sets.iconify.design/mdi/triangle/\n src: \"https://static1.plasmic.app/arrow-up.svg\",\n styles: {\n position: \"absolute\",\n top: \"-14px\",\n // center the arrow horizontally on the popover\n left: \"50%\",\n transform: \"translateX(-50%)\",\n width: \"15px\",\n },\n};\n\nexport function registerPopover(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BasePopover>\n) {\n registerComponentHelper(\n loader,\n BasePopover,\n {\n name: POPOVER_COMPONENT_NAME,\n displayName: \"Aria Popover\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerPopover\",\n importName: \"BasePopover\",\n defaultStyles: {\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n padding: \"20px\",\n width: \"300px\",\n backgroundColor: \"#FDE3C3\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: [\n POPOVER_ARROW_IMG,\n {\n type: \"vbox\",\n styles: {\n width: \"stretch\",\n padding: 0,\n gap: \"10px\",\n },\n children: [\n {\n type: \"text\",\n value: \"This is a Popover!\",\n },\n {\n type: \"text\",\n value: \"You can put anything you can imagine here!\",\n styles: {\n fontWeight: 500,\n },\n },\n {\n type: \"text\",\n value:\n \"Use it in a `Aria Dialog Trigger` component to trigger it on a button click!\",\n },\n ],\n },\n ],\n },\n offset: {\n type: \"number\",\n displayName: \"Offset\",\n description:\n \"Additional offset applied vertically between the popover and its trigger\",\n defaultValueHint: 0,\n },\n shouldFlip: {\n type: \"boolean\",\n description:\n \"Whether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.\",\n defaultValueHint: (\n _ps: BasePopoverProps,\n ctx: PopoverControlContextData | null\n ) => ctx?.defaultShouldFlip ?? true,\n },\n placement: {\n type: \"choice\",\n description:\n \"Default placement of the popover relative to the trigger, if there is enough space\",\n defaultValueHint: \"bottom\",\n options: [\n \"bottom\",\n \"bottom left\",\n \"bottom right\",\n \"top\",\n \"top left\",\n \"top right\",\n ],\n },\n resetClassName: {\n type: \"themeResetClass\",\n },\n },\n styleSections: true,\n },\n overrides\n );\n}\n"],"names":["React","PopoverContext","PlasmicPopoverContext","SelectContext","usePlasmicCanvasContext","mergeProps","Popover","makeComponentName","registerComponentHelper"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAgE,MAAA,EAAA,GAAA,KAAA,EAAxD,kBAAgB,qBAzB1B,EAAA,GAyBkE,IAAd,SAAc,GAAA,SAAA,CAAA,EAAA,EAAd,CAA1C,gBAAgB,EAAA,uBAAA,CAAA,CAAA,CAAA;AACxB,EAAA,MAAM,YAAe,GAAA,CAACA,sBAAM,CAAA,UAAA,CAAWC,kCAAc,CAAA,CAAA;AACrD,EAAM,MAAA,OAAA,GAAUD,sBAAM,CAAA,UAAA,CAAWE,8BAAqB,CAAA,CAAA;AACtD,EAAA,MAAM,cAAiB,GAAA,CAAC,CAACF,sBAAA,CAAM,WAAWG,iCAAa,CAAA,CAAA;AACvD,EAAM,MAAA,UAAA,GAAaH,sBAAM,CAAA,MAAA,CAAY,IAAI,CAAA,CAAA;AACzC,EAAM,MAAA,UAAA,GAAa,CAAC,CAACI,4BAAwB,EAAA,CAAA;AAG7C,EAAM,MAAA,iBAAA,GAAoB,iBAAiB,KAAQ,GAAA,IAAA,CAAA;AAEnD,EAAA,MAAM,WAAc,GAAAC,gBAAA;AAAA,IAClB,EAAE,YAAY,iBAAkB,EAAA;AAAA,IAChC,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,UAAa,GAAA,EAAE,UAAY,EAAA,IAAA,EAAS,GAAA,IAAA;AAAA,IACpC,SAAA;AAAA,IACA,EAAE,SAAW,EAAA,CAAA,EAAG,cAAiB,CAAA,CAAA,EAAA;AAAA;AAAA,IAEjC,YACI,GAAA;AAAA,MACE,UAAA;AAAA,MACA,UAAY,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