@sproutsocial/seeds-react-segmented-control 1.1.24 → 1.1.26
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/esm/index.js +146 -51
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +30 -8
- package/dist/index.d.ts +30 -8
- package/dist/index.js +147 -52
- package/dist/index.js.map +1 -1
- package/dist/segmented-control.css +80 -0
- package/package.json +20 -9
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -4
- package/.turbo/turbo-build.log +0 -21
- package/CHANGELOG.md +0 -339
- package/jest.config.js +0 -9
- package/src/SegmentedControl.stories.tsx +0 -76
- package/src/SegmentedControl.tsx +0 -97
- package/src/SegmentedControlTypes.ts +0 -28
- package/src/__tests__/SegmentedControl.test.tsx +0 -57
- package/src/__tests__/SegmentedControl.typetest.tsx +0 -24
- package/src/index.ts +0 -5
- package/src/styled.d.ts +0 -7
- package/src/styles.ts +0 -121
- package/tsconfig.json +0 -9
- package/tsup.config.ts +0 -12
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/SegmentedControl.tsx","../src/styles.ts","../src/SegmentedControlTypes.ts"],"sourcesContent":["import SegmentedControl from \"./SegmentedControl\";\n\nexport default SegmentedControl;\nexport { SegmentedControl };\nexport * from \"./SegmentedControlTypes\";\n","import * as React from \"react\";\nimport { useState } from \"react\";\nimport * as ToggleGroup from \"@radix-ui/react-toggle-group\";\nimport { SegmentedControlContainer, ToggleButton } from \"./styles\";\nimport type {\n TypeSegmentedControlProps,\n TypeSegmentedControlItemProps,\n} from \"./SegmentedControlTypes\";\n\nlet nameCounter = 0;\nlet idCounter = 0;\n\ninterface TypeSegmentedControlContext {\n name: string;\n selectedValue: string;\n onChange: (e: React.SyntheticEvent<HTMLInputElement>) => void;\n}\n\nconst SegmentedControlContext = React.createContext<\n TypeSegmentedControlContext | null | undefined\n>(null);\n\nconst SegmentedControlItem = ({\n value,\n children,\n disabled,\n ...rest\n}: TypeSegmentedControlItemProps) => {\n return (\n <ToggleGroup.Item value={value} disabled={disabled} asChild>\n <ToggleButton\n // TODO: Discuss dropping these\n // We'd need to keep context, which seems unnecessary now\n // data-segmentedcontrol-isactive={isChecked}\n data-qa-segmentedcontrol-item={value}\n // data-qa-segmentedcontrol-ischecked={isChecked === true}\n disabled={disabled}\n {...rest}\n >\n {children}\n </ToggleButton>\n </ToggleGroup.Item>\n );\n};\n\nconst SegmentedControl = ({\n selectedValue,\n label,\n onChange,\n onValueChange,\n children,\n disabled,\n ...rest\n}: TypeSegmentedControlProps) => {\n const [name] = useState(`Racine-segmented-control-${nameCounter++}`);\n return (\n <ToggleGroup.Root\n className=\"inline-flex space-x-px rounded bg-mauve6 shadow-[0_2px_10px] shadow-blackA4\"\n type=\"single\"\n value={selectedValue}\n aria-label={label}\n disabled={disabled}\n onValueChange={(e) => {\n // Radix allows deselecting a value by clicking on it when it's already selected,\n // but we don't want to allow that behavior in our SegmentedControl.\n if (!e) return;\n\n onValueChange?.(e);\n // Create a mock event to pass to onChange for backwards compatibility.\n // We want to move towards onValueChange, but onChange is used by consumers currently so we need to support both for now.\n const mockEvent = new Event(\"change\", {\n bubbles: true,\n }) as unknown as React.SyntheticEvent<HTMLInputElement>;\n Object.defineProperty(mockEvent, \"target\", { value: { value: e } });\n Object.defineProperty(mockEvent, \"currentTarget\", {\n value: { value: e },\n });\n onChange?.(mockEvent);\n }}\n asChild\n >\n <SegmentedControlContainer\n data-qa-segmentedcontrol={label}\n data-qa-segmentedcontrol-value={selectedValue}\n disabled={disabled}\n {...rest}\n >\n {children}\n </SegmentedControlContainer>\n </ToggleGroup.Root>\n );\n};\n\nSegmentedControlItem.displayName = \"SegmentedControl.Item\";\nSegmentedControl.Item = SegmentedControlItem;\n\nexport default SegmentedControl;\n","import styled, { css } from \"styled-components\";\nimport {\n visuallyHidden,\n focusRing,\n disabled,\n} from \"@sproutsocial/seeds-react-mixins\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Button from \"@sproutsocial/seeds-react-button\";\nimport type {\n TypeSegmentedControlProps,\n TypeSegmentedControlItemProps,\n} from \"./SegmentedControlTypes\";\n\nexport const SegmentedControlContainer = styled(Box)<\n Pick<TypeSegmentedControlProps, \"disabled\">\n>`\n border: 1px solid\n ${(props) => props.theme.colors.button.secondary.border.base};\n border-radius: ${(props) => props.theme.radii.outer};\n padding: ${(props) => props.theme.space[100]};\n display: flex;\n\n ${(props) => props.disabled && disabled}\n`;\n\nexport const ToggleButton = styled(Button)`\n /* To match the height of buttons... 350 padding - 2px top and bottom padding of the parent - 1px border on top and bottom */\n padding: calc(${(props) => props.theme.space[350]} - 6px);\n flex: 1 1 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n border: 0;\n\n & + & {\n margin-left: ${(props) => props.theme.space[100]};\n }\n\n &:hover {\n background-color: ${(props) =>\n props.theme.colors.listItem.background.hover};\n }\n\n &[data-state=\"on\"] {\n color: ${(props) => props.theme.colors.text.inverse};\n background-color: ${(props) =>\n props.theme.colors.listItem.background.selected};\n\n &:hover {\n background-color: ${(props) =>\n props.theme.colors.listItem.background.selected};\n }\n }\n`;\n\nexport const SegmentedControlItemContainer = styled(Box)<\n Pick<TypeSegmentedControlItemProps, \"disabled\">\n>`\n flex: 1 1 auto;\n display: flex;\n cursor: pointer;\n\n & + & {\n margin-left: ${(props) => props.theme.space[100]};\n }\n\n &:focus-within label {\n ${focusRing}\n }\n\n input {\n ${visuallyHidden}\n }\n\n ${(props) => props.disabled && disabled}\n`;\n\ninterface TypeSegmentedControlState {\n isActive: boolean;\n}\n\nexport const SegmentedControlLabel = styled(Button)<TypeSegmentedControlState>`\n flex: 1 1 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n color: ${(props) => props.theme.colors.text.body};\n cursor: pointer;\n font-size: ${(props) => props.theme.typography[200].fontSize};\n /**\n\t* Matches default line height of Icon. Also matches the overall height of\n\t* Input, Select, and Button.\n\t*/\n line-height: 16px;\n font-weight: ${(props) => props.theme.fontWeights.semibold};\n\n border-radius: ${(props) => props.theme.radii.inner};\n /* To match the height of buttons... 350 padding - 2px top and bottom padding of the parent - 1px border on top and bottom */\n padding: calc(${(props) => props.theme.space[350]} - 6px);\n transition: all ${(props) => props.theme.duration.fast};\n\n &:hover {\n background-color: ${(props) =>\n props.theme.colors.listItem.background.hover};\n }\n\n ${(props) =>\n props.isActive &&\n css`\n color: ${(props) => props.theme.colors.text.inverse};\n background-color: ${(props) =>\n props.theme.colors.listItem.background.selected};\n\n &:hover {\n background-color: ${(props) =>\n props.theme.colors.listItem.background.selected};\n }\n `}\n`;\n","import type { TypeContainerProps } from \"@sproutsocial/seeds-react-box\";\nimport * as React from \"react\";\n\nexport interface TypeSegmentedControlItemProps {\n /** The value of this item. Should be unique among sibling items. */\n value: string;\n children: React.ReactNode;\n /** Disables user action and applies a disabled style on the component */\n disabled?: boolean;\n}\n\nexport interface TypeSegmentedControlProps extends TypeContainerProps {\n /** The value of the currently selected item. Should match the value prop of one of the child items */\n selectedValue: string;\n\n /** The title of the segmented control, used for accessibility purposes */\n label: string;\n\n /** Called when the user selects a new item. You can access the value of the newly selected item using \"event.target.value\" */\n onChange?: (e: React.SyntheticEvent<HTMLInputElement>) => void;\n\n /** Called when the user selects a new item. You can access the value of the newly selected item using \"event.target.value\" */\n onValueChange?: (value: string) => void;\n\n /** Disables user action and applies a disabled style on the component */\n disabled?: boolean;\n children: React.ReactNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,mBAAyB;AACzB,kBAA6B;;;ACF7B,+BAA4B;AAC5B,gCAIO;AACP,6BAAgB;AAChB,gCAAmB;AAMZ,IAAM,gCAA4B,yBAAAA,SAAO,uBAAAC,OAAG;AAAA;AAAA,MAI7C,CAAC,UAAU,MAAM,MAAM,OAAO,OAAO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,MAAM;AAGpB,YAAI,CAAC,EAAG;AAER,wBAAgB,CAAC;AAGjB,cAAM,YAAY,IAAI,MAAM,UAAU;AAAA,UACpC,SAAS;AAAA,QACX,CAAC;AACD,eAAO,eAAe,WAAW,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;AAClE,eAAO,eAAe,WAAW,iBAAiB;AAAA,UAChD,OAAO,EAAE,OAAO,EAAE;AAAA,QACpB,CAAC;AACD,mBAAW,SAAS;AAAA,MACtB;AAAA,MACA,SAAO;AAAA,MAEP;AAAA,QAAC;AAAA;AAAA,UACC,4BAA0B;AAAA,UAC1B,kCAAgC;AAAA,UAChC,UAAUA;AAAA,UACT,GAAG;AAAA,UAEH;AAAA;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;AAEA,qBAAqB,cAAc;AACnC,iBAAiB,OAAO;AAExB,IAAO,2BAAQ;;;AE/Ff,IAAAC,SAAuB;;;AHCvB,IAAO,gBAAQ;","names":["styled","Box","Button","props","disabled","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/SegmentedControl.tsx","../src/SegmentedControlHybrid.tsx","../src/styles.ts","../src/SegmentedControlTailwind.tsx","../src/SegmentedControlTypes.ts"],"sourcesContent":["import SegmentedControl from \"./SegmentedControl\";\n\nexport default SegmentedControl;\nexport { SegmentedControl };\nexport * from \"./SegmentedControlTypes\";\n","import * as React from \"react\";\nimport type { TypeSegmentedControlProps } from \"./SegmentedControlTypes\";\nimport SegmentedControlHybrid from \"./SegmentedControlHybrid\";\nimport { SegmentedControlItem } from \"./SegmentedControlTailwind\";\n\ntype TypeSegmentedControlComponent = React.ForwardRefExoticComponent<\n TypeSegmentedControlProps & React.RefAttributes<HTMLDivElement>\n> & {\n Item: typeof SegmentedControlItem;\n};\n\n/**\n * SegmentedControl routes between the Tailwind/CSS-class implementation\n * (preferred) and the legacy styled-components implementation via the hybrid\n * component. This entry file keeps a real component definition (mirroring\n * Button.tsx) so react-docgen's `generate:props-docs` step can discover it and\n * emit prop docs from TypeSegmentedControlProps. styles.ts is left untouched\n * for the styled path.\n */\nconst SegmentedControl = React.forwardRef<\n HTMLDivElement,\n TypeSegmentedControlProps\n>((props, ref) => (\n <SegmentedControlHybrid {...props} ref={ref} />\n)) as TypeSegmentedControlComponent;\n\nSegmentedControl.displayName = \"SegmentedControl\";\nSegmentedControl.Item = SegmentedControlItem;\n\nexport default SegmentedControl;\n","/**\n * Hybrid SegmentedControl Component\n * Automatically chooses between Tailwind and styled-components based on props.\n * Consumers using Box system props (flex, mr, ml, height, ...) or a\n * styled(SegmentedControl) extension keep the styled-components implementation;\n * everyone else gets the faster Tailwind path.\n */\n\nimport * as React from \"react\";\nimport * as ToggleGroup from \"@radix-ui/react-toggle-group\";\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport { SegmentedControlContainer } from \"./styles\";\nimport {\n SegmentedControlTailwind,\n SegmentedControlItem,\n SegmentedControlVariantContext,\n createChangeHandler,\n} from \"./SegmentedControlTailwind\";\nimport type { TypeSegmentedControlProps } from \"./SegmentedControlTypes\";\n\ntype TypeSegmentedControlComponent = React.ForwardRefExoticComponent<\n TypeSegmentedControlProps & React.RefAttributes<HTMLDivElement>\n> & {\n Item: typeof SegmentedControlItem;\n};\n\nconst SegmentedControlHybrid = React.forwardRef<\n HTMLDivElement,\n TypeSegmentedControlProps\n>((props, ref) => {\n const {\n selectedValue,\n label,\n onChange,\n onValueChange,\n children,\n disabled,\n ...rest\n } = props;\n\n if (hasStyledProps(rest)) {\n // Styled-components path: preserves Box system props and\n // styled(SegmentedControl) extensions. Mirrors the original\n // SegmentedControl.tsx body, sharing the change handler with the\n // Tailwind path. The variant provider (outside ToggleGroup.Root so it does\n // not interfere with the asChild prop-merge onto SegmentedControlContainer)\n // makes each child `.Item` render the styled `ToggleButton`, restoring the\n // styled-components item styling that consumers on this path rely on.\n return (\n <SegmentedControlVariantContext.Provider value=\"styled\">\n <ToggleGroup.Root\n className=\"inline-flex space-x-px rounded bg-mauve6 shadow-[0_2px_10px] shadow-blackA4\"\n type=\"single\"\n value={selectedValue}\n aria-label={label}\n disabled={disabled}\n onValueChange={createChangeHandler(onChange, onValueChange)}\n asChild\n >\n <SegmentedControlContainer\n ref={ref}\n data-qa-segmentedcontrol={label}\n data-qa-segmentedcontrol-value={selectedValue}\n disabled={disabled}\n {...rest}\n >\n {children}\n </SegmentedControlContainer>\n </ToggleGroup.Root>\n </SegmentedControlVariantContext.Provider>\n );\n }\n\n // Tailwind path (preferred - better performance)\n return <SegmentedControlTailwind {...props} ref={ref} />;\n}) as TypeSegmentedControlComponent;\n\nSegmentedControlHybrid.displayName = \"SegmentedControl\";\nSegmentedControlHybrid.Item = SegmentedControlItem;\n\nexport default SegmentedControlHybrid;\n","import styled, { css } from \"styled-components\";\nimport {\n visuallyHidden,\n focusRing,\n disabled,\n} from \"@sproutsocial/seeds-react-mixins\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Button from \"@sproutsocial/seeds-react-button\";\nimport type {\n TypeSegmentedControlProps,\n TypeSegmentedControlItemProps,\n} from \"./SegmentedControlTypes\";\n\nexport const SegmentedControlContainer = styled(Box)<\n Pick<TypeSegmentedControlProps, \"disabled\">\n>`\n border: 1px solid\n ${(props) => props.theme.colors.button.secondary.border.base};\n border-radius: ${(props) => props.theme.radii.outer};\n padding: ${(props) => props.theme.space[100]};\n display: flex;\n\n ${(props) => props.disabled && disabled}\n`;\n\nexport const ToggleButton = styled(Button)`\n /* To match the height of buttons... 350 padding - 2px top and bottom padding of the parent - 1px border on top and bottom */\n padding: calc(${(props) => props.theme.space[350]} - 6px);\n flex: 1 1 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n border: 0;\n\n & + & {\n margin-left: ${(props) => props.theme.space[100]};\n }\n\n &:hover {\n background-color: ${(props) =>\n props.theme.colors.listItem.background.hover};\n }\n\n &[data-state=\"on\"] {\n color: ${(props) => props.theme.colors.text.inverse};\n background-color: ${(props) =>\n props.theme.colors.listItem.background.selected};\n\n &:hover {\n background-color: ${(props) =>\n props.theme.colors.listItem.background.selected};\n }\n }\n`;\n\nexport const SegmentedControlItemContainer = styled(Box)<\n Pick<TypeSegmentedControlItemProps, \"disabled\">\n>`\n flex: 1 1 auto;\n display: flex;\n cursor: pointer;\n\n & + & {\n margin-left: ${(props) => props.theme.space[100]};\n }\n\n &:focus-within label {\n ${focusRing}\n }\n\n input {\n ${visuallyHidden}\n }\n\n ${(props) => props.disabled && disabled}\n`;\n\ninterface TypeSegmentedControlState {\n isActive: boolean;\n}\n\nexport const SegmentedControlLabel = styled(Button)<TypeSegmentedControlState>`\n flex: 1 1 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n color: ${(props) => props.theme.colors.text.body};\n cursor: pointer;\n font-size: ${(props) => props.theme.typography[200].fontSize};\n /**\n\t* Matches default line height of Icon. Also matches the overall height of\n\t* Input, Select, and Button.\n\t*/\n line-height: 16px;\n font-weight: ${(props) => props.theme.fontWeights.semibold};\n\n border-radius: ${(props) => props.theme.radii.inner};\n /* To match the height of buttons... 350 padding - 2px top and bottom padding of the parent - 1px border on top and bottom */\n padding: calc(${(props) => props.theme.space[350]} - 6px);\n transition: all ${(props) => props.theme.duration.fast};\n\n &:hover {\n background-color: ${(props) =>\n props.theme.colors.listItem.background.hover};\n }\n\n ${(props) =>\n props.isActive &&\n css`\n color: ${(props) => props.theme.colors.text.inverse};\n background-color: ${(props) =>\n props.theme.colors.listItem.background.selected};\n\n &:hover {\n background-color: ${(props) =>\n props.theme.colors.listItem.background.selected};\n }\n `}\n`;\n","/**\n * Tailwind CSS implementation of SegmentedControl component\n * Uses Seeds segmented-control CSS classes from segmented-control.css\n */\n\nimport * as React from \"react\";\nimport * as ToggleGroup from \"@radix-ui/react-toggle-group\";\nimport { ToggleButton } from \"./styles\";\nimport type {\n TypeSegmentedControlProps,\n TypeSegmentedControlItemProps,\n} from \"./SegmentedControlTypes\";\n\n/**\n * Identifies which rendering path the surrounding SegmentedControl took so the\n * compound `.Item` can match it. The styled-components path renders the legacy\n * styled `ToggleButton` (styled at runtime, no CSS-file dependency); the\n * Tailwind path renders the pure CSS-class button. The Hybrid Root provides\n * \"styled\" on its styled branch; the default is \"tailwind\".\n */\ntype SegmentedControlVariant = \"tailwind\" | \"styled\";\nexport const SegmentedControlVariantContext =\n React.createContext<SegmentedControlVariant>(\"tailwind\");\n\n// Utility for merging class names properly\nfunction cn(\n ...inputs: (string | undefined | null | false | Record<string, boolean>)[]\n): string {\n const classes: string[] = [];\n\n for (const input of inputs) {\n if (!input) continue;\n\n if (typeof input === \"string\") {\n classes.push(input);\n } else if (typeof input === \"object\") {\n for (const [key, value] of Object.entries(input)) {\n if (value) {\n classes.push(key);\n }\n }\n }\n }\n\n return classes.join(\" \");\n}\n\n/**\n * Builds the Radix `onValueChange` handler shared by both the Tailwind and the\n * styled-components paths. Preserves the deselect guard and the synthetic\n * `change` event used for `onChange` backwards compatibility.\n */\nexport function createChangeHandler(\n onChange?: (e: React.SyntheticEvent<HTMLInputElement>) => void,\n onValueChange?: (value: string) => void\n) {\n return (e: string) => {\n // Radix allows deselecting a value by clicking on it when it's already selected,\n // but we don't want to allow that behavior in our SegmentedControl.\n if (!e) return;\n\n onValueChange?.(e);\n // Create a mock event to pass to onChange for backwards compatibility.\n // We want to move towards onValueChange, but onChange is used by consumers\n // currently so we need to support both for now.\n const mockEvent = new Event(\"change\", {\n bubbles: true,\n }) as unknown as React.SyntheticEvent<HTMLInputElement>;\n Object.defineProperty(mockEvent, \"target\", { value: { value: e } });\n Object.defineProperty(mockEvent, \"currentTarget\", {\n value: { value: e },\n });\n onChange?.(mockEvent);\n };\n}\n\n/**\n * Compound item routed to match the surrounding container's path.\n *\n * On the styled-components path it renders the legacy styled `ToggleButton`\n * (styled at runtime by styled-components, with no dependency on the component\n * CSS file) — this preserves backward compatibility for consumers routed to\n * the styled branch via a Box system prop or a `styled(SegmentedControl)`\n * extension. On the Tailwind path it renders the pure CSS-class button. The\n * host element is typed as `any` so Radix's `asChild`-injected props\n * (data-state, role, keyboard handlers, onClick) and any forwarded props\n * spread cleanly — mirrors ButtonTailwind's `Component as any` pattern.\n */\nexport const SegmentedControlItem = ({\n value,\n children,\n disabled,\n ...rest\n}: TypeSegmentedControlItemProps) => {\n const variant = React.useContext(SegmentedControlVariantContext);\n\n if (variant === \"styled\") {\n // `Button` sets its own `type`, so we do not pass `type` here.\n return (\n <ToggleGroup.Item value={value} disabled={disabled} asChild>\n <ToggleButton\n data-qa-segmentedcontrol-item={value}\n disabled={disabled}\n {...rest}\n >\n {children}\n </ToggleButton>\n </ToggleGroup.Item>\n );\n }\n\n const Toggle = \"button\" as any;\n\n return (\n <ToggleGroup.Item value={value} disabled={disabled} asChild>\n <Toggle\n type=\"button\"\n data-qa-segmentedcontrol-item={value}\n disabled={disabled}\n {...rest}\n className=\"seeds-segmented-control-item\"\n >\n {children}\n </Toggle>\n </ToggleGroup.Item>\n );\n};\n\nSegmentedControlItem.displayName = \"SegmentedControl.Item\";\n\nexport const SegmentedControlTailwind = React.forwardRef<\n HTMLDivElement,\n TypeSegmentedControlProps\n>(\n (\n {\n selectedValue,\n label,\n onChange,\n onValueChange,\n children,\n disabled = false,\n className,\n ...rest\n }: TypeSegmentedControlProps,\n ref: React.Ref<HTMLDivElement>\n ) => {\n // Plain <div> container, typed as `any` so the `asChild`-merged className\n // and any forwarded props spread cleanly — mirrors ButtonTailwind.\n const Container = \"div\" as any;\n\n return (\n <ToggleGroup.Root\n className=\"inline-flex space-x-px rounded bg-mauve6 shadow-[0_2px_10px] shadow-blackA4\"\n type=\"single\"\n value={selectedValue}\n aria-label={label}\n disabled={disabled}\n onValueChange={createChangeHandler(onChange, onValueChange)}\n asChild\n >\n <Container\n ref={ref}\n data-qa-segmentedcontrol={label}\n data-qa-segmentedcontrol-value={selectedValue}\n {...rest}\n // className is set last (after {...rest}) and merges any incoming\n // className — Radix Slot merges the Root's className onto this child,\n // and a consumer-provided className must be preserved too.\n className={cn(\n \"seeds-segmented-control\",\n { \"seeds-segmented-control-disabled\": disabled },\n className\n )}\n >\n {children}\n </Container>\n </ToggleGroup.Root>\n );\n }\n);\n\nSegmentedControlTailwind.displayName = \"SegmentedControlTailwind\";\n","import type { TypeContainerProps } from \"@sproutsocial/seeds-react-box\";\nimport * as React from \"react\";\n\nexport interface TypeSegmentedControlItemProps {\n /** The value of this item. Should be unique among sibling items. */\n value: string;\n children: React.ReactNode;\n /** Disables user action and applies a disabled style on the component */\n disabled?: boolean;\n}\n\nexport interface TypeSegmentedControlProps extends TypeContainerProps {\n /** The value of the currently selected item. Should match the value prop of one of the child items */\n selectedValue: string;\n\n /** The title of the segmented control, used for accessibility purposes */\n label: string;\n\n /** Called when the user selects a new item. You can access the value of the newly selected item using \"event.target.value\" */\n onChange?: (e: React.SyntheticEvent<HTMLInputElement>) => void;\n\n /** Called when the user selects a new item. You can access the value of the newly selected item using \"event.target.value\" */\n onValueChange?: (value: string) => void;\n\n /** Disables user action and applies a disabled style on the component */\n disabled?: boolean;\n children: React.ReactNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;;;ACQvB,IAAAC,SAAuB;AACvB,IAAAC,eAA6B;AAC7B,sCAA+B;;;ACV/B,+BAA4B;AAC5B,gCAIO;AACP,6BAAgB;AAChB,gCAAmB;AAMZ,IAAM,gCAA4B,yBAAAC,SAAO,uBAAAC,OAAG;AAAA;AAAA,MAI7C,CAAC,UAAU,MAAM,MAAM,OAAO,OAAO,UAAU,OAAO,IAAI;AAAA,mBAC7C,CAAC,UAAU,MAAM,MAAM,MAAM,KAAK;AAAA,aACxC,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA,IAG1C,CAAC,UAAU,MAAM,YAAY,kCAAQ;AAAA;AAGlC,IAAM,mBAAe,yBAAAD,SAAO,0BAAAE,OAAM;AAAA;AAA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AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAAC;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,UAAI,gDAAe,IAAI,GAAG;AAQxB,WACE,6CAAC,+BAA+B,UAA/B,EAAwC,OAAM,UAC7C;AAAA,MAAa;AAAA,MAAZ;AAAA,QACC,WAAU;AAAA,QACV,MAAK;AAAA,QACL,OAAO;AAAA,QACP,cAAY;AAAA,QACZ,UAAUA;AAAA,QACV,eAAe,oBAAoB,UAAU,aAAa;AAAA,QAC1D,SAAO;AAAA,QAEP;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,4BAA0B;AAAA,YAC1B,kCAAgC;AAAA,YAChC,UAAUA;AAAA,YACT,GAAG;AAAA,YAEH;AAAA;AAAA,QACH;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AAGA,SAAO,6CAAC,4BAA0B,GAAG,OAAO,KAAU;AACxD,CAAC;AAED,uBAAuB,cAAc;AACrC,uBAAuB,OAAO;AAE9B,IAAO,iCAAQ;;;ADzDb,IAAAC,sBAAA;AAJF,IAAM,mBAAyB,kBAG7B,CAAC,OAAO,QACR,6CAAC,kCAAwB,GAAG,OAAO,KAAU,CAC9C;AAED,iBAAiB,cAAc;AAC/B,iBAAiB,OAAO;AAExB,IAAO,2BAAQ;;;AI5Bf,IAAAC,SAAuB;;;ALCvB,IAAO,gBAAQ;","names":["React","React","ToggleGroup","styled","Box","Button","props","disabled","import_jsx_runtime","disabled","import_jsx_runtime","React"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds SegmentedControl component classes
|
|
3
|
+
* Use these instead of writing out individual Tailwind utility classes.
|
|
4
|
+
*
|
|
5
|
+
* Requires @sproutsocial/seeds-react-theme/dist/theme-all.css imported for
|
|
6
|
+
* CSS variable definitions and dark mode support. Dark mode works
|
|
7
|
+
* automatically because the variables below are redefined under
|
|
8
|
+
* [data-theme="dark"] in theme-all.css.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* <div class="seeds-segmented-control">
|
|
12
|
+
* <button class="seeds-segmented-control-item" data-state="on">One</button>
|
|
13
|
+
* <button class="seeds-segmented-control-item" data-state="off">Two</button>
|
|
14
|
+
* </div>
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/* Rules live in the Tailwind `components` cascade layer so that consumer
|
|
18
|
+
utility classes (which Tailwind v4 emits in the later `utilities` layer, or
|
|
19
|
+
unlayered) can override the component's own styles. Without this layer the
|
|
20
|
+
unlayered component rules would always win the cascade and classes like
|
|
21
|
+
`p-300`, `mx-200`, or `inline-flex` could not override them. */
|
|
22
|
+
@layer components {
|
|
23
|
+
.seeds-segmented-control {
|
|
24
|
+
display: flex;
|
|
25
|
+
border: 1px solid var(--color-button-secondary-border-base);
|
|
26
|
+
border-radius: var(--radius-outer);
|
|
27
|
+
padding: var(--space-100);
|
|
28
|
+
font-family: var(--font-family);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.seeds-segmented-control-disabled {
|
|
32
|
+
opacity: 0.4;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.seeds-segmented-control-item {
|
|
37
|
+
flex: 1 1 auto;
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
text-align: center;
|
|
42
|
+
border: 0;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
color: var(--color-text-body);
|
|
45
|
+
background: transparent;
|
|
46
|
+
font-size: var(--font-size-200);
|
|
47
|
+
font-weight: var(--font-weight-semibold);
|
|
48
|
+
/* Matches default line height of Icon. Also matches the overall height of
|
|
49
|
+
Input, Select, and Button. */
|
|
50
|
+
line-height: 16px;
|
|
51
|
+
border-radius: var(--radius-inner);
|
|
52
|
+
/* To match the height of buttons... 350 padding - 2px top and bottom padding
|
|
53
|
+
of the parent - 1px border on top and bottom */
|
|
54
|
+
padding: calc(var(--space-350) - 6px);
|
|
55
|
+
transition: all var(--duration-fast);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.seeds-segmented-control-item + .seeds-segmented-control-item {
|
|
59
|
+
margin-left: var(--space-100);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.seeds-segmented-control-item:hover {
|
|
63
|
+
background-color: var(--color-listItem-bg-hover);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.seeds-segmented-control-item[data-state="on"] {
|
|
67
|
+
color: var(--color-text-inverse);
|
|
68
|
+
background-color: var(--color-listItem-bg-selected);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.seeds-segmented-control-item[data-state="on"]:hover {
|
|
72
|
+
background-color: var(--color-listItem-bg-selected);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.seeds-segmented-control-item:disabled,
|
|
76
|
+
.seeds-segmented-control-item[data-disabled] {
|
|
77
|
+
opacity: 0.4;
|
|
78
|
+
pointer-events: none;
|
|
79
|
+
}
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-segmented-control",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.26",
|
|
4
4
|
"description": "Seeds React SegmentedControl",
|
|
5
5
|
"author": "Sprout Social, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/esm/index.js",
|
|
16
|
+
"require": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./dist/segmented-control.css": "./dist/segmented-control.css"
|
|
20
|
+
},
|
|
10
21
|
"scripts": {
|
|
11
|
-
"build": "tsup --dts",
|
|
12
|
-
"build:debug": "tsup --dts --metafile",
|
|
22
|
+
"build": "tsup --dts && cp src/segmented-control.css dist/segmented-control.css",
|
|
23
|
+
"build:debug": "tsup --dts --metafile && cp src/segmented-control.css dist/segmented-control.css",
|
|
13
24
|
"dev": "tsup --watch --dts",
|
|
14
25
|
"clean": "rm -rf .turbo dist",
|
|
15
26
|
"clean:modules": "rm -rf node_modules",
|
|
@@ -19,12 +30,12 @@
|
|
|
19
30
|
},
|
|
20
31
|
"dependencies": {
|
|
21
32
|
"@radix-ui/react-toggle-group": "^1.0.0",
|
|
22
|
-
"@sproutsocial/seeds-react-theme": "^4.2.
|
|
23
|
-
"@sproutsocial/seeds-react-system-props": "^3.1.
|
|
24
|
-
"@sproutsocial/seeds-react-box": "^1.1.
|
|
25
|
-
"@sproutsocial/seeds-react-button": "^2.2.
|
|
26
|
-
"@sproutsocial/seeds-react-text": "^1.5.
|
|
27
|
-
"@sproutsocial/seeds-react-mixins": "^4.3.
|
|
33
|
+
"@sproutsocial/seeds-react-theme": "^4.2.1",
|
|
34
|
+
"@sproutsocial/seeds-react-system-props": "^3.1.2",
|
|
35
|
+
"@sproutsocial/seeds-react-box": "^1.1.25",
|
|
36
|
+
"@sproutsocial/seeds-react-button": "^2.2.5",
|
|
37
|
+
"@sproutsocial/seeds-react-text": "^1.5.1",
|
|
38
|
+
"@sproutsocial/seeds-react-mixins": "^4.3.10"
|
|
28
39
|
},
|
|
29
40
|
"devDependencies": {
|
|
30
41
|
"@types/react": "^18.0.0",
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
package/.turbo/turbo-build.log
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
yarn run v1.22.22
|
|
2
|
-
$ tsup --dts
|
|
3
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
4
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
|
-
[34mCLI[39m tsup v8.5.0
|
|
6
|
-
[34mCLI[39m Using tsup config: /home/runner/_work/seeds/seeds/seeds-react/seeds-react-segmented-control/tsup.config.ts
|
|
7
|
-
[34mCLI[39m Target: es2022
|
|
8
|
-
[34mCLI[39m Cleaning output folder
|
|
9
|
-
[34mCJS[39m Build start
|
|
10
|
-
[34mESM[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[32m7.11 KB[39m
|
|
12
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m10.59 KB[39m
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in 12ms
|
|
14
|
-
[32mESM[39m [1mdist/esm/index.js [22m[32m4.96 KB[39m
|
|
15
|
-
[32mESM[39m [1mdist/esm/index.js.map [22m[32m10.51 KB[39m
|
|
16
|
-
[32mESM[39m ⚡️ Build success in 12ms
|
|
17
|
-
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in 4325ms
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.66 KB[39m
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.66 KB[39m
|
|
21
|
-
Done in 6.10s.
|
package/CHANGELOG.md
DELETED
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
# @sproutsocial/seeds-react-segmented-control
|
|
2
|
-
|
|
3
|
-
## 1.1.24
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [85f9728]
|
|
8
|
-
- Updated dependencies [fa7d859]
|
|
9
|
-
- @sproutsocial/seeds-react-theme@4.2.0
|
|
10
|
-
- @sproutsocial/seeds-react-box@1.1.23
|
|
11
|
-
- @sproutsocial/seeds-react-mixins@4.3.9
|
|
12
|
-
- @sproutsocial/seeds-react-button@2.2.3
|
|
13
|
-
|
|
14
|
-
## 1.1.23
|
|
15
|
-
|
|
16
|
-
### Patch Changes
|
|
17
|
-
|
|
18
|
-
- Updated dependencies [65b5879]
|
|
19
|
-
- @sproutsocial/seeds-react-text@1.5.0
|
|
20
|
-
|
|
21
|
-
## 1.1.22
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- Updated dependencies [a13a571]
|
|
26
|
-
- @sproutsocial/seeds-react-theme@4.1.1
|
|
27
|
-
- @sproutsocial/seeds-react-box@1.1.22
|
|
28
|
-
- @sproutsocial/seeds-react-mixins@4.3.8
|
|
29
|
-
- @sproutsocial/seeds-react-button@2.2.2
|
|
30
|
-
|
|
31
|
-
## 1.1.21
|
|
32
|
-
|
|
33
|
-
### Patch Changes
|
|
34
|
-
|
|
35
|
-
- @sproutsocial/seeds-react-button@2.2.1
|
|
36
|
-
|
|
37
|
-
## 1.1.20
|
|
38
|
-
|
|
39
|
-
### Patch Changes
|
|
40
|
-
|
|
41
|
-
- Updated dependencies [edc1819]
|
|
42
|
-
- @sproutsocial/seeds-react-text@1.4.3
|
|
43
|
-
|
|
44
|
-
## 1.1.19
|
|
45
|
-
|
|
46
|
-
### Patch Changes
|
|
47
|
-
|
|
48
|
-
- Updated dependencies [456a20f]
|
|
49
|
-
- Updated dependencies [5892f44]
|
|
50
|
-
- @sproutsocial/seeds-react-button@2.2.0
|
|
51
|
-
- @sproutsocial/seeds-react-system-props@3.1.1
|
|
52
|
-
- @sproutsocial/seeds-react-box@1.1.21
|
|
53
|
-
- @sproutsocial/seeds-react-text@1.4.2
|
|
54
|
-
|
|
55
|
-
## 1.1.18
|
|
56
|
-
|
|
57
|
-
### Patch Changes
|
|
58
|
-
|
|
59
|
-
- Updated dependencies [5114a32]
|
|
60
|
-
- Updated dependencies [a0fe3d3]
|
|
61
|
-
- @sproutsocial/seeds-react-theme@4.1.0
|
|
62
|
-
- @sproutsocial/seeds-react-button@2.1.3
|
|
63
|
-
- @sproutsocial/seeds-react-box@1.1.20
|
|
64
|
-
- @sproutsocial/seeds-react-mixins@4.3.7
|
|
65
|
-
|
|
66
|
-
## 1.1.17
|
|
67
|
-
|
|
68
|
-
### Patch Changes
|
|
69
|
-
|
|
70
|
-
- Updated dependencies [cb27f07]
|
|
71
|
-
- @sproutsocial/seeds-react-button@2.1.2
|
|
72
|
-
|
|
73
|
-
## 1.1.16
|
|
74
|
-
|
|
75
|
-
### Patch Changes
|
|
76
|
-
|
|
77
|
-
- Updated dependencies [40d2dfe]
|
|
78
|
-
- @sproutsocial/seeds-react-button@2.1.1
|
|
79
|
-
|
|
80
|
-
## 1.1.15
|
|
81
|
-
|
|
82
|
-
### Patch Changes
|
|
83
|
-
|
|
84
|
-
- Updated dependencies [132ef9d]
|
|
85
|
-
- Updated dependencies [132ef9d]
|
|
86
|
-
- Updated dependencies [132ef9d]
|
|
87
|
-
- @sproutsocial/seeds-react-button@2.1.0
|
|
88
|
-
- @sproutsocial/seeds-react-theme@4.0.0
|
|
89
|
-
- @sproutsocial/seeds-react-system-props@3.1.0
|
|
90
|
-
- @sproutsocial/seeds-react-box@1.1.19
|
|
91
|
-
- @sproutsocial/seeds-react-mixins@4.3.6
|
|
92
|
-
- @sproutsocial/seeds-react-text@1.4.1
|
|
93
|
-
|
|
94
|
-
## 1.1.14
|
|
95
|
-
|
|
96
|
-
### Patch Changes
|
|
97
|
-
|
|
98
|
-
- @sproutsocial/seeds-react-button@2.0.8
|
|
99
|
-
|
|
100
|
-
## 1.1.13
|
|
101
|
-
|
|
102
|
-
### Patch Changes
|
|
103
|
-
|
|
104
|
-
- Updated dependencies [47c62b3]
|
|
105
|
-
- @sproutsocial/seeds-react-theme@3.7.1
|
|
106
|
-
- @sproutsocial/seeds-react-box@1.1.18
|
|
107
|
-
- @sproutsocial/seeds-react-mixins@4.3.5
|
|
108
|
-
- @sproutsocial/seeds-react-button@2.0.7
|
|
109
|
-
|
|
110
|
-
## 1.1.12
|
|
111
|
-
|
|
112
|
-
### Patch Changes
|
|
113
|
-
|
|
114
|
-
- Updated dependencies [06da9c2]
|
|
115
|
-
- @sproutsocial/seeds-react-theme@3.7.0
|
|
116
|
-
- @sproutsocial/seeds-react-box@1.1.17
|
|
117
|
-
- @sproutsocial/seeds-react-mixins@4.3.4
|
|
118
|
-
- @sproutsocial/seeds-react-button@2.0.6
|
|
119
|
-
|
|
120
|
-
## 1.1.11
|
|
121
|
-
|
|
122
|
-
### Patch Changes
|
|
123
|
-
|
|
124
|
-
- @sproutsocial/seeds-react-button@2.0.5
|
|
125
|
-
|
|
126
|
-
## 1.1.10
|
|
127
|
-
|
|
128
|
-
### Patch Changes
|
|
129
|
-
|
|
130
|
-
- @sproutsocial/seeds-react-button@2.0.4
|
|
131
|
-
|
|
132
|
-
## 1.1.9
|
|
133
|
-
|
|
134
|
-
### Patch Changes
|
|
135
|
-
|
|
136
|
-
- @sproutsocial/seeds-react-button@2.0.3
|
|
137
|
-
|
|
138
|
-
## 1.1.8
|
|
139
|
-
|
|
140
|
-
### Patch Changes
|
|
141
|
-
|
|
142
|
-
- @sproutsocial/seeds-react-button@2.0.2
|
|
143
|
-
|
|
144
|
-
## 1.1.7
|
|
145
|
-
|
|
146
|
-
### Patch Changes
|
|
147
|
-
|
|
148
|
-
- @sproutsocial/seeds-react-button@2.0.1
|
|
149
|
-
|
|
150
|
-
## 1.1.6
|
|
151
|
-
|
|
152
|
-
### Patch Changes
|
|
153
|
-
|
|
154
|
-
- Updated dependencies [4ba8720]
|
|
155
|
-
- Updated dependencies [df9d751]
|
|
156
|
-
- @sproutsocial/seeds-react-theme@3.6.2
|
|
157
|
-
- @sproutsocial/seeds-react-button@2.0.0
|
|
158
|
-
- @sproutsocial/seeds-react-mixins@4.3.3
|
|
159
|
-
- @sproutsocial/seeds-react-box@1.1.16
|
|
160
|
-
|
|
161
|
-
## 1.1.5
|
|
162
|
-
|
|
163
|
-
### Patch Changes
|
|
164
|
-
|
|
165
|
-
- Updated dependencies [1f9a473]
|
|
166
|
-
- @sproutsocial/seeds-react-theme@3.6.1
|
|
167
|
-
- @sproutsocial/seeds-react-box@1.1.15
|
|
168
|
-
- @sproutsocial/seeds-react-mixins@4.3.2
|
|
169
|
-
- @sproutsocial/seeds-react-button@1.4.3
|
|
170
|
-
|
|
171
|
-
## 1.1.4
|
|
172
|
-
|
|
173
|
-
### Patch Changes
|
|
174
|
-
|
|
175
|
-
- @sproutsocial/seeds-react-button@1.4.2
|
|
176
|
-
|
|
177
|
-
## 1.1.3
|
|
178
|
-
|
|
179
|
-
### Patch Changes
|
|
180
|
-
|
|
181
|
-
- @sproutsocial/seeds-react-button@1.4.1
|
|
182
|
-
|
|
183
|
-
## 1.1.2
|
|
184
|
-
|
|
185
|
-
### Patch Changes
|
|
186
|
-
|
|
187
|
-
- 9280f81: Remove unintentional label
|
|
188
|
-
|
|
189
|
-
## 1.1.1
|
|
190
|
-
|
|
191
|
-
### Patch Changes
|
|
192
|
-
|
|
193
|
-
- 598356f: Correct SegmentedControl to always have a value
|
|
194
|
-
|
|
195
|
-
## 1.1.0
|
|
196
|
-
|
|
197
|
-
### Minor Changes
|
|
198
|
-
|
|
199
|
-
- 1f356b4: Correct SegmentedControll accessibility, switch to radix, introduce simpler onValueChange callback
|
|
200
|
-
|
|
201
|
-
## 1.0.15
|
|
202
|
-
|
|
203
|
-
### Patch Changes
|
|
204
|
-
|
|
205
|
-
- Updated dependencies [17d4f12]
|
|
206
|
-
- @sproutsocial/seeds-react-theme@3.6.0
|
|
207
|
-
- @sproutsocial/seeds-react-box@1.1.14
|
|
208
|
-
- @sproutsocial/seeds-react-mixins@4.3.1
|
|
209
|
-
|
|
210
|
-
## 1.0.14
|
|
211
|
-
|
|
212
|
-
### Patch Changes
|
|
213
|
-
|
|
214
|
-
- Updated dependencies [5bb63e1]
|
|
215
|
-
- @sproutsocial/seeds-react-mixins@4.3.0
|
|
216
|
-
|
|
217
|
-
## 1.0.13
|
|
218
|
-
|
|
219
|
-
### Patch Changes
|
|
220
|
-
|
|
221
|
-
- Updated dependencies [118e300]
|
|
222
|
-
- @sproutsocial/seeds-react-theme@3.5.1
|
|
223
|
-
- @sproutsocial/seeds-react-box@1.1.13
|
|
224
|
-
- @sproutsocial/seeds-react-mixins@4.2.5
|
|
225
|
-
|
|
226
|
-
## 1.0.12
|
|
227
|
-
|
|
228
|
-
### Patch Changes
|
|
229
|
-
|
|
230
|
-
- Updated dependencies [db6ce39]
|
|
231
|
-
- Updated dependencies [20bb01b]
|
|
232
|
-
- @sproutsocial/seeds-react-theme@3.5.0
|
|
233
|
-
- @sproutsocial/seeds-react-box@1.1.12
|
|
234
|
-
- @sproutsocial/seeds-react-mixins@4.2.4
|
|
235
|
-
|
|
236
|
-
## 1.0.11
|
|
237
|
-
|
|
238
|
-
### Patch Changes
|
|
239
|
-
|
|
240
|
-
- Updated dependencies [29ced53]
|
|
241
|
-
- @sproutsocial/seeds-react-text@1.4.0
|
|
242
|
-
|
|
243
|
-
## 1.0.10
|
|
244
|
-
|
|
245
|
-
### Patch Changes
|
|
246
|
-
|
|
247
|
-
- Updated dependencies [7716e16]
|
|
248
|
-
- @sproutsocial/seeds-react-theme@3.4.0
|
|
249
|
-
- @sproutsocial/seeds-react-box@1.1.11
|
|
250
|
-
- @sproutsocial/seeds-react-mixins@4.2.3
|
|
251
|
-
|
|
252
|
-
## 1.0.9
|
|
253
|
-
|
|
254
|
-
### Patch Changes
|
|
255
|
-
|
|
256
|
-
- @sproutsocial/seeds-react-theme@3.3.2
|
|
257
|
-
- @sproutsocial/seeds-react-box@1.1.10
|
|
258
|
-
- @sproutsocial/seeds-react-mixins@4.2.2
|
|
259
|
-
|
|
260
|
-
## 1.0.8
|
|
261
|
-
|
|
262
|
-
### Patch Changes
|
|
263
|
-
|
|
264
|
-
- @sproutsocial/seeds-react-theme@3.3.1
|
|
265
|
-
- @sproutsocial/seeds-react-box@1.1.9
|
|
266
|
-
- @sproutsocial/seeds-react-mixins@4.2.1
|
|
267
|
-
|
|
268
|
-
## 1.0.7
|
|
269
|
-
|
|
270
|
-
### Patch Changes
|
|
271
|
-
|
|
272
|
-
- Updated dependencies [750d1ea]
|
|
273
|
-
- @sproutsocial/seeds-react-mixins@4.2.0
|
|
274
|
-
- @sproutsocial/seeds-react-theme@3.3.0
|
|
275
|
-
- @sproutsocial/seeds-react-box@1.1.8
|
|
276
|
-
|
|
277
|
-
## 1.0.6
|
|
278
|
-
|
|
279
|
-
### Patch Changes
|
|
280
|
-
|
|
281
|
-
- Updated dependencies [fa7579a]
|
|
282
|
-
- @sproutsocial/seeds-react-theme@3.2.1
|
|
283
|
-
- @sproutsocial/seeds-react-box@1.1.7
|
|
284
|
-
- @sproutsocial/seeds-react-mixins@4.1.6
|
|
285
|
-
|
|
286
|
-
## 1.0.5
|
|
287
|
-
|
|
288
|
-
### Patch Changes
|
|
289
|
-
|
|
290
|
-
- Updated dependencies [8f6ba8d]
|
|
291
|
-
- @sproutsocial/seeds-react-theme@3.2.0
|
|
292
|
-
- @sproutsocial/seeds-react-box@1.1.6
|
|
293
|
-
- @sproutsocial/seeds-react-mixins@4.1.5
|
|
294
|
-
|
|
295
|
-
## 1.0.4
|
|
296
|
-
|
|
297
|
-
### Patch Changes
|
|
298
|
-
|
|
299
|
-
- Updated dependencies [b1c3b44]
|
|
300
|
-
- @sproutsocial/seeds-react-theme@3.1.1
|
|
301
|
-
- @sproutsocial/seeds-react-box@1.1.5
|
|
302
|
-
- @sproutsocial/seeds-react-mixins@4.1.4
|
|
303
|
-
|
|
304
|
-
## 1.0.3
|
|
305
|
-
|
|
306
|
-
### Patch Changes
|
|
307
|
-
|
|
308
|
-
- Updated dependencies [47580c4]
|
|
309
|
-
- @sproutsocial/seeds-react-theme@3.1.0
|
|
310
|
-
- @sproutsocial/seeds-react-box@1.1.4
|
|
311
|
-
- @sproutsocial/seeds-react-mixins@4.1.3
|
|
312
|
-
|
|
313
|
-
## 1.0.2
|
|
314
|
-
|
|
315
|
-
### Patch Changes
|
|
316
|
-
|
|
317
|
-
- Updated dependencies [22e1111]
|
|
318
|
-
- @sproutsocial/seeds-react-text@1.3.2
|
|
319
|
-
- @sproutsocial/seeds-react-theme@3.0.1
|
|
320
|
-
- @sproutsocial/seeds-react-box@1.1.3
|
|
321
|
-
- @sproutsocial/seeds-react-mixins@4.1.2
|
|
322
|
-
|
|
323
|
-
## 1.0.1
|
|
324
|
-
|
|
325
|
-
### Patch Changes
|
|
326
|
-
|
|
327
|
-
- 9fd8bac: Update dependencies to use semantic package version instead of wildcards
|
|
328
|
-
- Updated dependencies [9fd8bac]
|
|
329
|
-
- @sproutsocial/seeds-react-system-props@3.0.2
|
|
330
|
-
- @sproutsocial/seeds-react-mixins@4.1.1
|
|
331
|
-
- @sproutsocial/seeds-react-theme@2.2.1
|
|
332
|
-
- @sproutsocial/seeds-react-text@1.3.1
|
|
333
|
-
- @sproutsocial/seeds-react-box@1.1.2
|
|
334
|
-
|
|
335
|
-
## 1.0.0
|
|
336
|
-
|
|
337
|
-
### Major Changes
|
|
338
|
-
|
|
339
|
-
- d480e33: Migrated SegmentedControl to its own seeds-react-segmented-control
|
package/jest.config.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
-
import Box from "@sproutsocial/seeds-react-box";
|
|
4
|
-
import Button from "@sproutsocial/seeds-react-button";
|
|
5
|
-
import SegmentedControl from "./SegmentedControl";
|
|
6
|
-
|
|
7
|
-
const meta: Meta<typeof SegmentedControl> = {
|
|
8
|
-
title: "Components/SegmentedControl",
|
|
9
|
-
component: SegmentedControl,
|
|
10
|
-
};
|
|
11
|
-
export default meta;
|
|
12
|
-
|
|
13
|
-
type Story = StoryObj<typeof SegmentedControl>;
|
|
14
|
-
|
|
15
|
-
// @ts-ignore IDK what props should be
|
|
16
|
-
const StatefulSegmentedControl = (props) => {
|
|
17
|
-
const [value, setValue] = useState("1");
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<SegmentedControl
|
|
21
|
-
selectedValue={value}
|
|
22
|
-
label="Segmented control component"
|
|
23
|
-
onChange={(e) => {
|
|
24
|
-
console.log(e);
|
|
25
|
-
setValue((e.target as HTMLInputElement).value);
|
|
26
|
-
}}
|
|
27
|
-
{...props}
|
|
28
|
-
>
|
|
29
|
-
<SegmentedControl.Item value="1">Test 1</SegmentedControl.Item>
|
|
30
|
-
<SegmentedControl.Item value="2">Test 2</SegmentedControl.Item>
|
|
31
|
-
<SegmentedControl.Item value="3">Test 3</SegmentedControl.Item>
|
|
32
|
-
</SegmentedControl>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const Default: Story = {
|
|
37
|
-
render: () => (
|
|
38
|
-
<Box width={1 / 3} display="flex" alignItems="center" minWidth="25%">
|
|
39
|
-
<StatefulSegmentedControl flex="1" mr={300} />
|
|
40
|
-
<Button appearance="secondary">Some button</Button>
|
|
41
|
-
</Box>
|
|
42
|
-
),
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const Disabled: Story = {
|
|
46
|
-
render: () => (
|
|
47
|
-
<Box width={1 / 3} display="flex" alignItems="center" minWidth="25%">
|
|
48
|
-
<StatefulSegmentedControl flex="1" mr={300} disabled={true} />
|
|
49
|
-
<Button appearance="secondary">Some button</Button>
|
|
50
|
-
</Box>
|
|
51
|
-
),
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const DisabledItem: Story = {
|
|
55
|
-
render: () => {
|
|
56
|
-
const [value, setValue] = useState("1");
|
|
57
|
-
return (
|
|
58
|
-
<Box width={1 / 3} display="flex" alignItems="center" minWidth="25%">
|
|
59
|
-
<SegmentedControl
|
|
60
|
-
selectedValue={value}
|
|
61
|
-
label="Segmented control component"
|
|
62
|
-
onValueChange={setValue}
|
|
63
|
-
flex="1"
|
|
64
|
-
>
|
|
65
|
-
<SegmentedControl.Item value="1">Test 1</SegmentedControl.Item>
|
|
66
|
-
<SegmentedControl.Item value="2" disabled={true}>
|
|
67
|
-
Test 2
|
|
68
|
-
</SegmentedControl.Item>
|
|
69
|
-
<SegmentedControl.Item value="3">Test 3</SegmentedControl.Item>
|
|
70
|
-
<SegmentedControl.Item value="4">Test 4</SegmentedControl.Item>
|
|
71
|
-
<SegmentedControl.Item value="5">Test 5</SegmentedControl.Item>
|
|
72
|
-
</SegmentedControl>
|
|
73
|
-
</Box>
|
|
74
|
-
);
|
|
75
|
-
},
|
|
76
|
-
};
|