| | |
| | | import { classNames } from "../util/lang" |
| | | import { i18n } from "../i18n" |
| | | import { FileTrieNode } from "../util/fileTrie" |
| | | import OverflowList from "./OverflowList" |
| | | import OverflowListFactory from "./OverflowList" |
| | | import { concatenateResources } from "../util/resources" |
| | | |
| | | type OrderEntries = "sort" | "filter" | "map" |
| | | |
| | |
| | | |
| | | const defaultOptions: Options = { |
| | | folderDefaultState: "collapsed", |
| | | folderClickBehavior: "collapse", |
| | | folderClickBehavior: "link", |
| | | useSavedState: true, |
| | | mapFn: (node) => { |
| | | return node |
| | |
| | | collapsed: boolean |
| | | } |
| | | |
| | | let numExplorers = 0 |
| | | export default ((userOpts?: Partial<Options>) => { |
| | | const opts: Options = { ...defaultOptions, ...userOpts } |
| | | const { OverflowList, overflowListAfterDOMLoaded } = OverflowListFactory() |
| | | |
| | | const Explorer: QuartzComponent = ({ cfg, displayClass }: QuartzComponentProps) => { |
| | | const id = `explorer-${numExplorers++}` |
| | | |
| | | return ( |
| | | <div |
| | | class={classNames(displayClass, "explorer")} |
| | |
| | | > |
| | | <button |
| | | type="button" |
| | | id="mobile-explorer" |
| | | class="explorer-toggle hide-until-loaded" |
| | | class="explorer-toggle mobile-explorer hide-until-loaded" |
| | | data-mobile={true} |
| | | aria-controls="explorer-content" |
| | | aria-controls={id} |
| | | > |
| | | <svg |
| | | xmlns="http://www.w3.org/2000/svg" |
| | |
| | | </button> |
| | | <button |
| | | type="button" |
| | | id="desktop-explorer" |
| | | class="title-button explorer-toggle" |
| | | class="title-button explorer-toggle desktop-explorer" |
| | | data-mobile={false} |
| | | aria-expanded={true} |
| | | > |
| | |
| | | <polyline points="6 9 12 15 18 9"></polyline> |
| | | </svg> |
| | | </button> |
| | | <div id="explorer-content" aria-expanded={false}> |
| | | <OverflowList id="explorer-ul" /> |
| | | <div id={id} class="explorer-content" aria-expanded={false} role="group"> |
| | | <OverflowList class="explorer-ul" /> |
| | | </div> |
| | | <template id="template-file"> |
| | | <li> |
| | |
| | | } |
| | | |
| | | Explorer.css = style |
| | | Explorer.afterDOMLoaded = script + OverflowList.afterDOMLoaded("explorer-ul") |
| | | Explorer.afterDOMLoaded = concatenateResources(script, overflowListAfterDOMLoaded) |
| | | return Explorer |
| | | }) satisfies QuartzComponentConstructor |