UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

62 lines (61 loc) 3.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Expandable = exports.expandableContainerStencil = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const common_1 = require("@workday/canvas-kit-react/common"); const layout_1 = require("@workday/canvas-kit-react/layout"); const ExpandableContent_1 = require("./ExpandableContent"); const ExpandableTarget_1 = require("./ExpandableTarget"); const ExpandableIcon_1 = require("./ExpandableIcon"); const ExpandableTitle_1 = require("./ExpandableTitle"); const ExpandableAvatar_1 = require("./ExpandableAvatar"); const useExpandableModel_1 = require("./hooks/useExpandableModel"); const canvas_kit_styling_1 = require("@workday/canvas-kit-styling"); const canvas_tokens_web_1 = require("@workday/canvas-tokens-web"); exports.expandableContainerStencil = (0, canvas_kit_styling_1.createStencil)({ base: { name: "2m0mbc", styles: "box-sizing:border-box;display:flex;flex-direction:column;padding:var(--cnvs-sys-space-x2);" } }, "expandable-container-f664d5"); /** * `Expandable` wraps an `Expandable.Target` and an `Expandable.Content`. By default, it provides a * `DisclosureModel` for its subcomponents. Alternatively, a model may be passed in using the * hoisted model pattern. */ exports.Expandable = (0, common_1.createContainer)('div')({ displayName: 'Expandable', modelHook: useExpandableModel_1.useExpandableModel, subComponents: { /** * `Expandable.Target` creates a heading and a button. The heading is a semantic heading to * describe the associated content. The button provides users the ability to toggle the * associated content. * * As according to the [W3 disclosure * specification](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/), the button has * `aria-expanded` and `aria-controls` attributes set by default * * This component should hold an `Expandable.Icon`, an optional `Expandable.Avatar`, and an * `Expandable.Title`. */ Target: ExpandableTarget_1.ExpandableTarget, /** * `Expandable.Title` styles the target text that describes the content. */ Title: ExpandableTitle_1.ExpandableTitle, /** * `Expandable.Icon` creates an icon to visually indicate the state of the content. It takes an * `iconPosition` prop to determine which chevron icon to use. */ Icon: ExpandableIcon_1.ExpandableIcon, /** * `Expandable.Avatar` is an optional component that creates an `Avatar` to display a decorative * image. */ Avatar: ExpandableAvatar_1.ExpandableAvatar, /** * `Expandable.Content` holds the content that will be conditionally expanded and collapsed. It * has an `id` to ensure the `Expandable.Target` properly set it to the `aria-controls` * attribute. */ Content: ExpandableContent_1.ExpandableContent, }, })(({ children, ...elementProps }, Element) => ((0, jsx_runtime_1.jsx)(Element, { ...(0, layout_1.mergeStyles)(elementProps, (0, exports.expandableContainerStencil)()), children: children })));