` is now gone and `.spectrum-FieldButton` is no longer used. Instead, the outer tag is now `
`;
};
+/**
+ * Picker template including adjacent popover and help text.
+ */
export const Template = ({
rootClass = "spectrum-Picker",
size = "m",
label,
labelPosition = "top",
- placeholder,
- helpText,
+ placeholder = "",
+ currentValue = "",
+ helpText = "",
isQuiet = false,
isKeyboardFocused = false,
+ showWorkflowIcon = false,
isOpen = false,
isInvalid = false,
isLoading = false,
isDisabled = false,
isReadOnly = false,
+ isHovered = false,
+ isActive = false,
withSwitch = false,
fieldLabelStyle = {},
customClasses = [],
customStyles = {},
- content = [],
+ popoverContent = [],
id = getRandomId("picker"),
} = {}, context = {}) => {
const { updateArgs } = context;
- let iconName = "ChevronDown200";
- switch (size) {
- case "s":
- iconName = "ChevronDown75";
- break;
- case "m":
- iconName = "ChevronDown100";
- break;
- case "xl":
- iconName = "ChevronDown300";
- break;
- default:
- iconName = "ChevronDown200";
- }
-
return html`
${when(label, () =>
FieldLabel({
@@ -117,7 +136,7 @@ export const Template = ({
label,
isDisabled,
customStyles: fieldLabelStyle,
- alignment: labelPosition,
+ alignment: labelPosition === "side" ? "left" : undefined,
}, context)
)}
${Popover({
@@ -129,27 +148,26 @@ export const Template = ({
rootClass,
size,
placeholder,
+ currentValue,
isQuiet,
+ showWorkflowIcon,
isKeyboardFocused,
isOpen,
isInvalid,
isLoading,
isDisabled,
isReadOnly,
+ isHovered,
+ isActive,
customClasses,
- customStyles: {
- "display": labelPosition == "left" ? "inline-block" : undefined,
- ...customStyles,
- },
- content,
- iconName,
+ customStyles,
labelPosition,
id,
onclick: function() {
updateArgs({ isOpen: !isOpen });
},
}, context),
- content,
+ content: popoverContent,
}, context)}
${when(helpText, () =>
HelpText({
@@ -158,12 +176,65 @@ export const Template = ({
hideIcon: true,
}, context)
)}
- ${when(withSwitch, () => Switch({
- size,
- label: "Toggle switch",
- customStyles: {
- "padding-inline-start": "15px"
- }
- }, context))}
+ ${when(withSwitch, () =>
+ Switch({
+ size,
+ label: "Toggle switch",
+ customStyles: {
+ "padding-inline-start": "15px"
+ }
+ }, context)
+ )}
`;
};
+
+/**
+ * Template showing both closed and open versions of the Picker.
+ */
+export const ClosedAndOpenTemplate = (args, context) => Container({
+ withBorder: false,
+ content: html`${[false, true].map((isOpen) =>
+ Container({
+ withBorder: false,
+ direction: "column",
+ heading: isOpen ? "Open" : "Closed",
+ containerStyles: {
+ rowGap: "8px",
+ },
+ // Make sure container flex layout does not misalign sibling elements such as field label in Template()
+ wrapperStyles: {
+ display: "block",
+ },
+ content: Template({
+ ...args,
+ isOpen,
+ }, context),
+ })
+ )}`,
+});
+
+/**
+ * Template for the Disabled docs story.
+ */
+export const DisabledTemplate = (args, context) => Container({
+ withBorder: false,
+ content: html`${[false, true].map((isInvalid) =>
+ Container({
+ withBorder: false,
+ direction: "column",
+ heading: isInvalid ? "Invalid" : "Default",
+ containerStyles: {
+ rowGap: "8px",
+ overflow: "hidden",
+ },
+ // Make sure container flex layout does not misalign sibling elements such as field label in Template()
+ wrapperStyles: {
+ display: "block",
+ },
+ content: Template({
+ ...args,
+ isInvalid,
+ }, context),
+ })
+ )}`,
+});
\ No newline at end of file
diff --git a/components/tabs/stories/template.js b/components/tabs/stories/template.js
index 17c6a3e2585..2e5c4ee6d45 100644
--- a/components/tabs/stories/template.js
+++ b/components/tabs/stories/template.js
@@ -124,7 +124,7 @@ export const Template = ({
customPopoverStyles: {
insetBlockStart: "24px",
},
- content: [
+ popoverContent: [
() => Menu({
selectionMode: "none",
size,