@chocbite/ts-lib-ui 1.1.2 → 1.1.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"list-DZ60Kgn5.mjs","names":["state","state","state","state","state","state"],"sources":["../../package-ui/list/key_field.ts","../../package-ui/list/add_row.ts","../../package-ui/list/drag.ts","../../package-ui/list/error.ts","../../package-ui/list/field.ts","../../package-ui/list/selection.ts","../../package-ui/list/row.ts","../../package-ui/list/shared.ts","../../package-ui/list/warn.ts","../../package-ui/list/container.ts","../../package-ui/list/types.ts","../../package-ui/list/index.ts"],"sourcesContent":["import { Base, define_element } from \"#base\";\nimport { array_from_length } from \"@chocbite/ts-lib/common\";\nimport { none, some } from \"@chocbite/ts-lib/result\";\nimport { state, type State } from \"@chocbite/ts-lib/state\";\nimport type { SVGFunc } from \"#svg\";\nimport \"./key_field.scss\";\nimport type { ListRowParent, ListType } from \"./types\";\n\nexport interface ListKeyFieldOptions {\n /**Icon shown after the sub row opener */\n icon?: SVGFunc | State<SVGFunc>;\n /**Text shown after the icon, an error of a state is shown as the text */\n text?: string | State<string>;\n}\n\nexport class ListKeyField<A extends ListType<any>> extends Base {\n static element_name() {\n return \"keyfield\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n #opener: HTMLDivElement;\n #text_box?: HTMLSpanElement;\n #icon?: SVGSVGElement;\n #tail?: HTMLElement;\n\n constructor(parent: ListRowParent<A>) {\n super();\n this.tabIndex = 0;\n //Places the line down to the sub rows of an open row\n this.style.setProperty(\"--list-key-depth\", String(parent.depth));\n this.onkeydown = (e) => {\n if (parent.key_down?.(e)) e.preventDefault();\n else if (e.key === \"Enter\" || e.key === \" \") parent.open = !parent.open;\n else if (e.key === \"ArrowRight\") parent.open = true;\n else if (e.key === \"ArrowLeft\") parent.open = false;\n else if (e.key === \"ArrowDown\") parent.select_adjacent(\"next\", none());\n else if (e.key === \"ArrowUp\") parent.select_adjacent(\"previous\", none());\n else return;\n e.preventDefault();\n };\n\n const opener_box = document.createElement(\"span\");\n opener_box.className = \"opener\";\n this.#opener = opener_box.appendChild(document.createElement(\"div\"));\n this.replaceChildren(\n ...array_from_length(parent.depth, (i) => {\n const div = document.createElement(\"div\");\n div.style.borderColor = \"var(--i-\" + i + \")\";\n return div;\n }),\n opener_box,\n );\n\n this.#opener.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n e.preventDefault();\n parent.open = !parent.open;\n });\n }\n\n set options(options: ListKeyFieldOptions | undefined) {\n if (state.is.state(options?.icon)) {\n this.attach_state_to_prop(\"icon\", options.icon, () => some(undefined));\n } else this.detach_state_from_prop(\"icon\").icon = options?.icon;\n if (state.is.state(options?.text)) {\n this.attach_state_to_prop(\"text\", options.text, (e) => some(e));\n } else this.detach_state_from_prop(\"text\").text = options?.text;\n }\n\n set icon(value: SVGFunc | undefined) {\n if (this.#icon) this.#icon.remove();\n this.#icon = undefined;\n this.classList.toggle(\"has-icon\", Boolean(value));\n if (!value) return;\n this.#icon = value();\n this.insertBefore(this.#icon, this.#text_box ?? this.#tail ?? null);\n }\n\n /**Element filling the rest of the key field, the button of an add row or the text of an error\n * A key field with a tail spans from the key column to the end of the row, so it works without value columns */\n set tail(value: HTMLElement | undefined) {\n if (value === this.#tail) return;\n this.#tail?.remove();\n this.#tail = value;\n this.classList.toggle(\"tail\", Boolean(value));\n if (value) this.appendChild(value);\n }\n get tail(): HTMLElement | undefined {\n return this.#tail;\n }\n\n /**Text after the icon, an empty string removes the text element */\n set text(value: string | undefined) {\n this.classList.toggle(\"has-text\", Boolean(value));\n if (!value) {\n this.#text_box?.remove();\n this.#text_box = undefined;\n return;\n }\n if (!this.#text_box) {\n this.#text_box = document.createElement(\"span\");\n this.#text_box.className = \"text\";\n this.insertBefore(this.#text_box, this.#tail ?? null);\n }\n this.#text_box.textContent = value;\n }\n\n // ____ _____ ______ _ _ _____ _ _ _____\n // / __ \\| __ \\| ____| \\ | |_ _| \\ | |/ ____|\n // | | | | |__) | |__ | \\| | | | | \\| | | __\n // | | | | ___/| __| | . ` | | | | . ` | | |_ |\n // | |__| | | | |____| |\\ |_| |_| |\\ | |__| |\n // \\____/|_| |______|_| \\_|_____|_| \\_|\\_____|\n\n set openable(value: boolean) {\n if (value) this.classList.add(\"openable\");\n else this.classList.remove(\"openable\");\n }\n get openable(): boolean {\n return this.classList.contains(\"openable\");\n }\n}\ndefine_element(ListKeyField);\n","import { Base, define_element } from \"#base\";\nimport { some } from \"@chocbite/ts-lib/result\";\nimport { state, type State } from \"@chocbite/ts-lib/state\";\nimport type { SVGFunc } from \"#svg\";\nimport \"./add_row.scss\";\nimport { ListKeyField } from \"./key_field\";\nimport type {\n ListParentRows,\n ListRoot,\n ListRowParent,\n ListType,\n} from \"./types\";\n\nexport interface ListAddRowOptions {\n text: string | State<string>;\n disabled?: boolean | State<boolean>;\n icon?: SVGFunc | State<SVGFunc>;\n on_add: () => void;\n}\n\nexport class ListAddRow<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n>\n extends Base\n implements ListRowParent<A>\n{\n static element_name() {\n return \"addrow\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n #button: HTMLSpanElement;\n #text: Text;\n #icon?: SVGSVGElement;\n #parent: ListRowParent<A>;\n readonly depth: number;\n\n constructor(root: ListRoot<R, T, A, S>, parent: ListRowParent<A>) {\n super();\n this.#parent = parent;\n this.depth = parent.depth + 1;\n this.#button = document.createElement(\"span\");\n this.#button.className = \"add\";\n this.#button.tabIndex = 0;\n //With sub rows the button is in the key field after the tree lines, it runs from the key column to the end\n if (root.sub_rows)\n this.appendChild(new ListKeyField(this)).tail = this.#button;\n else this.appendChild(this.#button);\n this.#text = this.#button.appendChild(document.createTextNode(\"\"));\n }\n\n set options(options: ListAddRowOptions) {\n this.#button.onclick = options.on_add;\n\n if (state.is.state(options.text))\n this.attach_state_to_prop(\"text\", options.text, (e) => some(e));\n else this.detach_state_from_prop(\"text\").text = options.text;\n if (state.is.state(options.disabled))\n this.attach_state_to_prop(\"disabled\", options.disabled, () =>\n some(false),\n );\n else this.detach_state_from_prop(\"disabled\").disabled = Boolean(\n options.disabled,\n );\n if (state.is.state(options.icon))\n this.attach_state_to_prop(\"icon\", options.icon, () => some(undefined));\n else this.detach_state_from_prop(\"icon\").icon = options.icon;\n }\n\n set text(value: string) {\n this.#text.data = value;\n }\n\n set icon(value: SVGFunc | undefined) {\n this.#icon?.remove();\n this.#icon = value ? this.#button.insertBefore(value(), this.#text) : undefined;\n }\n\n set disabled(value: boolean) {\n if (value) this.inert = true;\n else this.inert = false;\n }\n\n set open(_value: boolean) {}\n get open(): boolean {\n return false;\n }\n\n set global_index(_value: number) {}\n get global_index(): number {\n return 0;\n }\n\n /**Rows the add row adds to, the state of its parent */\n set state(_value: ListParentRows<A>) {}\n get state(): ListParentRows<A> {\n return this.#parent.state;\n }\n\n get global_amount(): number {\n return 0;\n }\n\n select_adjacent(): void {}\n}\ndefine_element(ListAddRow);\n","import { Base, define_element } from \"#base\";\nimport type { Option, Result } from \"@chocbite/ts-lib/result\";\nimport { state, type State, type StateREAW } from \"@chocbite/ts-lib/state\";\nimport \"./drag.scss\";\nimport type { ListWarn } from \"./warn\";\n\n/**What moving needs from a row */\nexport interface ListMovableRow extends HTMLElement {\n readonly data: unknown;\n /**Moving of the list the row is in */\n readonly reorder: object | undefined;\n readonly parent_rows: unknown;\n readonly parent_row: ListMovableRow | undefined;\n readonly next_row: ListMovableRow | undefined;\n readonly first_sub_row: ListMovableRow | undefined;\n readonly movable: boolean;\n readonly droppable: boolean;\n readonly selected: boolean;\n readonly multi_selected: boolean;\n readonly label: string;\n readonly anchor: Element | undefined;\n readonly index: number;\n readonly openable: boolean;\n open: boolean;\n drop_rows(): unknown;\n focus_cell(): void;\n}\n\ntype AnyRow = ListMovableRow;\ntype Rows = StateREAW<unknown[], Option<{}>, unknown[]>;\n\n/**Lists that rows can be dragged between, rows are given from one list to another of the same group\n * The type is checked both ways, so only lists with exactly the same row type can join */\nexport class ListDragGroup<R> {\n declare readonly type: (value: R) => R;\n}\n\n/**Where rows are dropped, given to can_drop */\nexport interface ListDropTarget<R> {\n /**Row the rows become sub rows of, undefined for the top level */\n parent: R | undefined;\n /**List the rows are dropped in */\n list: HTMLElement;\n}\n\nexport interface ListReorderOptions<R> {\n /**Lists of the same group can give rows to each other, without a group rows only move inside the list */\n group?: ListDragGroup<R>;\n /**Whether the row data can be dropped at the target, all dropped rows must be allowed for a drop */\n can_drop?(data: R, target: ListDropTarget<R>): boolean;\n /**Rows moved to another parent or list are only inserted there, not removed from where they came from\n * For apps that remove the rows themselves when they are added, set on the list the rows are dragged from\n * Moves inside one parent are still one move write */\n no_remove?: boolean;\n}\n\n/**Drag handle cell in front of a row, empty in the header */\nexport class ListDragField extends Base {\n static element_name() {\n return \"dragfield\";\n }\n static element_name_space() {\n return \"list\";\n }\n}\ndefine_element(ListDragField);\n\n/**Place rows are dropped at, before or after a row, or into it as its last sub rows */\nexport interface ListDropPlace {\n row: AnyRow;\n mode: \"before\" | \"after\" | \"into\";\n}\n\n/**Pixels the pointer moves before a press on the handle becomes a drag */\nconst DRAG_THRESHOLD = 5;\n/**Milliseconds hovering into a closed row before it opens */\nconst OPEN_DELAY = 600;\n/**Thickness of the drop line in pixels, it is drawn inside the row it is about */\nconst LINE_WIDTH = 5;\n/**Distance from the top or bottom edge of a list in pixels where dragging scrolls it */\nconst SCROLL_EDGE = 32;\n\n/**A rows state that the list can write moves to */\nfunction writable(rows: unknown): rows is Rows {\n return state.is.state(rows) && (rows as State<unknown>).writable;\n}\n\n/**Moving rows of a list by dragging their handle or with alt and the arrow keys\n * Like the selection, moves are only written to the rows states, the rows move when the states give the change back */\nexport class ListReorder<R> {\n readonly group: ListDragGroup<R>;\n readonly container: HTMLElement;\n #options: ListReorderOptions<R>;\n #warn: ListWarn;\n /**Shows where rows are dropped in this list */\n #indicator: HTMLSpanElement;\n\n constructor(\n container: HTMLElement,\n options: ListReorderOptions<R>,\n warn: ListWarn,\n ) {\n this.container = container;\n this.group = options.group ?? new ListDragGroup<R>();\n this.#options = options;\n this.#warn = warn;\n this.#indicator = container.appendChild(document.createElement(\"span\"));\n this.#indicator.className = \"list-drop\";\n this.#indicator.hidden = true;\n }\n\n /**Makes the handle cell of a row */\n handle(row: AnyRow): ListDragField {\n const handle = new ListDragField();\n handle.onpointerdown = (e) => this.#press(row, handle, e);\n return handle;\n }\n\n // _____ _____ _____\n // | __ \\| __ \\ /\\ / ____|\n // | | | | |__) | / \\ | | __\n // | | | | _ / / /\\ \\| | |_ |\n // | |__| | | \\ \\ / ____ \\ |__| |\n // |_____/|_| \\_\\/_/ \\_\\_____|\n\n #press(row: AnyRow, handle: ListDragField, e: PointerEvent) {\n if (e.button !== 0 || !row.movable) return;\n e.preventDefault();\n handle.setPointerCapture(e.pointerId);\n const start_x = e.clientX;\n const start_y = e.clientY;\n let x = start_x;\n let y = start_y;\n let rows: AnyRow[] | undefined;\n let place: ListDropPlace | undefined;\n let shown: ListReorder<R> | undefined;\n let frame = 0;\n let open_timer = 0;\n let open_row: AnyRow | undefined;\n const label = document.createElement(\"span\");\n label.className = \"list-drag-label\";\n\n const update = () => {\n frame = requestAnimationFrame(update);\n this.#scroll(x, y);\n const next = this.#place(x, y, rows!);\n shown?.indicate(undefined);\n shown = next?.row.reorder as ListReorder<R> | undefined;\n shown?.indicate(next);\n place = next;\n label.style.left = x + 12 + \"px\";\n label.style.top = y + 12 + \"px\";\n label.classList.toggle(\"none\", !next);\n //Hovering into a closed row opens it after a moment\n const hover =\n next?.mode === \"into\" && !next.row.open ? next.row : undefined;\n if (hover !== open_row) {\n clearTimeout(open_timer);\n open_row = hover;\n if (hover)\n open_timer = window.setTimeout(() => (hover.open = true), OPEN_DELAY);\n }\n };\n const end = (drop: boolean) => {\n handle.onpointermove = null;\n handle.onpointerup = null;\n handle.onpointercancel = null;\n handle.onlostpointercapture = null;\n document.removeEventListener(\"keydown\", escape, true);\n cancelAnimationFrame(frame);\n clearTimeout(open_timer);\n shown?.indicate(undefined);\n label.remove();\n if (!rows) return;\n for (const dragged of rows) dragged.classList.remove(\"dragging\");\n if (drop && place) void this.#drop(rows, place);\n };\n const escape = (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\") return;\n ev.preventDefault();\n ev.stopPropagation();\n end(false);\n };\n\n handle.onpointermove = (ev) => {\n x = ev.clientX;\n y = ev.clientY;\n if (rows) return;\n if (Math.hypot(x - start_x, y - start_y) < DRAG_THRESHOLD) return;\n rows = this.#dragged(row);\n for (const dragged of rows) dragged.classList.add(\"dragging\");\n label.textContent =\n rows.length > 1 ? rows.length + \" rows\" : row.label || \"1 row\";\n //In the body, a list is a stacking context, so a label in it would be covered by the lists after it\n document.body.appendChild(label);\n document.addEventListener(\"keydown\", escape, true);\n update();\n };\n handle.onpointerup = () => end(true);\n handle.onpointercancel = () => end(false);\n handle.onlostpointercapture = () => end(false);\n }\n\n /**Rows a drag from the row moves, the visible selected movable rows when the row is selected in multi mode\n * Sub rows of a dragged row move with it, so they are left out */\n #dragged(row: AnyRow): AnyRow[] {\n if (!row.selected || !row.multi_selected) return [row];\n const rows = [\n ...this.container.querySelectorAll<AnyRow>(\"list-row.selected.movable\"),\n ].filter((selected) => selected.reorder === this);\n const dragged = new Set(rows);\n return rows.filter((selected) => {\n for (let parent = selected.parent_row; parent; parent = parent.parent_row)\n if (dragged.has(parent)) return false;\n return true;\n });\n }\n\n /**Scrolls the list under the pointer when the pointer is near its top or bottom edge */\n #scroll(x: number, y: number) {\n const list = document\n .elementFromPoint(x, y)\n ?.closest<HTMLElement>(\"list-container\");\n const target = list ?? this.container;\n const rect = target.getBoundingClientRect();\n if (x < rect.left || x > rect.right) return;\n if (y < rect.top + SCROLL_EDGE)\n target.scrollTop -= Math.ceil((rect.top + SCROLL_EDGE - y) / 4);\n else if (y > rect.bottom - SCROLL_EDGE)\n target.scrollTop += Math.ceil((y - rect.bottom + SCROLL_EDGE) / 4);\n }\n\n // _____ _____ ____ _____\n // | __ \\| __ \\ / __ \\| __ \\\n // | | | | |__) | | | | |__) |\n // | | | | _ /| | | | ___/\n // | |__| | | \\ \\| |__| | |\n // |_____/|_| \\_\\\\____/|_|\n\n /**The place under the pointer, undefined when the rows can not be dropped there */\n #place(x: number, y: number, rows: AnyRow[]): ListDropPlace | undefined {\n const element = document.elementFromPoint(x, y);\n let row = element?.closest<AnyRow>(\"list-row\") ?? undefined;\n let mode: ListDropPlace[\"mode\"];\n if (!row) {\n //Below the last row of a list drops after it\n const list = element?.closest<HTMLElement>(\"list-container\");\n const last = list?.querySelector<AnyRow>(\n \":scope > div > div > list-row:last-child\",\n );\n if (!last?.anchor || y < last.anchor.getBoundingClientRect().bottom)\n return undefined;\n row = last;\n mode = \"after\";\n } else {\n const rect = row.anchor?.getBoundingClientRect();\n if (!rect) return undefined;\n const part = (y - rect.top) / rect.height;\n if (row.openable)\n mode = part < 0.25 ? \"before\" : part > 0.75 ? \"after\" : \"into\";\n else mode = part < 0.5 ? \"before\" : \"after\";\n }\n const reorder = row.reorder as ListReorder<R> | undefined;\n if (reorder?.group !== this.group) return undefined;\n //After an open row is before its first sub row\n if (mode === \"after\" && row.open) {\n const first = row.first_sub_row;\n if (first) {\n row = first;\n mode = \"before\";\n }\n }\n const place: ListDropPlace = { row, mode };\n return reorder.#allowed(place, rows) ? place : undefined;\n }\n\n /**Whether the rows can be dropped at the place of this list */\n #allowed(place: ListDropPlace, rows: AnyRow[]): boolean {\n const parent = place.mode === \"into\" ? place.row : place.row.parent_row;\n if (place.mode !== \"into\" && rows.includes(place.row)) return false;\n //Not into itself or its own sub rows\n for (let up: AnyRow | undefined = parent; up; up = up.parent_row)\n if (rows.includes(up)) return false;\n if (place.mode === \"into\" ? !place.row.droppable : !place.row.movable)\n return false;\n const options = this.#options;\n if (!options.can_drop) return true;\n const target: ListDropTarget<R> = {\n parent: parent?.data as R | undefined,\n list: this.container,\n };\n return rows.every((row) => options.can_drop!(row.data as R, target));\n }\n\n /**Shows where rows are dropped in this list, undefined hides it */\n indicate(place: ListDropPlace | undefined) {\n const indicator = this.#indicator;\n const cell = place?.row.anchor;\n if (!place || !cell) {\n indicator.hidden = true;\n return;\n }\n const list = this.container;\n const box = list.getBoundingClientRect();\n const rect = cell.getBoundingClientRect();\n const top = rect.top - box.top + list.scrollTop;\n //A line starts at the tree indent of the row, so the depth the rows land at shows,\n //after the last sub row of an open row and before the next row are at the same height\n const opener =\n place.mode === \"into\"\n ? undefined\n : place.row.querySelector(\n \":scope > div > list-keyfield > span:not(.text)\",\n );\n const left =\n (opener ?? cell).getBoundingClientRect().left -\n box.left +\n list.scrollLeft;\n //Ends at the right edge of the rows, not the scroll width of the list, which includes the indicator itself,\n //rounded down so it never makes the list wider and flashes a scrollbar\n const grid = list.querySelector(\":scope > div\") ?? list;\n const right =\n grid.getBoundingClientRect().right - box.left + list.scrollLeft;\n indicator.hidden = false;\n indicator.className = \"list-drop \" + place.mode;\n indicator.style.left = left + \"px\";\n indicator.style.width = Math.max(Math.floor(right - left), 0) + \"px\";\n //Drawn inside the row it is about, at its top or bottom edge\n indicator.style.top =\n (place.mode === \"after\" ? top + rect.height - LINE_WIDTH : top) + \"px\";\n indicator.style.height =\n (place.mode === \"into\" ? rect.height : LINE_WIDTH) + \"px\";\n }\n\n // __ __ ______ ________\n // | \\/ |/ __ \\ \\ / / ____|\n // | \\ / | | | \\ \\ / /| |__\n // | |\\/| | | | |\\ \\/ / | __|\n // | | | | |__| | \\ / | |____\n // |_| |_|\\____/ \\/ |______|\n\n /**Writes the moves of the rows to the place, rows next to each other in one parent move with one write\n * Moving to another parent inserts first and removes after, so a failure can leave a row twice but never loses it */\n async #drop(rows: AnyRow[], place: ListDropPlace) {\n const errors: string[] = [];\n const into = place.mode === \"into\" ? place.row : undefined;\n //Rows are dropped in order before this row, undefined appends to the parent\n const before: AnyRow | undefined =\n place.mode === \"before\"\n ? place.row\n : place.mode === \"after\"\n ? place.row.next_row\n : undefined;\n const target_box =\n place.mode === \"into\" ? undefined : place.row.parentElement;\n const target_rows = into ? into.drop_rows() : place.row.parent_rows;\n if (!writable(target_rows)) return;\n for (const chunk of this.#chunks(rows)) {\n const first = chunk[0];\n const source_box = first.parentElement;\n const same = into ? first.parent_row === into : source_box === target_box;\n if (same) {\n const from = first.index;\n const end = before ? before.index : source_box!.childElementCount;\n const to = from < end ? end - chunk.length : end;\n if (from === to) continue;\n const result = await target_rows.write(\n state.a.write.move(from, to, chunk.length),\n );\n if (result.err) errors.push(result.error);\n continue;\n }\n const items = chunk.map((row) => row.data);\n const inserted: Result<void, string> = await target_rows.write(\n before\n ? state.a.write.splice(before.index, 0, ...items)\n : state.a.write.push(...items),\n );\n if (inserted.err) {\n errors.push(inserted.error);\n continue;\n }\n //The app already took the rows out of the source while inserting\n if (this.#options.no_remove || !first.parentElement) continue;\n const source_rows = first.parent_rows;\n if (!writable(source_rows)) continue;\n const removed = await source_rows.write(\n state.a.write.splice(first.index, chunk.length),\n );\n if (removed.err) errors.push(removed.error);\n }\n if (into && errors.length === 0) into.open = true;\n if (errors.length)\n (place.row.reorder as ListReorder<R> | undefined)?.warn(\n place.row,\n [...new Set(errors)].join(\"\\n\"),\n );\n }\n\n /**Splits rows in display order into runs of rows next to each other in one parent */\n #chunks(rows: AnyRow[]): AnyRow[][] {\n const chunks: AnyRow[][] = [];\n for (const row of rows) {\n const last = chunks[chunks.length - 1]?.at(-1);\n if (\n last &&\n last.parentElement === row.parentElement &&\n last.next_row === row\n )\n chunks[chunks.length - 1].push(row);\n else chunks.push([row]);\n }\n return chunks;\n }\n\n /**Shows why a move failed at the row, in the list of the row */\n warn(row: AnyRow, message: string) {\n this.#warn.show(row.anchor, message);\n }\n\n /**Moves the row one place up or down in its parent, from the keyboard, the row keeps the focus */\n async key_move(row: AnyRow, direction: -1 | 1) {\n const rows = row.parent_rows;\n if (!row.movable || !writable(rows)) return;\n const from = row.index;\n const to = from + direction;\n if (to < 0 || to >= row.parentElement!.childElementCount) return;\n const result = await rows.write(state.a.write.move(from, to, 1));\n //Moving takes the row out of the document for a moment, which loses the focus\n row.focus_cell();\n if (result.err) this.warn(row, result.error);\n }\n}\n","import { Base, define_element } from \"#base\";\nimport \"./error.scss\";\nimport { ListKeyField } from \"./key_field\";\nimport type { ListParentRows, ListRowParent, ListType } from \"./types\";\n\n/**Error text shown instead of the fields of an invalid row */\nexport class ListError extends Base {\n static element_name() {\n return \"error\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n set text(value: string) {\n this.textContent = value;\n }\n}\ndefine_element(ListError);\n\n/**Error text shown instead of the rows of a parent, has a key field to continue the tree lines like an add row */\nexport class ListRowsError<A extends ListType<any>>\n extends Base\n implements ListRowParent<A>\n{\n static element_name() {\n return \"rowserror\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n #text = new ListError();\n #parent: ListRowParent<A>;\n readonly depth: number;\n\n constructor(sub_rows: boolean, parent: ListRowParent<A>) {\n super();\n this.#parent = parent;\n this.depth = parent.depth + 1;\n //With sub rows the text is in the key field after the tree lines, it runs from the key column to the end\n if (sub_rows) this.appendChild(new ListKeyField(this)).tail = this.#text;\n else this.appendChild(this.#text);\n }\n\n set text(value: string) {\n this.#text.text = value;\n }\n\n set open(_value: boolean) {}\n get open(): boolean {\n return false;\n }\n\n /**Rows the error is shown for, the state of its parent */\n set state(_value: ListParentRows<A>) {}\n get state(): ListParentRows<A> {\n return this.#parent.state;\n }\n\n select_adjacent(): void {}\n}\ndefine_element(ListRowsError);\n\n/**Shows the text in an error element directly after the row box, removes the element when there is no text\n * @returns the element to give next time, undefined when there is no text*/\nexport function list_rows_error_update<A extends ListType<any>>(\n row_box: Element,\n current: ListRowsError<A> | undefined,\n text: string | undefined,\n sub_rows: boolean,\n parent: ListRowParent<A>,\n): ListRowsError<A> | undefined {\n if (text === undefined) {\n current?.remove();\n return undefined;\n }\n if (!current) {\n current = new ListRowsError(sub_rows, parent);\n //Not in the row box, everything in there is a row\n row_box.after(current);\n }\n current.text = text;\n return current;\n}\n","import { Base, define_element } from \"#base\";\nimport \"./field.scss\";\nimport type { ListColumnAlign } from \"./types\";\n\n/**Adds the class for the alignment, center is the default and adds nothing\n * Only the styling of an element decides if the class does anything, so complex fields just do not follow it */\nexport function list_align_apply(\n element: HTMLElement,\n align: ListColumnAlign | undefined,\n) {\n if (align === \"left\" || align === \"right\")\n element.classList.add(\"align-\" + align);\n}\n\nexport abstract class ListField extends Base {\n static element_name() {\n return \"@abstract@\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n constructor() {\n super();\n }\n}\n\nexport class ListTextField extends ListField {\n static element_name() {\n return \"textfield\";\n }\n\n set text(value: string) {\n this.textContent = value;\n }\n}\ndefine_element(ListTextField);\n\nexport function text_field() {\n return new ListTextField();\n}\n\nexport class ListNumberField extends ListField {\n static element_name() {\n return \"numberfield\";\n }\n\n set number(value: number) {\n this.textContent = value.toString();\n }\n}\ndefine_element(ListNumberField);\n\nexport function number_field() {\n return new ListNumberField();\n}\n\nexport class ListNodeField<T extends Node> extends ListField {\n static element_name() {\n return \"nodefield\";\n }\n\n constructor(node: T) {\n super();\n this.appendChild(node);\n }\n\n set node(node: T) {\n this.replaceChildren(node);\n }\n\n get node() {\n return this.firstChild! as unknown as T;\n }\n}\ndefine_element(ListNodeField);\n\nexport function node_field<T extends Node>(node: T) {\n return new ListNodeField<T>(node);\n}\n","import { Base, define_element } from \"#base\";\nimport type { Result } from \"@chocbite/ts-lib/result\";\nimport { state, type StateREAW } from \"@chocbite/ts-lib/state\";\nimport \"./selection.scss\";\n\nexport interface ListSelectionOptions<R, K = R> {\n /**Single allows one selected row and shows radio buttons in front of the rows,\n * multi allows any amount and shows checkboxes, which toggle a row without modifier keys */\n mode: \"single\" | \"multi\";\n /**Identity of the data of a row, the selection is a list of these\n * Defaults to the data itself, give a key when rows can have equal data, like primitives\n * Keys must be unique among the rows of the list, sub rows included */\n key?: (data: R) => K;\n}\n\n/**What the selection needs from a row */\nexport interface ListSelectionRow {\n /**Shows the row as selected */\n selected: boolean;\n /**Cell to point at with a message about the row */\n readonly anchor: Element | undefined;\n}\n\n/**Selection of the rows of a list, kept in an array state of keys owned by the app\n * The list shows the keys of the state that have a visible row, and writes the state only on user actions,\n * keys of rows it does not show are left alone, except by select all and deselect all which replace the selection */\nexport class ListSelection<K> {\n readonly multi: boolean;\n /**Whether the rows get a checkbox or radio button column\n * Left out in single mode with a key column, a click on the row selects and the key field is the keyboard cell */\n readonly column: boolean;\n readonly key: (data: any) => K;\n /**Called after a change of the shown selection or of the selectable rows */\n on_change?: () => void;\n /**Called when the state rejects a write, with the row the user acted on */\n on_error?: (row: ListSelectionRow | undefined, message: string) => void;\n /**State user actions are written to */\n target?: StateREAW<K[], any, K[]>;\n\n /**Element holding all rows of the list, sub rows included, in display order */\n #box: Element;\n #rows = new Map<K, ListSelectionRow & Element>();\n /**Mirror of the state array, the removed and changed entries of an update only give positions or new items */\n #keys: K[] = [];\n /**How often each key is in the state, a key that is in it twice stays selected when one is removed */\n #counts = new Map<K, number>();\n /**Amount of visible rows that are selected */\n #shown = 0;\n #anchor?: K;\n #batch = 0;\n #changed = false;\n\n constructor(\n options: ListSelectionOptions<any, K>,\n box: Element,\n key_column: boolean,\n ) {\n this.multi = options.mode === \"multi\";\n this.column = this.multi || !key_column;\n this.key = options.key ?? ((data) => data as K);\n this.#box = box;\n }\n\n /**Runs the function with the change notification delayed until all nested batches are done */\n batch<T>(func: () => T): T {\n this.#batch++;\n try {\n return func();\n } finally {\n if (--this.#batch === 0 && this.#changed) {\n this.#changed = false;\n this.on_change?.();\n }\n }\n }\n\n // _____ _______ _______ ______\n // / ____|__ __|/\\|__ __| ____|\n // | (___ | | / \\ | | | |__\n // \\___ \\ | | / /\\ \\ | | | __|\n // ____) | | |/ ____ \\| | | |____\n // |_____/ |_/_/ \\_\\_| |______|\n\n /**Applies a value of the state, only the changed keys are touched when the value carries its changes */\n apply(value: Result<readonly K[], string>) {\n this.batch(() => {\n if (!value.ok) {\n this.#fresh([]);\n return;\n }\n for (const change of state.a.read(value.value)) {\n if (change.type === \"fresh\") this.#fresh(change.items);\n else if (change.type === \"added\") {\n this.#keys.splice(change.index, 0, ...change.items);\n for (const key of change.items) this.#add(key);\n } else if (change.type === \"removed\") {\n for (const key of this.#keys.splice(\n change.index,\n change.items.length,\n ))\n this.#remove(key);\n } else if (change.type === \"changed\")\n change.items.forEach((key, i) => {\n const old = this.#keys[change.index + i];\n this.#keys[change.index + i] = key;\n this.#remove(old);\n this.#add(key);\n });\n else {\n const moved = this.#keys.splice(\n change.from_index,\n change.items.length,\n );\n this.#keys.splice(change.to_index, 0, ...moved);\n }\n }\n });\n }\n\n #fresh(keys: readonly K[]) {\n const old = this.#counts;\n this.#keys = [...keys];\n this.#counts = new Map();\n for (const key of keys)\n this.#counts.set(key, (this.#counts.get(key) ?? 0) + 1);\n for (const key of old.keys())\n if (!this.#counts.has(key)) this.#show(key, false);\n for (const key of this.#counts.keys())\n if (!old.has(key)) this.#show(key, true);\n }\n\n #add(key: K) {\n const count = this.#counts.get(key) ?? 0;\n this.#counts.set(key, count + 1);\n if (count === 0) this.#show(key, true);\n }\n\n #remove(key: K) {\n const count = this.#counts.get(key);\n if (!count) return;\n if (count > 1) this.#counts.set(key, count - 1);\n else {\n this.#counts.delete(key);\n this.#show(key, false);\n }\n }\n\n #show(key: K, selected: boolean) {\n const row = this.#rows.get(key);\n if (!row) return;\n row.selected = selected;\n this.#shown += selected ? 1 : -1;\n this.#changed = true;\n }\n\n /**Writes the state, a rejected write is reported at the row of the key the user acted on */\n #write(value: K[], key?: K) {\n const write = this.target?.write(value);\n if (!write) return;\n const row = key === undefined ? undefined : this.#rows.get(key);\n void write.then((result) => {\n if (result.err) this.on_error?.(row, result.error);\n });\n }\n\n // _____ ______ _______\n // | __ \\ / __ \\ \\ / / ____|\n // | |__) | | | \\ \\ /\\ / / (___\n // | _ /| | | |\\ \\/ \\/ / \\___ \\\n // | | \\ \\| |__| | \\ /\\ / ____) |\n // |_| \\_\\\\____/ \\/ \\/ |_____/\n\n /**Adds a visible row that can be selected, it shows whether its key is in the state */\n register(key: K, row: ListSelectionRow & Element) {\n this.#rows.set(key, row);\n row.selected = this.#counts.has(key);\n if (row.selected) this.#shown++;\n this.#changed = true;\n }\n\n /**Removes a row that is no longer visible or selectable, the state keeps its key */\n unregister(key: K, row: ListSelectionRow & Element) {\n if (this.#rows.get(key) === row) {\n this.#rows.delete(key);\n if (this.#counts.has(key)) this.#shown--;\n }\n row.selected = false;\n this.#changed = true;\n }\n\n /**Amount of visible rows that can be selected */\n get amount_selectable(): number {\n return this.#rows.size;\n }\n\n /**Amount of visible rows that are selected */\n get amount_selected(): number {\n return this.#shown;\n }\n\n is_selected(key: K): boolean {\n return this.#counts.has(key);\n }\n\n // _ _ _____ ______ _____\n // | | | |/ ____| ____| __ \\\n // | | | | (___ | |__ | |__) |\n // | | | |\\___ \\| __| | _ /\n // | |__| |____) | |____| | \\ \\\n // \\____/|_____/|______|_| \\_\\\n //Every user action writes the state, the rows show the change when the state gives it back\n\n /**Keys of the selectable rows from one row to another in display order, both included */\n #range(from: K, to: K): K[] {\n const keys: K[] = [];\n let inside = false;\n const rows = this.#box.querySelectorAll(\"list-row\");\n const from_row = this.#rows.get(from);\n const to_row = this.#rows.get(to);\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const edge = row === from_row || row === to_row;\n if (edge || inside) {\n const key = (row as unknown as { selection_key: K | undefined })\n .selection_key;\n if (key !== undefined && this.#rows.get(key) === row) keys.push(key);\n }\n if (edge) {\n if (inside || from_row === to_row) break;\n inside = true;\n }\n }\n return keys;\n }\n\n #select_range(to: K, add: boolean) {\n if (!this.#rows.has(to)) return;\n const anchor =\n this.#anchor !== undefined && this.#rows.has(this.#anchor)\n ? this.#anchor\n : to;\n const keys = this.#range(anchor, to);\n this.#anchor = anchor;\n if (!add) return this.#write(state.a.write.fresh(keys), to);\n const added = keys.filter((key) => !this.#counts.has(key));\n if (added.length) this.#write(state.a.write.push(...added), to);\n }\n\n /**Replaces the selection with only the row */\n select_only(key: K) {\n if (!this.#rows.has(key)) return;\n this.#anchor = key;\n if (this.#keys.length === 1 && this.#keys[0] === key) return;\n this.#write(state.a.write.fresh([key]), key);\n }\n\n /**Adds the row to the selection, in single mode it replaces the selection */\n select(key: K) {\n if (!this.multi) return this.select_only(key);\n if (!this.#rows.has(key)) return;\n this.#anchor = key;\n if (!this.#counts.has(key)) this.#write(state.a.write.push(key), key);\n }\n\n /**Removes the row from the selection */\n deselect(key: K) {\n if (this.#counts.has(key)) this.#write(state.a.write.delete(key), key);\n }\n\n /**Toggles the row, in single mode selecting replaces the selection */\n toggle(key: K) {\n if (!this.#rows.has(key)) return;\n if (this.#counts.has(key)) {\n this.#anchor = key;\n this.deselect(key);\n } else this.select(key);\n }\n\n /**Replaces the selection with all visible selectable rows, multi mode only */\n select_all() {\n if (this.multi) this.#write(state.a.write.fresh([...this.#rows.keys()]));\n }\n\n /**Clears the selection, also of keys without a visible row */\n clear() {\n if (this.#keys.length) this.#write(state.a.write.fresh([]));\n }\n\n /**Click on the checkbox or radio button of a row */\n check_click(key: K) {\n if (this.multi) this.toggle(key);\n else this.select_only(key);\n }\n\n /**Click on a row outside its checkbox or radio button */\n click(key: K, e: MouseEvent) {\n if (this.multi && e.shiftKey)\n this.#select_range(key, e.ctrlKey || e.metaKey);\n else if (e.ctrlKey || e.metaKey) this.toggle(key);\n else this.select_only(key);\n }\n\n /**Focus moved to a row with the arrow keys, only shift in multi mode extends the range, otherwise the focus moves alone and space selects */\n focus_moved(key: K, e: KeyboardEvent) {\n if (this.multi && e.shiftKey)\n this.#select_range(key, e.ctrlKey || e.metaKey);\n }\n\n /**Handles selection keys pressed on a row, returns true when the key was used */\n key_down(key: K | undefined, e: KeyboardEvent): boolean {\n if (e.key === \" \") {\n if (key === undefined) return true;\n if (this.multi || e.ctrlKey || e.metaKey) this.toggle(key);\n else this.select_only(key);\n } else if (e.key === \"Escape\") this.clear();\n else if (this.multi && (e.ctrlKey || e.metaKey) && e.key === \"a\")\n this.select_all();\n else return false;\n return true;\n }\n}\n\n/**Checkbox or radio button cell in front of a row or in the header, its look comes from the selected class of the row or the header */\nexport class ListCheckField extends Base {\n static element_name() {\n return \"checkfield\";\n }\n static element_name_space() {\n return \"list\";\n }\n}\ndefine_element(ListCheckField);\n","import { Base, define_element } from \"#base\";\nimport ctm, { ContextMenu, type ContextMenuLines } from \"#context-menu\";\nimport { none, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { state, type State, type StateInferSub } from \"@chocbite/ts-lib/state\";\nimport state_ui from \"#state_ui\";\nimport { ListAddRow, type ListAddRowOptions } from \"./add_row\";\nimport type { ListDragField } from \"./drag\";\nimport { list_rows_error_update, ListError, type ListRowsError } from \"./error\";\nimport { list_align_apply, type ListField } from \"./field\";\nimport { ListKeyField, type ListKeyFieldOptions } from \"./key_field\";\nimport \"./row.scss\";\nimport { ListCheckField, type ListSelection } from \"./selection\";\nimport type {\n ListParentRows,\n ListRoot,\n ListRowParent,\n ListRowTransformer,\n ListType,\n} from \"./types\";\n\n/**Shown when the user tries to select a row that can not be selected */\nconst NOT_SELECTABLE = \"This row cannot be selected\";\n\nexport type ListSubRows<R> = () => R[] | State<R[]>;\n\nexport interface ListRowOptions<R, T extends {}, S extends boolean> {\n opened?: boolean;\n openable?: boolean | State<boolean>;\n key_field?: ListKeyFieldOptions;\n sub_rows?: S extends true ? ListSubRows<R> : never;\n add_row?: ListAddRowOptions;\n context_menu?: ContextMenu | (() => Option<ContextMenu>);\n /**Whether the row can be selected when the list has selection, true when undefined */\n selectable?: boolean;\n values: T;\n}\n\nexport class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>\n extends Base\n implements ListRowParent<A>\n{\n static element_name() {\n return \"row\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n #root: ListRoot<R, T, A, S>;\n #parent: ListRowParent<A>;\n #sub_rows?: ListSubRows<R>;\n readonly depth: number;\n #key_field?: ListKeyField<A>;\n /**Drag handle cell, only with reorder */\n #drag?: ListDragField;\n /**Checkbox or radio button cell, only with selection */\n #check?: ListCheckField;\n #data!: R;\n /**Sub rows of a closed row given for a drop, used when it opens so the sub rows function is called once */\n #drop_rows?: R[] | State<R[]>;\n /**Key of the row in the selection, undefined when the row can not be selected */\n selection_key?: unknown;\n #field_box: HTMLDivElement;\n #child_box: HTMLSpanElement;\n #add_row?: ListAddRow<R, T, A, S>;\n #fields: ListField[];\n #values!: T;\n /**Shown instead of the fields while the row is invalid */\n #invalid?: ListError;\n /**Shown instead of the sub rows while their state has an error */\n #error?: ListRowsError<A>;\n #open_pending = false;\n #sub_row_menu = false;\n #state_sub?: StateInferSub<State<R[]>>;\n state!: ListParentRows<A>;\n\n constructor(root: ListRoot<R, T, A, S>, parent: ListRowParent<A>, data: R) {\n super();\n this.#root = root;\n this.#parent = parent;\n this.depth = parent.depth + 1;\n this.style.setProperty(\"--i-\" + this.depth, \"var(--c)\");\n if (this.#root.sub_rows) {\n this.#key_field = new ListKeyField(this);\n if (this.#root.observer)\n this.#key_field.attach_to_intersect_observer(this.#root.observer);\n }\n this.#field_box = this.appendChild(document.createElement(\"div\"));\n this.#child_box = this.appendChild(document.createElement(\"span\"));\n if (this.#root.reorder) this.#drag = this.#root.reorder.handle(this);\n if (this.#root.selection) this.#selection_setup(this.#root.selection);\n //A right click on a sub row without its own menu reaches the child box before this row\n if (this.#root.sub_rows)\n this.#child_box.oncontextmenu = () => {\n this.#sub_row_menu = true;\n };\n this.#fields = this.#generate_fields();\n this.#show_cells(this.#fields);\n\n //Updates row data\n this.data = data;\n }\n\n #generate_fields(): ListField[] {\n return this.#root.columns_visible.map((key) => {\n const column = this.#root.columns.get(key)!;\n const field = column.field_gen();\n list_align_apply(field, column.align);\n if (this.#root.observer)\n field.attach_to_intersect_observer(this.#root.observer);\n return field;\n });\n }\n\n /**Shows the cells after the key field, which stays so an invalid row keeps its indent and arrow key navigation */\n #show_cells(cells: readonly HTMLElement[]) {\n const lead: HTMLElement[] = [];\n if (this.#drag) lead.push(this.#drag);\n if (this.#check) lead.push(this.#check);\n if (this.#key_field) lead.push(this.#key_field);\n this.#field_box.replaceChildren(...lead, ...cells);\n }\n\n #apply_values() {\n this.#root.columns_visible.forEach((key, index) => {\n this.#root.columns\n .get(key)!\n .field_apply(this.#fields[index], this.#values[key]);\n });\n }\n\n /**Regenerates the fields of the row and its sub rows after the columns changed */\n columns_changed() {\n this.#fields = this.#generate_fields();\n //An invalid row has no values, the new fields are shown when it becomes valid\n if (!this.#invalid) {\n this.#show_cells(this.#fields);\n this.#apply_values();\n }\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n (this.#child_box.children[i] as ListRow<R, T, A, S>).columns_changed();\n }\n\n // _____ _____ ______ _ _ _______\n // | __ \\ /\\ | __ \\| ____| \\ | |__ __|\n // | |__) / \\ | |__) | |__ | \\| | | |\n // | ___/ /\\ \\ | _ /| __| | . ` | | |\n // | | / ____ \\| | \\ \\| |____| |\\ | | |\n // |_| /_/ \\_\\_| \\_\\______|_| \\_| |_|\n\n select_adjacent(\n direction: \"next\" | \"previous\" | \"p_next\" | \"p_previous\" | \"last\",\n field: Option<number>,\n ) {\n if (!this.#key_field && !this.#check) return;\n //Open is not enough, an open row can show an error instead of sub rows\n const has_rows = this.#child_box.childElementCount > 0;\n if (direction === \"next\" || direction === \"p_next\") {\n if (direction === \"next\" && has_rows)\n (this.#child_box.firstElementChild! as ListRow<R, T, A, S>).#focus();\n else {\n const sibling = this.nextElementSibling;\n if (sibling instanceof ListRow) sibling.#focus();\n else this.#parent.select_adjacent(\"p_next\", field);\n }\n } else if (direction === \"previous\") {\n const sibling = this.previousElementSibling;\n if (sibling instanceof ListRow) {\n if (sibling.open) sibling.select_adjacent(\"last\", field);\n else sibling.#focus();\n } else this.#parent.select_adjacent(\"p_previous\", field);\n } else if (direction === \"p_previous\") this.#focus();\n else if (direction === \"last\") {\n if (has_rows) {\n (\n this.#child_box.lastElementChild as ListRow<R, T, A, S>\n ).select_adjacent(\"last\", field);\n } else this.#focus();\n }\n }\n\n /**Focuses the cell used for keyboard navigation, the key field or else the checkbox */\n #focus(options?: FocusOptions) {\n (this.#key_field ?? this.#check)?.focus(options);\n }\n\n /**Focuses the cell used for keyboard navigation */\n focus_cell() {\n this.#focus({ preventScroll: true });\n }\n\n /**Moves the focus to the keyboard cell after a click, so the selection keys work right away\n * Unless the click focused something in the row itself, like an input of a field */\n #focus_after_click() {\n const active = document.activeElement;\n if (active && active !== document.body && this.#field_box.contains(active))\n return;\n const cell = this.#key_field ?? this.#check;\n if (!cell) return;\n //Without scrolling, the sticky cell would scroll the list sideways\n cell.focus({ preventScroll: true });\n //Focus from script shows the focus ring, which a click should not, removed again by a key or blur\n cell.classList.add(\"click-focus\");\n }\n\n key_down(e: KeyboardEvent): boolean {\n const selection = this.#root.selection;\n if (e.altKey && (e.key === \"ArrowDown\" || e.key === \"ArrowUp\")) {\n if (!this.#root.reorder) return false;\n void this.#root.reorder.key_move(this, e.key === \"ArrowDown\" ? 1 : -1);\n return true;\n }\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n this.select_adjacent(e.key === \"ArrowDown\" ? \"next\" : \"previous\", none());\n const focused = document.activeElement?.closest(\"list-row\");\n if (\n selection &&\n focused !== this &&\n focused instanceof ListRow &&\n focused.selection_key !== undefined\n )\n selection.focus_moved(focused.selection_key, e);\n return true;\n }\n if (!selection) return false;\n if (e.key === \" \" && this.selection_key === undefined) {\n selection.on_error?.(this, NOT_SELECTABLE);\n return true;\n }\n return selection.key_down(this.selection_key, e);\n }\n\n // _____ _______\n // | __ \\ /\\|__ __|/\\\n // | | | | / \\ | | / \\\n // | | | |/ /\\ \\ | | / /\\ \\\n // | |__| / ____ \\| |/ ____ \\\n // |_____/_/ \\_\\_/_/ \\_\\\n\n set data(data: R) {\n this.#data = data;\n this.#drop_rows = undefined;\n this.classList.toggle(\n \"movable\",\n Boolean(this.#drag) &&\n state.is.state(this.#parent.state) &&\n this.#parent.state.writable,\n );\n const result = this.#root.transform(\n data,\n this,\n //Only the container gives top level rows, rows are only parents of sub rows\n this.#parent.state as Parameters<ListRowTransformer<R, T, A, S>>[2],\n );\n if (!result.ok) {\n this.#set_invalid(result.error);\n return;\n }\n const row_options = result.value;\n if (this.#invalid) {\n this.#invalid = undefined;\n if (this.#key_field) this.#key_field.tail = undefined;\n this.#show_cells(this.#fields);\n }\n this.#selection_update(row_options.selectable ?? true, data);\n if (this.#key_field) this.#key_field.options = row_options.key_field;\n this.#sub_rows = row_options.sub_rows;\n\n this.add_row = row_options.add_row;\n\n this.#values = row_options.values;\n this.#apply_values();\n\n //Setup openable\n const was_open = this.open;\n if (state.is.state(row_options.openable)) {\n //Opening waits for the first value of the state, which is immediate when connected\n this.#open_pending = !was_open && Boolean(row_options.opened);\n this.attach_state_to_prop(\"openable\", row_options.openable, () =>\n some(false),\n );\n } else {\n this.#open_pending = false;\n this.detach_state_from_prop(\"openable\");\n this.openable = Boolean(row_options.openable);\n if (!was_open && row_options.opened) this.open = true;\n }\n\n //Refresh the sub rows of an open row\n if (was_open && this.open) {\n if (this.#sub_rows) this.rows = this.#sub_rows();\n else if (!row_options.opened) this.open = false;\n }\n\n //Setup context menu, blocked for right clicks bubbling up from sub rows\n ctm.detach(this);\n this.#sub_row_menu = false;\n //With sub rows a row gets open, close and close all lines and a selectable row select lines, in front of its own menu\n //Openable can be a state and rows open and close, the lines are made when the menu opens\n const menu =\n this.#root.sub_rows || this.selection_key !== undefined\n ? ctm.combine(\n () => this.#open_lines(),\n () => this.#selection_lines(),\n row_options.context_menu,\n )\n : row_options.context_menu;\n if (menu)\n ctm.attach(this, menu, () => {\n const from_sub_row = this.#sub_row_menu;\n this.#sub_row_menu = false;\n return from_sub_row;\n });\n }\n\n /**Replaces the fields with the text and removes everything else the row options gave */\n #set_invalid(text: string) {\n this.#selection_update(false);\n if (this.#key_field) this.#key_field.options = undefined;\n this.#sub_rows = undefined;\n this.add_row = undefined;\n this.#open_pending = false;\n this.detach_state_from_prop(\"openable\");\n this.openable = false;\n ctm.detach(this);\n this.#sub_row_menu = false;\n if (!this.#invalid) {\n this.#invalid = new ListError();\n //With sub rows the text is in the key field after the tree lines, it runs from the key column to the end\n if (this.#key_field) {\n this.#key_field.tail = this.#invalid;\n this.#show_cells([]);\n } else this.#show_cells([this.#invalid]);\n }\n this.#invalid.text = text;\n }\n\n set add_row(options: ListAddRowOptions | undefined) {\n if (!options && this.#add_row) {\n this.#add_row.remove();\n this.classList.remove(\"addrow\");\n this.#add_row = undefined;\n } else if (options) {\n if (!this.#add_row) {\n this.classList.add(\"addrow\");\n this.#add_row = this.appendChild(\n new ListAddRow<R, T, A, S>(this.#root, this),\n );\n }\n this.#add_row.options = options;\n }\n }\n\n // ____ _____ ______ _ _ _____ _ _ _____\n // / __ \\| __ \\| ____| \\ | |_ _| \\ | |/ ____|\n // | | | | |__) | |__ | \\| | | | | \\| | | __\n // | | | | ___/| __| | . ` | | | | . ` | | |_ |\n // | |__| | | | |____| |\\ |_| |_| |\\ | |__| |\n // \\____/|_| |______|_| \\_|_____|_| \\_|\\_____|\n\n set openable(value: boolean) {\n if (!value) this.open = false;\n if (this.#key_field) this.#key_field.openable = value;\n if (this.#open_pending) {\n this.#open_pending = false;\n if (value) this.open = true;\n }\n }\n get openable(): boolean {\n return this.#key_field?.openable ?? false;\n }\n\n set open(open: boolean) {\n if (!this.openable) return;\n if (open && this.#child_box.childElementCount === 0) {\n const rows = this.#drop_rows ?? this.#sub_rows?.();\n this.#drop_rows = undefined;\n if (rows) this.rows = rows;\n } else if (!open && this.open) this.rows = [];\n }\n get open(): boolean {\n return this.classList.contains(\"open\");\n }\n\n // _____ ______ _______\n // | __ \\ / __ \\ \\ / / ____|\n // | |__) | | | \\ \\ /\\ / / (___\n // | _ /| | | |\\ \\/ \\/ / \\___ \\\n // | | \\ \\| |__| | \\ /\\ / ____) |\n // |_| \\_\\\\____/ \\/ \\/ |_____/\n\n get index(): number {\n return Array.prototype.indexOf.call(this.parentElement!.children, this);\n }\n\n amount_rows(rec: boolean = false): number {\n let count = this.#child_box.childElementCount;\n if (rec)\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n count += (\n this.#child_box.children[i] as ListRow<R, T, A, S>\n ).amount_rows(true);\n return count;\n }\n\n set rows(rows: R[] | State<R[]>) {\n if (this.#state_sub) this.detach_state(this.#state_sub);\n this.#state_sub = undefined;\n //R is the item type of A\n this.state = rows as ListParentRows<A>;\n if (state.is.state(rows))\n this.#state_sub = this.attach_state(rows, (r) =>\n this.#update_rows(r.ok ? r.value : [], r.ok ? undefined : r.error),\n );\n else this.#update_rows(rows);\n }\n\n #update_rows(rows: readonly R[], error?: string) {\n this.#error = list_rows_error_update(\n this.#child_box,\n this.#error,\n error,\n this.#root.sub_rows,\n this,\n );\n this.classList.toggle(\"open\", rows.length > 0 || error !== undefined);\n list_rows_apply(this.#root, this, this.#child_box, rows);\n }\n\n // _____ ______ _ ______ _____ _______ _____ ____ _ _\n // / ____| ____| | | ____/ ____|__ __|_ _/ __ \\| \\ | |\n // | (___ | |__ | | | |__ | | | | | || | | | \\| |\n // \\___ \\| __| | | | __|| | | | | || | | | . ` |\n // ____) | |____| |____| |___| |____ | | _| || |__| | |\\ |\n // |_____/|______|______|______\\_____| |_| |_____\\____/|_| \\_|\n\n #selection_setup(selection: ListSelection<unknown>) {\n const clear_click_focus = (e: Event) =>\n (e.currentTarget as HTMLElement).classList.remove(\"click-focus\");\n if (selection.column) {\n this.#check = new ListCheckField();\n //The key field is the keyboard cell when there is one\n if (!this.#key_field) this.#check.tabIndex = 0;\n this.#check.onkeydown = (e) => {\n if (this.key_down(e)) e.preventDefault();\n };\n this.#check.onclick = (e) => {\n e.stopPropagation();\n //Focus first, moving the focus after the warning would close it\n this.#focus_after_click();\n if (this.selection_key !== undefined)\n selection.check_click(this.selection_key);\n else selection.on_error?.(this, NOT_SELECTABLE);\n };\n }\n for (const cell of [this.#check, this.#key_field])\n if (cell) {\n cell.addEventListener(\"keydown\", clear_click_focus);\n cell.addEventListener(\"blur\", clear_click_focus);\n }\n this.#field_box.onclick = (e) => {\n //Focus first, moving the focus after the warning would close it\n this.#focus_after_click();\n if (this.selection_key !== undefined)\n selection.click(this.selection_key, e);\n else selection.on_error?.(this, NOT_SELECTABLE);\n };\n //Shift click would select text between the rows\n this.#field_box.onmousedown = (e) => {\n if (e.shiftKey && selection.multi) e.preventDefault();\n };\n }\n\n /**Registers the row in the selection with the key of its data, or removes it when not selectable */\n #selection_update(selectable: boolean, data?: R) {\n const selection = this.#root.selection;\n if (!selection) return;\n const key: unknown = selectable ? selection.key(data) : undefined;\n if (key === this.selection_key) return;\n if (this.selection_key !== undefined)\n selection.unregister(this.selection_key, this);\n this.selection_key = key;\n if (key !== undefined) selection.register(key, this);\n this.classList.toggle(\"selectable\", key !== undefined);\n }\n\n /**Context menu lines to open or close the sub rows of an openable row, and to close all rows while one is open\n * Close all is on every row, so a list without header can close all */\n #open_lines(): ContextMenuLines {\n const lines: ContextMenuLines = [];\n if (this.openable)\n lines.push(\n this.open\n ? ctm.line(\"Close\", () => (this.open = false))\n : ctm.line(\"Open\", () => (this.open = true)),\n );\n if (this.#root.any_open())\n lines.push(ctm.line(\"Close all\", () => this.#root.close_all()));\n return lines;\n }\n\n /**Context menu lines to select or deselect the row, and in multi mode all rows\n * Empty when the row can not be selected */\n #selection_lines(): ContextMenuLines {\n const selection = this.#root.selection;\n const key = this.selection_key;\n if (!selection || key === undefined) return [];\n const lines: ContextMenuLines = [\n selection.is_selected(key)\n ? ctm.line(\"Deselect\", () => selection.deselect(key))\n : ctm.line(\"Select\", () => selection.select(key)),\n ];\n if (selection.multi)\n lines.push(\n ctm.line(\n \"Select all\",\n () => selection.select_all(),\n undefined,\n \"Ctrl+A\",\n ),\n ctm.line(\"Deselect all\", () => selection.clear(), undefined, \"Esc\"),\n );\n return lines;\n }\n\n // __ __ ______ _______ _ _ _____\n // | \\/ |/ __ \\ \\ / /_ _| \\ | |/ ____|\n // | \\ / | | | \\ \\ / / | | | \\| | | __\n // | |\\/| | | | |\\ \\/ / | | | . ` | | |_ |\n // | | | | |__| | \\ / _| |_| |\\ | |__| |\n // |_| |_|\\____/ \\/ |_____|_| \\_|\\_____|\n\n get data(): R {\n return this.#data;\n }\n\n /**Moving of the list the row is in, undefined when its rows can not be moved */\n get reorder() {\n return this.#root.reorder;\n }\n\n /**Rows of the parent the row is in */\n get parent_rows(): ListParentRows<A> {\n return this.#parent.state;\n }\n\n /**Row the row is a sub row of, undefined for top level rows */\n get parent_row(): ListRow<R, T, A, S> | undefined {\n return this.#parent instanceof ListRow ? this.#parent : undefined;\n }\n\n get next_row(): ListRow<R, T, A, S> | undefined {\n const next = this.nextElementSibling;\n return next instanceof ListRow ? next : undefined;\n }\n\n get first_sub_row(): ListRow<R, T, A, S> | undefined {\n const first = this.#child_box.firstElementChild;\n return first instanceof ListRow ? first : undefined;\n }\n\n /**Whether the row has a handle and its parent rows can be written */\n get movable(): boolean {\n return this.classList.contains(\"movable\");\n }\n\n /**Whether rows can be dropped into the row, it must be openable with sub rows in a writable state */\n get droppable(): boolean {\n if (!this.openable) return false;\n const rows = this.drop_rows();\n return state.is.state(rows) && rows.writable;\n }\n\n /**The sub rows rows are dropped into, also of a closed row */\n drop_rows(): R[] | State<R[]> | undefined {\n if (this.open) return this.state;\n return (this.#drop_rows ??= this.#sub_rows?.());\n }\n\n /**Whether the row is selected in a list with multi selection, a drag of it moves all selected rows */\n get multi_selected(): boolean {\n return this.selected && Boolean(this.#root.selection?.multi);\n }\n\n /**Text naming the row while it is dragged, the key field text or the text of the first cell */\n get label(): string {\n const text =\n this.#key_field?.querySelector(\".text\")?.textContent ||\n this.#fields[0]?.textContent ||\n \"\";\n return text.trim();\n }\n\n /**First visible cell of the row, the row itself is display contents and has no box */\n get anchor(): Element | undefined {\n return this.#field_box.firstElementChild ?? undefined;\n }\n\n set selected(value: boolean) {\n this.classList.toggle(\"selected\", value);\n }\n get selected(): boolean {\n return this.classList.contains(\"selected\");\n }\n\n /**Removes the row and its sub rows from the selection, when the row is removed */\n selection_leave() {\n const selection = this.#root.selection;\n if (!selection) return;\n if (this.selection_key !== undefined)\n selection.unregister(this.selection_key, this);\n this.selection_key = undefined;\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n (this.#child_box.children[i] as ListRow<R, T, A, S>).selection_leave();\n }\n}\ndefine_element(ListRow);\n\n/**Applies rows to a row box, removed rows leave the selection, which updates once after all changes */\nexport function list_rows_apply<\n R,\n T extends {},\n A extends ListType<R>,\n S extends boolean,\n>(\n root: ListRoot<R, T, A, S>,\n parent: ListRowParent<A>,\n box: HTMLElement,\n rows: readonly R[],\n) {\n const apply = () =>\n state_ui.a.apply(box, rows, {\n create: (row) => new ListRow<R, T, A, S>(root, parent, row),\n update: (element, row) => (element.data = row),\n destroy: (element) => element.selection_leave(),\n });\n if (root.selection) root.selection.batch(apply);\n else apply();\n}\n","import { theme_init_variable_root } from \"#theme\";\nimport { BLUE, GREY, ORANGE, RED } from \"@chocbite/ts-lib/colors\";\n\nconst theme_root = theme_init_variable_root(\n \"list\",\n \"UI List Elements\",\n \"Theme variables for UI list elements\",\n);\n\n// _____ ______ _____ ____ _ _ _ __ __\n// | __ \\| ____| /\\ | __ \\ / __ \\| \\ | | | \\ \\ / /\n// | |__) | |__ / \\ | | | | | | | | \\| | | \\ \\_/ /\n// | _ /| __| / /\\ \\ | | | | | | | | . ` | | \\ /\n// | | \\ \\| |____ / ____ \\| |__| | | |__| | |\\ | |____| |\n// |_| \\_\\______/_/ \\_\\_____/ \\____/|_| \\_|______|_|\nconst read_only = theme_root.make_sub_group(\n \"read\",\n \"Read Only\",\n \"Settings for list elements in read only mode\",\n);\nread_only.make_variable(\n \"filter\",\n \"Read Only Filter\",\n \"Filter applied to list elements in read only mode\",\n \"opacity(0.6)\",\n \"opacity(0.6)\",\n \"Filter\",\n undefined,\n);\n\n//#################################################################################3\n//#################################################################################3\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors = theme_root.make_sub_group(\n \"colors\",\n \"Colors\",\n \"Colors used in all list elements\",\n);\n\n// _______ ________ _________ _____ ____ _ ____ _____ _____\n// |__ __| ____\\ \\ / /__ __| / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | |__ \\ V / | | | | | | | | | | | | | |__) | (___\n// | | | __| > < | | | | | | | | | | | | | _ / \\___ \\\n// | | | |____ / . \\ | | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |_| |______/_/ \\_\\ |_| \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_text = colors.make_sub_group(\n \"text\",\n \"Text Colors\",\n \"Text colors used in all list elements\",\n);\ncolors_text.make_variable(\n \"header\",\n \"Header Text Color\",\n \"Header text color in list elements\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"field\",\n \"Field Text Color\",\n \"Text color of list field elements\",\n GREY[\"800\"],\n GREY[\"100\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"key_field\",\n \"Special Column Text Color\",\n \"Text color of special first column elements\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"add\",\n \"Row Adder Text Color\",\n \"Text color of row adder button\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"error\",\n \"Error Text Color\",\n \"Text color of list errors and invalid rows\",\n RED[\"800\"],\n RED[\"200\"],\n \"Color\",\n undefined,\n);\n\n// _____ _____ ____ _ _ _____ ____ _ ____ _____ _____\n// |_ _/ ____/ __ \\| \\ | | / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | || | | | | | \\| | | | | | | | | | | | | |__) | (___\n// | || | | | | | . ` | | | | | | | | | | | | _ / \\___ \\\n// _| || |___| |__| | |\\ | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |_____\\_____\\____/|_| \\_| \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_icon = colors.make_sub_group(\n \"icon\",\n \"Icon Colors\",\n \"Icon colors used in all form elements\",\n);\ncolors_icon.make_variable(\n \"sub_opener\",\n \"Sub Row Opener Icon Color\",\n \"Color of the sub row opener icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"key_icon\",\n \"Key Field Icon Color\",\n \"Color of the key field icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"drag\",\n \"Drag Handle Color\",\n \"Color of the drag handles that move rows\",\n GREY[\"600\"],\n GREY[\"400\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"check\",\n \"Selection Checkbox Color\",\n \"Color of the selection checkboxes\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"add_icon\",\n \"Add Row Icon Color\",\n \"Color of the add row icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\n\n// ____ _____ _ _______ _____ ____ _ _ _ _ _____ _____ ____ _ ____ _____ _____\n// | _ \\ /\\ / ____| |/ / ____| __ \\ / __ \\| | | | \\ | | __ \\ / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | |_) | / \\ | | | ' / | __| |__) | | | | | | | \\| | | | | | | | | | | | | | | | |__) | (___\n// | _ < / /\\ \\| | | <| | |_ | _ /| | | | | | | . ` | | | | | | | | | | | | | | | _ / \\___ \\\n// | |_) / ____ \\ |____| . \\ |__| | | \\ \\| |__| | |__| | |\\ | |__| | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |____/_/ \\_\\_____|_|\\_\\_____|_| \\_\\\\____/ \\____/|_| \\_|_____/ \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_background = colors.make_sub_group(\n \"background\",\n \"Background Colors\",\n \"Background colors used in all list elements\",\n);\ncolors_background.make_variable(\n \"row_even\",\n \"Even Row Background Color\",\n \"Color of even row element backgrounds\",\n GREY[\"200\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_odd\",\n \"Odd Row Background Color\",\n \"Color of odd row element backgrounds\",\n GREY[\"50\"],\n GREY[\"900\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_hover\",\n \"Hover Row Background Color\",\n \"Color of row element backgrounds when hovering\",\n GREY[\"300\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_selected\",\n \"Selected Row Background Color\",\n \"Color of selected row element backgrounds\",\n BLUE[\"100\"],\n BLUE[\"900\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_selected_hover\",\n \"Selected Hover Row Background Color\",\n \"Color of selected row element backgrounds when hovering\",\n BLUE[\"200\"],\n BLUE[\"800\"],\n \"Color\",\n undefined,\n);\n\n// ____ ____ _____ _____ ______ _____ _____ ____ _ ____ _____ _____\n// | _ \\ / __ \\| __ \\| __ \\| ____| __ \\ / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | |_) | | | | |__) | | | | |__ | |__) | | | | | | | | | | | | |__) | (___\n// | _ <| | | | _ /| | | | __| | _ / | | | | | | | | | | | _ / \\___ \\\n// | |_) | |__| | | \\ \\| |__| | |____| | \\ \\ | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |____/ \\____/|_| \\_\\_____/|______|_| \\_\\ \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_border = colors.make_sub_group(\n \"border\",\n \"Border Colors\",\n \"Border colors used in all list elements\",\n);\ncolors_border.make_variable(\n \"header\",\n \"Header Border Color\",\n \"Color of borders under header\",\n GREY[\"600\"],\n GREY[\"400\"],\n \"Color\",\n undefined,\n);\ncolors_border.make_variable(\n \"row\",\n \"Row Border Color\",\n \"Color of borders between rows\",\n GREY[\"400\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\ncolors_border.make_variable(\n \"column\",\n \"Column Border Color\",\n \"Color of border between columns\",\n GREY[\"500\"],\n GREY[\"500\"],\n \"Color\",\n undefined,\n);\n\n// ______ ____ _____ _ _ _____\n// | ____/ __ \\ / ____| | | |/ ____|\n// | |__ | | | | | | | | | (___\n// | __|| | | | | | | | |\\___ \\\n// | | | |__| | |____| |__| |____) |\n// |_| \\____/ \\_____|\\____/|_____/\nconst colors_focus = colors.make_sub_group(\n \"focus\",\n \"Focus Colors\",\n \"Focus colors used in all list elements\",\n);\ncolors_focus.make_variable(\n \"normal\",\n \"Focus Color\",\n \"Color of focussed list element\",\n ORANGE[\"600\"],\n ORANGE[\"300\"],\n \"Color\",\n undefined,\n);\n\n//#################################################################################3\n//#################################################################################3\n// _____ _____ ____________ _____\n// / ____|_ _|___ / ____|/ ____|\n// | (___ | | / /| |__ | (___\n// \\___ \\ | | / / | __| \\___ \\\n// ____) |_| |_ / /__| |____ ____) |\n// |_____/|_____/_____|______|_____/\nconst sizes = theme_root.make_sub_group(\n \"size\",\n \"Size\",\n \"Sizes used in all list elements\",\n);\n\nsizes.make_variable(\n \"row_min\",\n \"Row Minimum Height\",\n \"Minimum height for list rows\",\n \"1.4rem\",\n \"1.4rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"touch_row_min\",\n \"Touch Row Minimum Height\",\n \"Minimum height for list rows on touch devices\",\n \"2.6rem\",\n \"2.6rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"add_min\",\n \"Add Row Minimum Height\",\n \"Minimum height for add row button\",\n \"1rem\",\n \"1rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"touch_add_min\",\n \"Touch Add Row Minimum Height\",\n \"Minimum height for add row button on touch devices\",\n \"2rem\",\n \"2rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\n//#################################################################################3\n//#################################################################################3\n// _ _ _____ __ __ _______ _____ ____ _ _\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | |\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ |\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_|\nconst animation = theme_root.make_sub_group(\n \"animation\",\n \"Animation\",\n \"Animation settings used in all list elements\",\n);\n\nanimation.make_variable(\n \"transitionType\",\n \"Transition Type\",\n \"Type of transition used in list element animations\",\n \"ease-in-out\",\n \"ease-in-out\",\n \"TransitionType\",\n undefined,\n);\n\nanimation.make_variable(\n \"transitionDuration\",\n \"Transition Duration\",\n \"Duration of transitions used in list element animations\",\n \"200ms\",\n \"200ms\",\n \"Time\",\n { min: 0, max: 5000 },\n);\n\n//#################################################################################3\n//#################################################################################3\n// ______ ____ _ _ _______\n// | ____/ __ \\| \\ | |__ __|\n// | |__ | | | | \\| | | |\n// | __|| | | | . ` | | |\n// | | | |__| | |\\ | | |\n// |_| \\____/|_| \\_| |_|\nconst font = theme_root.make_sub_group(\n \"font\",\n \"Font\",\n \"Font settings used in all list elements\",\n);\n\nfont.make_variable(\n \"size\",\n \"Font Size\",\n \"Default font size used in all list elements\",\n \"1rem\",\n \"1rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nfont.make_variable(\n \"touchSize\",\n \"Touch Font Size\",\n \"Font size used in all list elements for touch devices\",\n \"1.2rem\",\n \"1.2rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n","/**Shows why a write of the list failed as the validation message of the browser, at the row it is about, like the form elements do\n * One hidden input in the container is placed over the row before the message is shown, it clears after 5 seconds */\nexport class ListWarn {\n #container: HTMLElement;\n #input: HTMLInputElement;\n #timeout?: number;\n\n constructor(container: HTMLElement) {\n this.#container = container;\n this.#input = container.appendChild(document.createElement(\"input\"));\n this.#input.className = \"list-warn\";\n this.#input.tabIndex = -1;\n }\n\n /**Shows the message at the element, or at the top of the list without element\n * @param at element to point at, rows are display contents, so give one of their cells */\n show(at: Element | undefined, message: string) {\n const input = this.#input;\n const container = this.#container;\n const box = container.getBoundingClientRect();\n const rect = at?.getBoundingClientRect() ?? box;\n input.style.top = rect.top - box.top + container.scrollTop + \"px\";\n input.style.left =\n Math.max(rect.left - box.left, 0) + container.scrollLeft + \"px\";\n input.style.width = rect.width + \"px\";\n input.style.height = rect.height + \"px\";\n //Showing the message can move the focus to the input, the keyboard cell keeps it\n const focused = document.activeElement;\n input.setCustomValidity(message);\n input.reportValidity();\n if (focused instanceof HTMLElement && focused !== document.activeElement)\n focused.focus({ preventScroll: true });\n if (this.#timeout) clearTimeout(this.#timeout);\n this.#timeout = window.setTimeout(() => {\n input.setCustomValidity(\"\");\n input.reportValidity();\n }, 5000);\n }\n}\n","import { Base, define_element, type BaseIntersectObserver } from \"#base\";\nimport ctm from \"#context-menu\";\nimport { px_to_rem } from \"#theme\";\nimport {\n state,\n type State,\n type StateInferSub,\n type StateREAW,\n type StateSub,\n} from \"@chocbite/ts-lib/state\";\nimport type { Result } from \"@chocbite/ts-lib/result\";\nimport { ListAddRow, type ListAddRowOptions } from \"./add_row\";\nimport { ListDragField, ListReorder, type ListReorderOptions } from \"./drag\";\nimport \"./container.scss\";\nimport { list_rows_error_update, type ListRowsError } from \"./error\";\nimport { list_align_apply } from \"./field\";\nimport { list_rows_apply, ListRow } from \"./row\";\nimport {\n ListCheckField,\n ListSelection,\n type ListSelectionOptions,\n} from \"./selection\";\nimport \"./shared\";\nimport { ListWarn } from \"./warn\";\nimport type {\n ListColumnOptions,\n ListRoot,\n ListRowParent,\n ListRowTransformer,\n ListType,\n ListTypeExtract,\n} from \"./types.ts\";\n\n/**Most rows open all opens at a time, a mistake making the sub rows recursive would otherwise never end */\nconst OPEN_ALL_LIMIT = 1000;\n\nclass HeaderField extends Base {\n static element_name() {\n return \"headerfield\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n #box = this.appendChild(document.createElement(\"div\"));\n #text = this.#box.appendChild(document.createElement(\"span\"));\n #sizer?: HTMLDivElement;\n\n constructor(text?: string) {\n super();\n if (text) this.text = text;\n }\n\n /**Elements shown instead of the text */\n set nodes(nodes: Node[]) {\n this.#text.replaceChildren(...nodes);\n }\n\n set text(value: string) {\n this.#text.textContent = value;\n }\n\n sizable(sizeable: boolean, sizer: (width: number | undefined) => void) {\n if (sizeable) {\n this.#sizer = this.#box.appendChild(document.createElement(\"div\"));\n let double_timeout: number;\n this.#sizer.onpointerdown = (e) => {\n e.preventDefault();\n if (double_timeout) {\n sizer(undefined);\n return;\n }\n double_timeout = window.setTimeout(() => {\n double_timeout = 0;\n }, 300);\n this.setPointerCapture(e.pointerId);\n const handle = e.currentTarget as HTMLElement;\n handle.classList.add(\"active\");\n const start_x = e.pageX;\n const start_width = this.#box.offsetWidth;\n this.onpointermove = (ev: PointerEvent) => {\n sizer(px_to_rem(start_width + (ev.pageX - start_x)));\n };\n //A cancel or lost capture also ends the resize, a touch the browser takes for something else cancels\n const end = () => {\n if (this.hasPointerCapture(e.pointerId))\n this.releasePointerCapture(e.pointerId);\n handle.classList.remove(\"active\");\n this.onpointermove = null;\n this.onpointerup = null;\n this.onpointercancel = null;\n this.onlostpointercapture = null;\n };\n this.onpointerup = end;\n this.onpointercancel = end;\n this.onlostpointercapture = end;\n };\n } else if (this.#sizer) {\n this.#sizer.remove();\n this.#sizer = undefined;\n }\n }\n}\ndefine_element(HeaderField);\n\nclass HeaderRow<\n R,\n T extends {},\n A extends ListType<R>,\n S extends boolean,\n> extends Base {\n static element_name() {\n return \"headerrow\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n set fields(fields: HeaderField[]) {\n const lead: HTMLElement[] = [];\n if (this.#drag_header) lead.push(this.#drag_header);\n if (this.#check_header) lead.push(this.#check_header);\n if (this.#key_header) lead.push(this.#key_header);\n this.replaceChildren(...lead, ...fields);\n }\n\n /**Header of the key field column, only with sub rows */\n get key_header(): HTMLElement | undefined {\n return this.#key_header;\n }\n\n /**Header of the key field column, only with sub rows */\n #key_header?: HeaderField;\n /**Empty header of the drag handle column */\n #drag_header?: ListDragField;\n /**Header of the checkbox or radio button column, in multi mode it selects or deselects all rows */\n #check_header?: ListCheckField;\n\n constructor(\n root: ListRoot<R, T, A, S>,\n key_sizer: (width: number | undefined) => void,\n ) {\n super();\n if (root.sub_rows) {\n const key = (this.#key_header = new HeaderField());\n key.classList.add(\"key\");\n const button = (kind: string, action: () => void) => {\n const span = document.createElement(\"span\");\n span.className = `list-${kind}-all`;\n span.onclick = action;\n return span;\n };\n key.nodes = [\n button(\"close\", () => root.close_all()),\n button(\"open\", () => root.open_all()),\n ];\n ctm.attach(\n key,\n ctm.menu([\n ctm.line(\"Open all\", () => root.open_all()),\n ctm.line(\"Close all\", () => root.close_all()),\n ]),\n );\n key.sizable(true, key_sizer);\n }\n if (root.reorder) this.#drag_header = new ListDragField();\n const selection = root.selection;\n if (selection?.column) this.#check_header = new ListCheckField();\n if (selection?.multi) {\n const check = this.#check_header!;\n check.onclick = () => {\n if (selection.amount_selected > 0) selection.clear();\n else selection.select_all();\n };\n ctm.attach(\n check,\n ctm.menu([\n ctm.line(\n \"Select all\",\n () => selection.select_all(),\n undefined,\n \"Ctrl+A\",\n ),\n ctm.line(\"Deselect all\", () => selection.clear(), undefined, \"Esc\"),\n ]),\n );\n selection.on_change = () => {\n const selected = selection.amount_selected;\n check.classList.toggle(\"some\", selected > 0);\n check.classList.toggle(\n \"all\",\n selected > 0 && selected === selection.amount_selectable,\n );\n };\n }\n }\n}\ndefine_element(HeaderRow);\n\ninterface ContainerOptions<S extends boolean = false, R = unknown, K = R> {\n /**Should header row be omitted */\n headless?: boolean;\n /**Can rows have sub rows */\n sub_rows?: S;\n /**Options for an add row button */\n add_row?: ListAddRowOptions;\n /**If list should use a container to give fields the option of attach/detach to states when visible */\n observer?: BaseIntersectObserver;\n /**Lets the user select rows, only rows that are visible can be selected */\n selection?: ListSelectionOptions<R, K>;\n /**Lets the user move rows with a drag handle in front of the rows, rows in a writable array state can be moved */\n reorder?: ListReorderOptions<R>;\n}\n\nclass Container<\n A extends ListType<any>,\n T extends { [key: string]: ListColumnOptions<any, any> },\n S extends boolean = false,\n R = ListTypeExtract<A>,\n K = R,\n> extends Base {\n static element_name() {\n return \"container\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n #root: ListRoot<R, T, A, S>;\n #selection?: ListSelection<K>;\n #selection_sub?: StateSub<Result<K[], string>>;\n #parent: ListRowParent<A>;\n #box = this.appendChild(document.createElement(\"div\"));\n #header?: HeaderRow<R, T, A, S>;\n #child_box: HTMLDivElement;\n #error?: ListRowsError<A>;\n #add_row?: ListAddRow<R, T, A, S>;\n #state_sub?: StateInferSub<State<R[]>>;\n /**Width of the key field column in rem set by resizing, fits the key fields when undefined */\n #key_width?: number;\n /**Shows why a write failed, or that open all stopped */\n #warn?: ListWarn;\n\n constructor(\n columns: { [C in keyof T]: ListColumnOptions<T[C], any> },\n transform: ListRowTransformer<R, T, A, S>,\n rows: A,\n options?: ContainerOptions<S, R, K>,\n ) {\n super();\n this.#root = {\n sub_rows: options?.sub_rows ?? (false as S),\n columns: new Map(),\n columns_visible: [],\n transform,\n observer: options?.observer,\n open_all: () => this.open_all(),\n close_all: () => this.close_all(),\n any_open: () => this.#open_rows().length > 0,\n };\n this.#parent = {\n depth: -1,\n open: false,\n select_adjacent() {},\n state: rows,\n };\n\n this.#child_box = document.createElement(\"div\");\n //Shows why a write of the selection or a move failed\n const warn =\n options?.selection || options?.reorder || options?.sub_rows\n ? new ListWarn(this)\n : undefined;\n this.#warn = warn;\n if (options?.reorder) {\n this.#root.reorder = new ListReorder(this, options.reorder, warn!);\n this.#box.classList.add(\"drag\");\n }\n if (options?.selection) {\n this.#selection = new ListSelection(\n options.selection,\n this.#child_box,\n Boolean(options.sub_rows),\n );\n this.#root.selection = this.#selection;\n if (this.#selection.column) this.#box.classList.add(\"check\");\n this.#box.classList.add(this.#selection.multi ? \"multi\" : \"single\");\n this.#selection.on_error = (row, message) =>\n warn!.show(row?.anchor ?? this.#header ?? this.#box, message);\n }\n //Columns in front of the key field column, the error and add rows start after them\n const lead =\n Number(Boolean(options?.reorder)) +\n Number(Boolean(this.#selection?.column));\n if (lead) this.#box.classList.add(\"lead-\" + lead);\n\n if (!options?.headless)\n this.#header = this.#box.appendChild(\n new HeaderRow(this.#root, (width) => {\n this.#key_width = width;\n this.#update_column_widths();\n }),\n );\n this.#box.appendChild(this.#child_box);\n if (options?.sub_rows) this.#box.classList.add(\"sub-rows\");\n this.add_row = options?.add_row;\n\n this.columns = columns;\n this.rows = rows;\n //Selection works without a bound state, in a state of its own nobody else can reach\n if (this.#selection) this.bind({});\n }\n\n set columns(columns: { [C in keyof T]: ListColumnOptions<T[C], any> }) {\n this.#root.columns.clear();\n const order = new Map<keyof T, number>();\n let index = 0;\n for (const key in columns) {\n //Copied, so resizing does not write into the callers options\n this.#root.columns.set(key, { ...columns[key as keyof T] });\n order.set(key, columns[key].order ?? index);\n index++;\n }\n this.#root.columns_visible = [...order.keys()].sort(\n (a, b) => order.get(a)! - order.get(b)!,\n );\n\n if (this.#header) {\n const headers = this.#root.columns_visible.map((key) => {\n const column = this.#root.columns.get(key)!;\n const header = new HeaderField(column.title);\n list_align_apply(header, column.align);\n header.sizable(typeof column.fixed_width === \"undefined\", (width) => {\n if (width !== undefined) this.#freeze_auto_widths(headers);\n column.init_width = width;\n this.#update_column_widths();\n });\n return header;\n });\n this.#header.fields = headers;\n }\n this.#update_column_widths();\n\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n (this.#child_box.children[i] as ListRow<R, T, A, S>).columns_changed();\n }\n\n /**Gives the auto width columns their current width, so resizing one column does not resize the others\n * Only measures while there are auto width columns, so after the first resize a move does no layout here*/\n #freeze_auto_widths(headers: HeaderField[]) {\n const auto = this.#root.columns_visible.flatMap((key, i) => {\n const col = this.#root.columns.get(key)!;\n return col.fixed_width === undefined && !col.init_width ? [i] : [];\n });\n //Measured before any is set, setting one would change the layout of the rest\n const widths = auto.map((i) => px_to_rem(headers[i].offsetWidth));\n auto.forEach((i, j) => {\n this.#root.columns.get(this.#root.columns_visible[i])!.init_width =\n widths[j];\n });\n }\n\n /**Opens every openable row, level by level so the upper levels are open first\n * Stops with a warning after opening OPEN_ALL_LIMIT rows, against huge or recursive sub rows, opening all again continues */\n open_all() {\n let opened = 0;\n let level = this.#top_rows();\n while (level.length) {\n const next: ListRow<R, T, A, S>[] = [];\n for (const row of level) {\n if (row.openable && !row.open) {\n if (opened >= OPEN_ALL_LIMIT) {\n this.#warn?.show(\n this.#header?.key_header ?? this.#box,\n `Stopped after opening ${OPEN_ALL_LIMIT} rows, open all again for more`,\n );\n return;\n }\n row.open = true;\n opened += row.amount_rows();\n }\n for (let sub = row.first_sub_row; sub; sub = sub.next_row)\n next.push(sub);\n }\n level = next;\n }\n }\n\n /**Closes every open row, closing the top rows removes everything below them */\n close_all() {\n for (const row of this.#open_rows()) row.open = false;\n }\n\n #top_rows(): ListRow<R, T, A, S>[] {\n return [...this.#child_box.children] as ListRow<R, T, A, S>[];\n }\n\n #open_rows(): ListRow<R, T, A, S>[] {\n return this.#top_rows().filter((row) => row.open);\n }\n\n #update_column_widths() {\n const widths: string[] = this.#root.columns_visible.map((key) => {\n const col = this.#root.columns.get(key)!;\n //Without a header nothing can resize, so init_width, the start of a resize, does not apply\n const width =\n col.fixed_width ?? (this.#header ? col.init_width : undefined);\n if (width) {\n if (width === \"min\") return \"min-content\";\n else if (width === \"max\") return \"max-content\";\n return `${Math.max(width, 1)}rem`;\n }\n return \"auto\";\n });\n //The key fields get the width instead of the column, so it never gets smaller than its widest key field minimum\n //Without value columns it fills the list unless resized\n if (this.#root.sub_rows)\n widths.unshift(widths.length || this.#key_width ? \"max-content\" : \"auto\");\n this.#box.classList.toggle(\"key-sized\", Boolean(this.#key_width));\n if (this.#key_width)\n this.#box.style.setProperty(\n \"--list-key-width\",\n `${Math.max(this.#key_width, 1)}rem`,\n );\n else this.#box.style.removeProperty(\"--list-key-width\");\n if (this.#selection?.column) widths.unshift(\"var(--list-check-width)\");\n if (this.#root.reorder) widths.unshift(\"var(--list-drag-width)\");\n this.#box.style.gridTemplateColumns = widths.join(\" \");\n }\n\n set add_row(options: ListAddRowOptions | undefined) {\n if (!options && this.#add_row) {\n this.#add_row.remove();\n this.#box.classList.remove(\"addrow\");\n this.#add_row = undefined;\n } else if (options) {\n if (!this.#add_row) {\n this.#box.classList.add(\"addrow\");\n this.#add_row = this.#box.appendChild(\n new ListAddRow<R, T, A, S>(this.#root, this.#parent),\n );\n }\n this.#add_row.options = options;\n }\n }\n\n // _____ ______ _______\n // | __ \\ / __ \\ \\ / / ____|\n // | |__) | | | \\ \\ /\\ / / (___\n // | _ /| | | |\\ \\/ \\/ / \\___ \\\n // | | \\ \\| |__| | \\ /\\ / ____) |\n // |_| \\_\\\\____/ \\/ \\/ |_____/\n\n amount_rows(rec: boolean = false): number {\n let count = this.#child_box.childElementCount;\n if (rec)\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n count += (\n this.#child_box.children[i] as ListRow<R, T, A, S>\n ).amount_rows(true);\n return count;\n }\n\n set rows(rows: R[] | State<R[]>) {\n if (this.#state_sub) this.detach_state(this.#state_sub);\n this.#state_sub = undefined;\n this.#parent.state = rows as A;\n if (state.is.state(rows))\n this.#state_sub = this.attach_state(rows, (r) =>\n this.#update_rows(r.ok ? r.value : [], r.ok ? undefined : r.error),\n );\n else this.#update_rows(rows);\n }\n\n #update_rows(rows: readonly R[], error?: string) {\n this.#error = list_rows_error_update(\n this.#child_box,\n this.#error,\n error,\n this.#root.sub_rows,\n this.#parent,\n );\n list_rows_apply(this.#root, this.#parent, this.#child_box, rows);\n }\n\n /**Binds the selection to an array state of keys, which can be shared with other lists and elements\n * The list shows the keys that have a visible row, and only writes the state on user actions,\n * with array write instructions, so it must be a state that applies them, like a local writable state\n * Without a state the selection is kept in a state of the list that nobody else can reach\n * Needs the selection option */\n bind(opts: { selection?: StateREAW<K[], any, K[]> }): this {\n const selection = this.#selection;\n if (!selection) {\n if (opts.selection) console.error(\"List has no selection option\", this);\n return this;\n }\n if (this.#selection_sub) this.detach_state(this.#selection_sub);\n const target = opts.selection ?? state.ok_w<K[]>([]);\n selection.target = target;\n this.#selection_sub = this.attach_state(\n target as StateREAW<K[]>,\n (value: Result<K[], string>) => selection.apply(value),\n );\n return this;\n }\n}\ndefine_element(Container);\n\nexport function container<\n A extends ListType<any>,\n T extends {},\n S extends boolean = false,\n R = ListTypeExtract<A>,\n K = R,\n>(\n columns: { [C in keyof T]: ListColumnOptions<T[C], any> },\n transform: ListRowTransformer<R, NoInfer<T>, A, S>,\n rows: A,\n options?: ContainerOptions<S, R, K>,\n) {\n return new Container<A, T, S, R, K>(columns, transform, rows, options);\n}\n","import type { BaseIntersectObserver } from \"#base\";\nimport { type Option, type Result } from \"@chocbite/ts-lib/result\";\nimport type { State } from \"@chocbite/ts-lib/state\";\nimport list from \".\";\nimport type { ListField, ListTextField } from \"./field\";\nimport type { ListRow, ListRowOptions } from \"./row\";\nimport type { ListReorder } from \"./drag\";\nimport type { ListSelection } from \"./selection\";\n\nexport type ListType<R> = R[] | State<R[]>;\n\nexport type ListTypeExtract<A extends ListType<any>> = A extends (infer U)[]\n ? U\n : A extends State<(infer U)[]>\n ? U\n : never;\n\n/**Rows of a row parent, the top level rows or sub rows, which can be an array or a state regardless of the top level rows */\nexport type ListParentRows<A extends ListType<any>> =\n A | ListType<ListTypeExtract<A>>;\n\nexport const ListDataType = {\n number: \"number\",\n string: \"string\",\n bool: \"bool\",\n} as const;\nexport type ListDataType = (typeof ListDataType)[keyof typeof ListDataType];\n\nexport type ListColumnAlign = \"left\" | \"center\" | \"right\";\n\nexport interface ListColumnOptions<V, C extends ListField> {\n /**Initial width of the column in rem, auto when undefined, ignored in a headless list as nothing can resize it*/\n init_width?: number;\n /**If the column has a fixed width in rem, overrides init_width and disables resizing*/\n fixed_width?: number | \"min\" | \"max\";\n /**Initial order of the column, lower numbers appear first, will order by column object if undefined\n * A column without order uses its position in the column object as order*/\n order?: number;\n /**Whether the column is reorderable by the user*/\n reorderable?: boolean;\n /**Data type of the column, used for sorting, will attempt auto detect if undefined*/\n type?: ListDataType;\n /**Horizontal alignment of the title and the fields, center when undefined\n * Text, number and node fields follow it, more complex fields like form fields do not */\n align?: ListColumnAlign;\n /**Column title*/\n title: string;\n /**Generates the field element, only called during row or column creation */\n field_gen(): C;\n /**Applies the value to the field */\n field_apply(field: C, value: V): void;\n}\n\n/**Helper to create a column object */\nexport function column<V, C extends ListField>(\n options: ListColumnOptions<V, C>,\n): ListColumnOptions<V, C> {\n return options;\n}\n\n/**Special helper to create a string value column */\nexport function column_string(\n /**Column title*/\n title: string,\n options?: { align?: ListColumnAlign },\n): ListColumnOptions<string, ListTextField> {\n return {\n title,\n align: options?.align,\n field_gen: () => list.text_field(),\n field_apply: (field, value) => (field.text = value),\n };\n}\n\n/**Transforms the data of a row into row options\n * Returning an error makes the row invalid, the error text then replaces the fields of the row\n * An invalid row is for failures with no other options, so it has no sub rows, add row or context menu */\nexport type ListRowTransformer<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n> = (\n /**Data of the row */\n data: R,\n /**The row the options are for */\n row: ListRow<R, T, A, S>,\n /**Rows the data is from, sub rows can come from an array or a state regardless of the top level rows */\n state: S extends true ? A | ListType<R> : A,\n) => Result<ListRowOptions<R, T, S>, string>;\n\nexport interface ListRoot<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n> {\n /**Sub rows */\n readonly sub_rows: S;\n /**Columns options mapped by column key */\n readonly columns: Map<keyof T, ListColumnOptions<T[keyof T], ListField>>;\n /**Order of visible columns by column key */\n columns_visible: (keyof T)[];\n /**Function to transform a row data into row options */\n transform: ListRowTransformer<R, T, A, S>;\n /**Observer for the container if observer is active */\n observer?: BaseIntersectObserver;\n /**Selection of rows, when enabled */\n selection?: ListSelection<any>;\n /**Moving of rows, when enabled */\n reorder?: ListReorder<R>;\n /**Opens every openable row, a limited amount of rows at a time */\n open_all(): void;\n /**Closes every open row */\n close_all(): void;\n /**Whether any row is open */\n any_open(): boolean;\n}\n\nexport interface ListRowParent<A extends ListType<any>> {\n /**Sub row depth */\n readonly depth: number;\n /**Whether the row is open to show sub rows */\n open: boolean;\n /**Selects the adjacent row in the given direction */\n select_adjacent(\n direction: \"next\" | \"previous\" | \"p_next\" | \"p_previous\" | \"last\",\n field: Option<number>,\n ): void;\n /**Rows of the parent, the rows of the container or the sub rows of a row */\n state: ListParentRows<A>;\n /**Handles a key pressed in the key field before the key field does, returns true when the key was used */\n key_down?(e: KeyboardEvent): boolean;\n}\n","import { container } from \"./container\";\nimport { ListDragGroup } from \"./drag\";\nimport { node_field, number_field, text_field } from \"./field\";\nimport { column, column_string } from \"./types\";\n\nexport const list = {\n column,\n column_string,\n container,\n text_field,\n number_field,\n node_field,\n /**Group of lists that can give rows to each other by dragging, all lists of a group must have the same row type */\n drag_group<R>(): ListDragGroup<R> {\n return new ListDragGroup<R>();\n },\n};\n\nexport { ListField } from \"./field\";\nexport type { ListDragGroup, ListDropTarget, ListReorderOptions } from \"./drag\";\n\nexport default list;\n"],"mappings":";;;;;;;;;;AAeA,IAAa,eAAb,cAA2D,KAAK;CAC9D,OAAO,eAAe;EACpB,OAAO;CACT;CACA,OAAO,qBAAqB;EAC1B,OAAO;CACT;CAEA;CACA;CACA;CACA;CAEA,YAAY,QAA0B;EACpC,MAAM;EACN,KAAK,WAAW;EAEhB,KAAK,MAAM,YAAY,oBAAoB,OAAO,OAAO,KAAK,CAAC;EAC/D,KAAK,aAAa,MAAM;GACtB,IAAI,OAAO,WAAW,CAAC,GAAG,EAAE,eAAe;QACtC,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK,OAAO,OAAO,CAAC,OAAO;QAC9D,IAA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K,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,aACA,6BACA,+CACA,KAAK,QACL,KAAK,OACL,SACA,KAAA,CACF;AACA,YAAY,cACV,OACA,wBACA,kCACA,KAAK,QACL,KAAK,OACL,SACA,KAAA,CACF;AACA,YAAY,cACV,SACA,oBACA,8CACA,IAAI,QACJ,IAAI,QACJ,SACA,KAAA,CACF;AAQA,MAAM,cAAc,OAAO,eACzB,QACA,eACA,uCACF;AACA,YAAY,cACV,cACA,6BACA,oCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,YACA,wBACA,+BACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,QACA,qBACA,4CACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,SACA,4BACA,qCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,YACA,sBACA,6BACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAQA,MAAM,oBAAoB,OAAO,eAC/B,cACA,qBACA,6CACF;AACA,kBAAkB,cAChB,YACA,6BACA,yCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,WACA,4BACA,wCACA,KAAK,OACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,aACA,8BACA,kDACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,gBACA,iCACA,6CACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,sBACA,uCACA,2DACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAQA,MAAM,gBAAgB,OAAO,eAC3B,UACA,iBACA,yCACF;AACA,cAAc,cACZ,UACA,uBACA,iCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,cAAc,cACZ,OACA,oBACA,iCACA,KAAK,QACL,KAAK,QACL,SACA,K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tD,KAAK,aAAa,KAAA;EAClB,KAAK,QAAQ,QAAQ;EACrB,IAAIC,QAAM,GAAG,MAAM,IAAI,GACrB,KAAK,aAAa,KAAK,aAAa,OAAO,MACzC,KAAK,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,KAAA,IAAY,EAAE,KAAK,CACnE;OACG,KAAK,aAAa,IAAI;CAC7B;CAEA,aAAa,MAAoB,OAAgB;EAC/C,KAAK,SAAS,uBACZ,KAAK,YACL,KAAK,QACL,OACA,KAAK,MAAM,UACX,KAAK,OACP;EACA,gBAAgB,KAAK,OAAO,KAAK,SAAS,KAAK,YAAY,IAAI;CACjE;;;;;;CAOA,KAAK,MAAsD;EACzD,MAAM,YAAY,KAAK;EACvB,IAAI,CAAC,WAAW;GACd,IAAI,KAAK,WAAW,QAAQ,MAAM,gCAAgC,IAAI;GACtE,OAAO;EACT;EACA,IAAI,KAAK,gBAAgB,KAAK,aAAa,KAAK,cAAc;EAC9D,MAAM,SAAS,KAAK,aAAaA,QAAM,KAAU,CAAC,CAAC;EACnD,UAAU,SAAS;EACnB,KAAK,iBAAiB,KAAK,aACzB,SACC,UAA+B,UAAU,MAAM,KAAK,CACvD;EACA,OAAO;CACT;AACF;AACA,eAAe,SAAS;AAExB,SAAgB,UAOd,SACA,WACA,MACA,SACA;CACA,OAAO,IAAI,UAAyB,SAAS,WAAW,MAAM,OAAO;AACvE;;;ACndA,SAAgB,OACd,SACyB;CACzB,OAAO;AACT;;AAGA,SAAgB,cAEd,OACA,SAC0C;CAC1C,OAAO;EACL;EACA,OAAO,SAAS;EAChB,iBAAiB,KAAK,WAAW;EACjC,cAAc,OAAO,UAAW,MAAM,OAAO;CAC/C;AACF;;ACnEA,MAAa,OAAO;CAClB;CACA;CACA;CACA;CACA;CACA;;CAEA,aAAkC;EAChC,OAAO,IAAI,cAAiB;CAC9B;AACF"}
1
+ {"version":3,"file":"list-eV59DvUB.mjs","names":["state","state","state","state","state","state"],"sources":["../../package-ui/list/key_field.ts","../../package-ui/list/add_row.ts","../../package-ui/list/drag.ts","../../package-ui/list/error.ts","../../package-ui/list/field.ts","../../package-ui/list/selection.ts","../../package-ui/list/row.ts","../../package-ui/list/shared.ts","../../package-ui/list/warn.ts","../../package-ui/list/container.ts","../../package-ui/list/types.ts","../../package-ui/list/index.ts"],"sourcesContent":["import { Base, define_element } from \"#base\";\nimport { array_from_length } from \"@chocbite/ts-lib/common\";\nimport { none, some } from \"@chocbite/ts-lib/result\";\nimport { state, type State } from \"@chocbite/ts-lib/state\";\nimport type { SVGFunc } from \"#svg\";\nimport \"./key_field.scss\";\nimport type { ListRowParent, ListType } from \"./types\";\n\nexport interface ListKeyFieldOptions {\n /**Icon shown after the sub row opener */\n icon?: SVGFunc | State<SVGFunc>;\n /**Text shown after the icon, an error of a state is shown as the text */\n text?: string | State<string>;\n}\n\nexport class ListKeyField<A extends ListType<any>> extends Base {\n static element_name() {\n return \"keyfield\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n #opener: HTMLDivElement;\n #text_box?: HTMLSpanElement;\n #icon?: SVGSVGElement;\n #tail?: HTMLElement;\n\n constructor(parent: ListRowParent<A>) {\n super();\n this.tabIndex = 0;\n //Places the line down to the sub rows of an open row\n this.style.setProperty(\"--list-key-depth\", String(parent.depth));\n this.onkeydown = (e) => {\n if (parent.key_down?.(e)) e.preventDefault();\n else if (e.key === \"Enter\" || e.key === \" \") parent.open = !parent.open;\n else if (e.key === \"ArrowRight\") parent.open = true;\n else if (e.key === \"ArrowLeft\") parent.open = false;\n else if (e.key === \"ArrowDown\") parent.select_adjacent(\"next\", none());\n else if (e.key === \"ArrowUp\") parent.select_adjacent(\"previous\", none());\n else return;\n e.preventDefault();\n };\n\n const opener_box = document.createElement(\"span\");\n opener_box.className = \"opener\";\n this.#opener = opener_box.appendChild(document.createElement(\"div\"));\n this.replaceChildren(\n ...array_from_length(parent.depth, (i) => {\n const div = document.createElement(\"div\");\n div.style.borderColor = \"var(--i-\" + i + \")\";\n return div;\n }),\n opener_box,\n );\n\n this.#opener.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n e.preventDefault();\n parent.open = !parent.open;\n });\n }\n\n set options(options: ListKeyFieldOptions | undefined) {\n if (state.is.state(options?.icon)) {\n this.attach_state_to_prop(\"icon\", options.icon, () => some(undefined));\n } else this.detach_state_from_prop(\"icon\").icon = options?.icon;\n if (state.is.state(options?.text)) {\n this.attach_state_to_prop(\"text\", options.text, (e) => some(e));\n } else this.detach_state_from_prop(\"text\").text = options?.text;\n }\n\n set icon(value: SVGFunc | undefined) {\n if (this.#icon) this.#icon.remove();\n this.#icon = undefined;\n this.classList.toggle(\"has-icon\", Boolean(value));\n if (!value) return;\n this.#icon = value();\n this.insertBefore(this.#icon, this.#text_box ?? this.#tail ?? null);\n }\n\n /**Element filling the rest of the key field, the button of an add row or the text of an error\n * A key field with a tail spans from the key column to the end of the row, so it works without value columns */\n set tail(value: HTMLElement | undefined) {\n if (value === this.#tail) return;\n this.#tail?.remove();\n this.#tail = value;\n this.classList.toggle(\"tail\", Boolean(value));\n if (value) this.appendChild(value);\n }\n get tail(): HTMLElement | undefined {\n return this.#tail;\n }\n\n /**Text after the icon, an empty string removes the text element */\n set text(value: string | undefined) {\n this.classList.toggle(\"has-text\", Boolean(value));\n if (!value) {\n this.#text_box?.remove();\n this.#text_box = undefined;\n return;\n }\n if (!this.#text_box) {\n this.#text_box = document.createElement(\"span\");\n this.#text_box.className = \"text\";\n this.insertBefore(this.#text_box, this.#tail ?? null);\n }\n this.#text_box.textContent = value;\n }\n\n // ____ _____ ______ _ _ _____ _ _ _____\n // / __ \\| __ \\| ____| \\ | |_ _| \\ | |/ ____|\n // | | | | |__) | |__ | \\| | | | | \\| | | __\n // | | | | ___/| __| | . ` | | | | . ` | | |_ |\n // | |__| | | | |____| |\\ |_| |_| |\\ | |__| |\n // \\____/|_| |______|_| \\_|_____|_| \\_|\\_____|\n\n set openable(value: boolean) {\n if (value) this.classList.add(\"openable\");\n else this.classList.remove(\"openable\");\n }\n get openable(): boolean {\n return this.classList.contains(\"openable\");\n }\n}\ndefine_element(ListKeyField);\n","import { Base, define_element } from \"#base\";\nimport { some } from \"@chocbite/ts-lib/result\";\nimport { state, type State } from \"@chocbite/ts-lib/state\";\nimport type { SVGFunc } from \"#svg\";\nimport \"./add_row.scss\";\nimport { ListKeyField } from \"./key_field\";\nimport type {\n ListParentRows,\n ListRoot,\n ListRowParent,\n ListType,\n} from \"./types\";\n\nexport interface ListAddRowOptions {\n text: string | State<string>;\n disabled?: boolean | State<boolean>;\n icon?: SVGFunc | State<SVGFunc>;\n on_add: () => void;\n}\n\nexport class ListAddRow<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n>\n extends Base\n implements ListRowParent<A>\n{\n static element_name() {\n return \"addrow\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n #button: HTMLSpanElement;\n #text: Text;\n #icon?: SVGSVGElement;\n #parent: ListRowParent<A>;\n readonly depth: number;\n\n constructor(root: ListRoot<R, T, A, S>, parent: ListRowParent<A>) {\n super();\n this.#parent = parent;\n this.depth = parent.depth + 1;\n this.#button = document.createElement(\"span\");\n this.#button.className = \"add\";\n this.#button.tabIndex = 0;\n //With sub rows the button is in the key field after the tree lines, it runs from the key column to the end\n if (root.sub_rows)\n this.appendChild(new ListKeyField(this)).tail = this.#button;\n else this.appendChild(this.#button);\n this.#text = this.#button.appendChild(document.createTextNode(\"\"));\n }\n\n set options(options: ListAddRowOptions) {\n this.#button.onclick = options.on_add;\n\n if (state.is.state(options.text))\n this.attach_state_to_prop(\"text\", options.text, (e) => some(e));\n else this.detach_state_from_prop(\"text\").text = options.text;\n if (state.is.state(options.disabled))\n this.attach_state_to_prop(\"disabled\", options.disabled, () =>\n some(false),\n );\n else this.detach_state_from_prop(\"disabled\").disabled = Boolean(\n options.disabled,\n );\n if (state.is.state(options.icon))\n this.attach_state_to_prop(\"icon\", options.icon, () => some(undefined));\n else this.detach_state_from_prop(\"icon\").icon = options.icon;\n }\n\n set text(value: string) {\n this.#text.data = value;\n }\n\n set icon(value: SVGFunc | undefined) {\n this.#icon?.remove();\n this.#icon = value ? this.#button.insertBefore(value(), this.#text) : undefined;\n }\n\n set disabled(value: boolean) {\n if (value) this.inert = true;\n else this.inert = false;\n }\n\n set open(_value: boolean) {}\n get open(): boolean {\n return false;\n }\n\n set global_index(_value: number) {}\n get global_index(): number {\n return 0;\n }\n\n /**Rows the add row adds to, the state of its parent */\n set state(_value: ListParentRows<A>) {}\n get state(): ListParentRows<A> {\n return this.#parent.state;\n }\n\n get global_amount(): number {\n return 0;\n }\n\n select_adjacent(): void {}\n}\ndefine_element(ListAddRow);\n","import { Base, define_element } from \"#base\";\nimport type { Option, Result } from \"@chocbite/ts-lib/result\";\nimport { state, type State, type StateREAW } from \"@chocbite/ts-lib/state\";\nimport \"./drag.scss\";\nimport type { ListWarn } from \"./warn\";\n\n/**What moving needs from a row */\nexport interface ListMovableRow extends HTMLElement {\n readonly data: unknown;\n /**Moving of the list the row is in */\n readonly reorder: object | undefined;\n readonly parent_rows: unknown;\n readonly parent_row: ListMovableRow | undefined;\n readonly next_row: ListMovableRow | undefined;\n readonly first_sub_row: ListMovableRow | undefined;\n readonly movable: boolean;\n readonly droppable: boolean;\n readonly selected: boolean;\n readonly multi_selected: boolean;\n readonly label: string;\n readonly anchor: Element | undefined;\n readonly index: number;\n readonly openable: boolean;\n open: boolean;\n drop_rows(): unknown;\n focus_cell(): void;\n}\n\ntype AnyRow = ListMovableRow;\ntype Rows = StateREAW<unknown[], Option<{}>, unknown[]>;\n\n/**Lists that rows can be dragged between, rows are given from one list to another of the same group\n * The type is checked both ways, so only lists with exactly the same row type can join */\nexport class ListDragGroup<R> {\n declare readonly type: (value: R) => R;\n}\n\n/**Where rows are dropped, given to can_drop */\nexport interface ListDropTarget<R> {\n /**Row the rows become sub rows of, undefined for the top level */\n parent: R | undefined;\n /**List the rows are dropped in */\n list: HTMLElement;\n}\n\nexport interface ListReorderOptions<R> {\n /**Lists of the same group can give rows to each other, without a group rows only move inside the list */\n group?: ListDragGroup<R>;\n /**Whether the row data can be dropped at the target, all dropped rows must be allowed for a drop */\n can_drop?(data: R, target: ListDropTarget<R>): boolean;\n /**Rows moved to another parent or list are only inserted there, not removed from where they came from\n * For apps that remove the rows themselves when they are added, set on the list the rows are dragged from\n * Moves inside one parent are still one move write */\n no_remove?: boolean;\n}\n\n/**Drag handle cell in front of a row, empty in the header */\nexport class ListDragField extends Base {\n static element_name() {\n return \"dragfield\";\n }\n static element_name_space() {\n return \"list\";\n }\n}\ndefine_element(ListDragField);\n\n/**Place rows are dropped at, before or after a row, or into it as its last sub rows */\nexport interface ListDropPlace {\n row: AnyRow;\n mode: \"before\" | \"after\" | \"into\";\n}\n\n/**Pixels the pointer moves before a press on the handle becomes a drag */\nconst DRAG_THRESHOLD = 5;\n/**Milliseconds hovering into a closed row before it opens */\nconst OPEN_DELAY = 600;\n/**Thickness of the drop line in pixels, it is drawn inside the row it is about */\nconst LINE_WIDTH = 5;\n/**Distance from the top or bottom edge of a list in pixels where dragging scrolls it */\nconst SCROLL_EDGE = 32;\n\n/**A rows state that the list can write moves to */\nfunction writable(rows: unknown): rows is Rows {\n return state.is.state(rows) && (rows as State<unknown>).writable;\n}\n\n/**Moving rows of a list by dragging their handle or with alt and the arrow keys\n * Like the selection, moves are only written to the rows states, the rows move when the states give the change back */\nexport class ListReorder<R> {\n readonly group: ListDragGroup<R>;\n readonly container: HTMLElement;\n #options: ListReorderOptions<R>;\n #warn: ListWarn;\n /**Shows where rows are dropped in this list */\n #indicator: HTMLSpanElement;\n\n constructor(\n container: HTMLElement,\n options: ListReorderOptions<R>,\n warn: ListWarn,\n ) {\n this.container = container;\n this.group = options.group ?? new ListDragGroup<R>();\n this.#options = options;\n this.#warn = warn;\n this.#indicator = container.appendChild(document.createElement(\"span\"));\n this.#indicator.className = \"list-drop\";\n this.#indicator.hidden = true;\n }\n\n /**Makes the handle cell of a row */\n handle(row: AnyRow): ListDragField {\n const handle = new ListDragField();\n handle.onpointerdown = (e) => this.#press(row, handle, e);\n return handle;\n }\n\n // _____ _____ _____\n // | __ \\| __ \\ /\\ / ____|\n // | | | | |__) | / \\ | | __\n // | | | | _ / / /\\ \\| | |_ |\n // | |__| | | \\ \\ / ____ \\ |__| |\n // |_____/|_| \\_\\/_/ \\_\\_____|\n\n #press(row: AnyRow, handle: ListDragField, e: PointerEvent) {\n if (e.button !== 0 || !row.movable) return;\n e.preventDefault();\n handle.setPointerCapture(e.pointerId);\n const start_x = e.clientX;\n const start_y = e.clientY;\n let x = start_x;\n let y = start_y;\n let rows: AnyRow[] | undefined;\n let place: ListDropPlace | undefined;\n let shown: ListReorder<R> | undefined;\n let frame = 0;\n let open_timer = 0;\n let open_row: AnyRow | undefined;\n const label = document.createElement(\"span\");\n label.className = \"list-drag-label\";\n\n const update = () => {\n frame = requestAnimationFrame(update);\n this.#scroll(x, y);\n const next = this.#place(x, y, rows!);\n shown?.indicate(undefined);\n shown = next?.row.reorder as ListReorder<R> | undefined;\n shown?.indicate(next);\n place = next;\n label.style.left = x + 12 + \"px\";\n label.style.top = y + 12 + \"px\";\n label.classList.toggle(\"none\", !next);\n //Hovering into a closed row opens it after a moment\n const hover =\n next?.mode === \"into\" && !next.row.open ? next.row : undefined;\n if (hover !== open_row) {\n clearTimeout(open_timer);\n open_row = hover;\n if (hover)\n open_timer = window.setTimeout(() => (hover.open = true), OPEN_DELAY);\n }\n };\n const end = (drop: boolean) => {\n handle.onpointermove = null;\n handle.onpointerup = null;\n handle.onpointercancel = null;\n handle.onlostpointercapture = null;\n document.removeEventListener(\"keydown\", escape, true);\n cancelAnimationFrame(frame);\n clearTimeout(open_timer);\n shown?.indicate(undefined);\n label.remove();\n if (!rows) return;\n for (const dragged of rows) dragged.classList.remove(\"dragging\");\n if (drop && place) void this.#drop(rows, place);\n };\n const escape = (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\") return;\n ev.preventDefault();\n ev.stopPropagation();\n end(false);\n };\n\n handle.onpointermove = (ev) => {\n x = ev.clientX;\n y = ev.clientY;\n if (rows) return;\n if (Math.hypot(x - start_x, y - start_y) < DRAG_THRESHOLD) return;\n rows = this.#dragged(row);\n for (const dragged of rows) dragged.classList.add(\"dragging\");\n label.textContent =\n rows.length > 1 ? rows.length + \" rows\" : row.label || \"1 row\";\n //In the body, a list is a stacking context, so a label in it would be covered by the lists after it\n document.body.appendChild(label);\n document.addEventListener(\"keydown\", escape, true);\n update();\n };\n handle.onpointerup = () => end(true);\n handle.onpointercancel = () => end(false);\n handle.onlostpointercapture = () => end(false);\n }\n\n /**Rows a drag from the row moves, the visible selected movable rows when the row is selected in multi mode\n * Sub rows of a dragged row move with it, so they are left out */\n #dragged(row: AnyRow): AnyRow[] {\n if (!row.selected || !row.multi_selected) return [row];\n const rows = [\n ...this.container.querySelectorAll<AnyRow>(\"list-row.selected.movable\"),\n ].filter((selected) => selected.reorder === this);\n const dragged = new Set(rows);\n return rows.filter((selected) => {\n for (let parent = selected.parent_row; parent; parent = parent.parent_row)\n if (dragged.has(parent)) return false;\n return true;\n });\n }\n\n /**Scrolls the list under the pointer when the pointer is near its top or bottom edge */\n #scroll(x: number, y: number) {\n const list = document\n .elementFromPoint(x, y)\n ?.closest<HTMLElement>(\"list-container\");\n const target = list ?? this.container;\n const rect = target.getBoundingClientRect();\n if (x < rect.left || x > rect.right) return;\n if (y < rect.top + SCROLL_EDGE)\n target.scrollTop -= Math.ceil((rect.top + SCROLL_EDGE - y) / 4);\n else if (y > rect.bottom - SCROLL_EDGE)\n target.scrollTop += Math.ceil((y - rect.bottom + SCROLL_EDGE) / 4);\n }\n\n // _____ _____ ____ _____\n // | __ \\| __ \\ / __ \\| __ \\\n // | | | | |__) | | | | |__) |\n // | | | | _ /| | | | ___/\n // | |__| | | \\ \\| |__| | |\n // |_____/|_| \\_\\\\____/|_|\n\n /**The place under the pointer, undefined when the rows can not be dropped there */\n #place(x: number, y: number, rows: AnyRow[]): ListDropPlace | undefined {\n const element = document.elementFromPoint(x, y);\n let row = element?.closest<AnyRow>(\"list-row\") ?? undefined;\n let mode: ListDropPlace[\"mode\"];\n if (!row) {\n //Below the last row of a list drops after it\n const list = element?.closest<HTMLElement>(\"list-container\");\n const last = list?.querySelector<AnyRow>(\n \":scope > div > div > list-row:last-child\",\n );\n if (!last?.anchor || y < last.anchor.getBoundingClientRect().bottom)\n return undefined;\n row = last;\n mode = \"after\";\n } else {\n const rect = row.anchor?.getBoundingClientRect();\n if (!rect) return undefined;\n const part = (y - rect.top) / rect.height;\n if (row.openable)\n mode = part < 0.25 ? \"before\" : part > 0.75 ? \"after\" : \"into\";\n else mode = part < 0.5 ? \"before\" : \"after\";\n }\n const reorder = row.reorder as ListReorder<R> | undefined;\n if (reorder?.group !== this.group) return undefined;\n //After an open row is before its first sub row\n if (mode === \"after\" && row.open) {\n const first = row.first_sub_row;\n if (first) {\n row = first;\n mode = \"before\";\n }\n }\n const place: ListDropPlace = { row, mode };\n return reorder.#allowed(place, rows) ? place : undefined;\n }\n\n /**Whether the rows can be dropped at the place of this list */\n #allowed(place: ListDropPlace, rows: AnyRow[]): boolean {\n const parent = place.mode === \"into\" ? place.row : place.row.parent_row;\n if (place.mode !== \"into\" && rows.includes(place.row)) return false;\n //Not into itself or its own sub rows\n for (let up: AnyRow | undefined = parent; up; up = up.parent_row)\n if (rows.includes(up)) return false;\n if (place.mode === \"into\" ? !place.row.droppable : !place.row.movable)\n return false;\n const options = this.#options;\n if (!options.can_drop) return true;\n const target: ListDropTarget<R> = {\n parent: parent?.data as R | undefined,\n list: this.container,\n };\n return rows.every((row) => options.can_drop!(row.data as R, target));\n }\n\n /**Shows where rows are dropped in this list, undefined hides it */\n indicate(place: ListDropPlace | undefined) {\n const indicator = this.#indicator;\n const cell = place?.row.anchor;\n if (!place || !cell) {\n indicator.hidden = true;\n return;\n }\n const list = this.container;\n const box = list.getBoundingClientRect();\n const rect = cell.getBoundingClientRect();\n const top = rect.top - box.top + list.scrollTop;\n //A line starts at the tree indent of the row, so the depth the rows land at shows,\n //after the last sub row of an open row and before the next row are at the same height\n const opener =\n place.mode === \"into\"\n ? undefined\n : place.row.querySelector(\n \":scope > div > list-keyfield > span:not(.text)\",\n );\n const left =\n (opener ?? cell).getBoundingClientRect().left -\n box.left +\n list.scrollLeft;\n //Ends at the right edge of the rows, not the scroll width of the list, which includes the indicator itself,\n //rounded down so it never makes the list wider and flashes a scrollbar\n const grid = list.querySelector(\":scope > div\") ?? list;\n const right =\n grid.getBoundingClientRect().right - box.left + list.scrollLeft;\n indicator.hidden = false;\n indicator.className = \"list-drop \" + place.mode;\n indicator.style.left = left + \"px\";\n indicator.style.width = Math.max(Math.floor(right - left), 0) + \"px\";\n //Drawn inside the row it is about, at its top or bottom edge\n indicator.style.top =\n (place.mode === \"after\" ? top + rect.height - LINE_WIDTH : top) + \"px\";\n indicator.style.height =\n (place.mode === \"into\" ? rect.height : LINE_WIDTH) + \"px\";\n }\n\n // __ __ ______ ________\n // | \\/ |/ __ \\ \\ / / ____|\n // | \\ / | | | \\ \\ / /| |__\n // | |\\/| | | | |\\ \\/ / | __|\n // | | | | |__| | \\ / | |____\n // |_| |_|\\____/ \\/ |______|\n\n /**Writes the moves of the rows to the place, rows next to each other in one parent move with one write\n * Moving to another parent inserts first and removes after, so a failure can leave a row twice but never loses it */\n async #drop(rows: AnyRow[], place: ListDropPlace) {\n const errors: string[] = [];\n const into = place.mode === \"into\" ? place.row : undefined;\n //Rows are dropped in order before this row, undefined appends to the parent\n const before: AnyRow | undefined =\n place.mode === \"before\"\n ? place.row\n : place.mode === \"after\"\n ? place.row.next_row\n : undefined;\n const target_box =\n place.mode === \"into\" ? undefined : place.row.parentElement;\n const target_rows = into ? into.drop_rows() : place.row.parent_rows;\n if (!writable(target_rows)) return;\n for (const chunk of this.#chunks(rows)) {\n const first = chunk[0];\n const source_box = first.parentElement;\n const same = into ? first.parent_row === into : source_box === target_box;\n if (same) {\n const from = first.index;\n const end = before ? before.index : source_box!.childElementCount;\n const to = from < end ? end - chunk.length : end;\n if (from === to) continue;\n const result = await target_rows.write(\n state.a.write.move(from, to, chunk.length),\n );\n if (result.err) errors.push(result.error);\n continue;\n }\n const items = chunk.map((row) => row.data);\n const inserted: Result<void, string> = await target_rows.write(\n before\n ? state.a.write.splice(before.index, 0, ...items)\n : state.a.write.push(...items),\n );\n if (inserted.err) {\n errors.push(inserted.error);\n continue;\n }\n //The app already took the rows out of the source while inserting\n if (this.#options.no_remove || !first.parentElement) continue;\n const source_rows = first.parent_rows;\n if (!writable(source_rows)) continue;\n const removed = await source_rows.write(\n state.a.write.splice(first.index, chunk.length),\n );\n if (removed.err) errors.push(removed.error);\n }\n if (into && errors.length === 0) into.open = true;\n if (errors.length)\n (place.row.reorder as ListReorder<R> | undefined)?.warn(\n place.row,\n [...new Set(errors)].join(\"\\n\"),\n );\n }\n\n /**Splits rows in display order into runs of rows next to each other in one parent */\n #chunks(rows: AnyRow[]): AnyRow[][] {\n const chunks: AnyRow[][] = [];\n for (const row of rows) {\n const last = chunks[chunks.length - 1]?.at(-1);\n if (\n last &&\n last.parentElement === row.parentElement &&\n last.next_row === row\n )\n chunks[chunks.length - 1].push(row);\n else chunks.push([row]);\n }\n return chunks;\n }\n\n /**Shows why a move failed at the row, in the list of the row */\n warn(row: AnyRow, message: string) {\n this.#warn.show(row.anchor, message);\n }\n\n /**Moves the row one place up or down in its parent, from the keyboard, the row keeps the focus */\n async key_move(row: AnyRow, direction: -1 | 1) {\n const rows = row.parent_rows;\n if (!row.movable || !writable(rows)) return;\n const from = row.index;\n const to = from + direction;\n if (to < 0 || to >= row.parentElement!.childElementCount) return;\n const result = await rows.write(state.a.write.move(from, to, 1));\n //Moving takes the row out of the document for a moment, which loses the focus\n row.focus_cell();\n if (result.err) this.warn(row, result.error);\n }\n}\n","import { Base, define_element } from \"#base\";\nimport \"./error.scss\";\nimport { ListKeyField } from \"./key_field\";\nimport type { ListParentRows, ListRowParent, ListType } from \"./types\";\n\n/**Error text shown instead of the fields of an invalid row */\nexport class ListError extends Base {\n static element_name() {\n return \"error\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n set text(value: string) {\n this.textContent = value;\n }\n}\ndefine_element(ListError);\n\n/**Error text shown instead of the rows of a parent, has a key field to continue the tree lines like an add row */\nexport class ListRowsError<A extends ListType<any>>\n extends Base\n implements ListRowParent<A>\n{\n static element_name() {\n return \"rowserror\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n #text = new ListError();\n #parent: ListRowParent<A>;\n readonly depth: number;\n\n constructor(sub_rows: boolean, parent: ListRowParent<A>) {\n super();\n this.#parent = parent;\n this.depth = parent.depth + 1;\n //With sub rows the text is in the key field after the tree lines, it runs from the key column to the end\n if (sub_rows) this.appendChild(new ListKeyField(this)).tail = this.#text;\n else this.appendChild(this.#text);\n }\n\n set text(value: string) {\n this.#text.text = value;\n }\n\n set open(_value: boolean) {}\n get open(): boolean {\n return false;\n }\n\n /**Rows the error is shown for, the state of its parent */\n set state(_value: ListParentRows<A>) {}\n get state(): ListParentRows<A> {\n return this.#parent.state;\n }\n\n select_adjacent(): void {}\n}\ndefine_element(ListRowsError);\n\n/**Shows the text in an error element directly after the row box, removes the element when there is no text\n * @returns the element to give next time, undefined when there is no text*/\nexport function list_rows_error_update<A extends ListType<any>>(\n row_box: Element,\n current: ListRowsError<A> | undefined,\n text: string | undefined,\n sub_rows: boolean,\n parent: ListRowParent<A>,\n): ListRowsError<A> | undefined {\n if (text === undefined) {\n current?.remove();\n return undefined;\n }\n if (!current) {\n current = new ListRowsError(sub_rows, parent);\n //Not in the row box, everything in there is a row\n row_box.after(current);\n }\n current.text = text;\n return current;\n}\n","import { Base, define_element } from \"#base\";\nimport \"./field.scss\";\nimport type { ListColumnAlign } from \"./types\";\n\n/**Adds the class for the alignment, center is the default and adds nothing\n * Only the styling of an element decides if the class does anything, so complex fields just do not follow it */\nexport function list_align_apply(\n element: HTMLElement,\n align: ListColumnAlign | undefined,\n) {\n if (align === \"left\" || align === \"right\")\n element.classList.add(\"align-\" + align);\n}\n\nexport abstract class ListField extends Base {\n static element_name() {\n return \"@abstract@\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n constructor() {\n super();\n }\n}\n\nexport class ListTextField extends ListField {\n static element_name() {\n return \"textfield\";\n }\n\n set text(value: string) {\n this.textContent = value;\n }\n}\ndefine_element(ListTextField);\n\nexport function text_field() {\n return new ListTextField();\n}\n\nexport class ListNumberField extends ListField {\n static element_name() {\n return \"numberfield\";\n }\n\n set number(value: number) {\n this.textContent = value.toString();\n }\n}\ndefine_element(ListNumberField);\n\nexport function number_field() {\n return new ListNumberField();\n}\n\nexport class ListNodeField<T extends Node> extends ListField {\n static element_name() {\n return \"nodefield\";\n }\n\n constructor(node: T) {\n super();\n this.appendChild(node);\n }\n\n set node(node: T) {\n this.replaceChildren(node);\n }\n\n get node() {\n return this.firstChild! as unknown as T;\n }\n}\ndefine_element(ListNodeField);\n\nexport function node_field<T extends Node>(node: T) {\n return new ListNodeField<T>(node);\n}\n","import { Base, define_element } from \"#base\";\nimport type { Result } from \"@chocbite/ts-lib/result\";\nimport { state, type StateREAW } from \"@chocbite/ts-lib/state\";\nimport \"./selection.scss\";\n\nexport interface ListSelectionOptions<R, K = R> {\n /**Single allows one selected row and shows radio buttons in front of the rows,\n * multi allows any amount and shows checkboxes, which toggle a row without modifier keys */\n mode: \"single\" | \"multi\";\n /**Identity of the data of a row, the selection is a list of these\n * Defaults to the data itself, give a key when rows can have equal data, like primitives\n * Keys must be unique among the rows of the list, sub rows included */\n key?: (data: R) => K;\n}\n\n/**What the selection needs from a row */\nexport interface ListSelectionRow {\n /**Shows the row as selected */\n selected: boolean;\n /**Cell to point at with a message about the row */\n readonly anchor: Element | undefined;\n}\n\n/**Selection of the rows of a list, kept in an array state of keys owned by the app\n * The list shows the keys of the state that have a visible row, and writes the state only on user actions,\n * keys of rows it does not show are left alone, except by select all and deselect all which replace the selection */\nexport class ListSelection<K> {\n readonly multi: boolean;\n /**Whether the rows get a checkbox or radio button column\n * Left out in single mode with a key column, a click on the row selects and the key field is the keyboard cell */\n readonly column: boolean;\n readonly key: (data: any) => K;\n /**Called after a change of the shown selection or of the selectable rows */\n on_change?: () => void;\n /**Called when the state rejects a write, with the row the user acted on */\n on_error?: (row: ListSelectionRow | undefined, message: string) => void;\n /**State user actions are written to */\n target?: StateREAW<K[], any, K[]>;\n\n /**Element holding all rows of the list, sub rows included, in display order */\n #box: Element;\n #rows = new Map<K, ListSelectionRow & Element>();\n /**Mirror of the state array, the removed and changed entries of an update only give positions or new items */\n #keys: K[] = [];\n /**How often each key is in the state, a key that is in it twice stays selected when one is removed */\n #counts = new Map<K, number>();\n /**Amount of visible rows that are selected */\n #shown = 0;\n #anchor?: K;\n #batch = 0;\n #changed = false;\n\n constructor(\n options: ListSelectionOptions<any, K>,\n box: Element,\n key_column: boolean,\n ) {\n this.multi = options.mode === \"multi\";\n this.column = this.multi || !key_column;\n this.key = options.key ?? ((data) => data as K);\n this.#box = box;\n }\n\n /**Runs the function with the change notification delayed until all nested batches are done */\n batch<T>(func: () => T): T {\n this.#batch++;\n try {\n return func();\n } finally {\n if (--this.#batch === 0 && this.#changed) {\n this.#changed = false;\n this.on_change?.();\n }\n }\n }\n\n // _____ _______ _______ ______\n // / ____|__ __|/\\|__ __| ____|\n // | (___ | | / \\ | | | |__\n // \\___ \\ | | / /\\ \\ | | | __|\n // ____) | | |/ ____ \\| | | |____\n // |_____/ |_/_/ \\_\\_| |______|\n\n /**Applies a value of the state, only the changed keys are touched when the value carries its changes */\n apply(value: Result<readonly K[], string>) {\n this.batch(() => {\n if (!value.ok) {\n this.#fresh([]);\n return;\n }\n for (const change of state.a.read(value.value)) {\n if (change.type === \"fresh\") this.#fresh(change.items);\n else if (change.type === \"added\") {\n this.#keys.splice(change.index, 0, ...change.items);\n for (const key of change.items) this.#add(key);\n } else if (change.type === \"removed\") {\n for (const key of this.#keys.splice(\n change.index,\n change.items.length,\n ))\n this.#remove(key);\n } else if (change.type === \"changed\")\n change.items.forEach((key, i) => {\n const old = this.#keys[change.index + i];\n this.#keys[change.index + i] = key;\n this.#remove(old);\n this.#add(key);\n });\n else {\n const moved = this.#keys.splice(\n change.from_index,\n change.items.length,\n );\n this.#keys.splice(change.to_index, 0, ...moved);\n }\n }\n });\n }\n\n #fresh(keys: readonly K[]) {\n const old = this.#counts;\n this.#keys = [...keys];\n this.#counts = new Map();\n for (const key of keys)\n this.#counts.set(key, (this.#counts.get(key) ?? 0) + 1);\n for (const key of old.keys())\n if (!this.#counts.has(key)) this.#show(key, false);\n for (const key of this.#counts.keys())\n if (!old.has(key)) this.#show(key, true);\n }\n\n #add(key: K) {\n const count = this.#counts.get(key) ?? 0;\n this.#counts.set(key, count + 1);\n if (count === 0) this.#show(key, true);\n }\n\n #remove(key: K) {\n const count = this.#counts.get(key);\n if (!count) return;\n if (count > 1) this.#counts.set(key, count - 1);\n else {\n this.#counts.delete(key);\n this.#show(key, false);\n }\n }\n\n #show(key: K, selected: boolean) {\n const row = this.#rows.get(key);\n if (!row) return;\n row.selected = selected;\n this.#shown += selected ? 1 : -1;\n this.#changed = true;\n }\n\n /**Writes the state, a rejected write is reported at the row of the key the user acted on */\n #write(value: K[], key?: K) {\n const write = this.target?.write(value);\n if (!write) return;\n const row = key === undefined ? undefined : this.#rows.get(key);\n void write.then((result) => {\n if (result.err) this.on_error?.(row, result.error);\n });\n }\n\n // _____ ______ _______\n // | __ \\ / __ \\ \\ / / ____|\n // | |__) | | | \\ \\ /\\ / / (___\n // | _ /| | | |\\ \\/ \\/ / \\___ \\\n // | | \\ \\| |__| | \\ /\\ / ____) |\n // |_| \\_\\\\____/ \\/ \\/ |_____/\n\n /**Adds a visible row that can be selected, it shows whether its key is in the state */\n register(key: K, row: ListSelectionRow & Element) {\n this.#rows.set(key, row);\n row.selected = this.#counts.has(key);\n if (row.selected) this.#shown++;\n this.#changed = true;\n }\n\n /**Removes a row that is no longer visible or selectable, the state keeps its key */\n unregister(key: K, row: ListSelectionRow & Element) {\n if (this.#rows.get(key) === row) {\n this.#rows.delete(key);\n if (this.#counts.has(key)) this.#shown--;\n }\n row.selected = false;\n this.#changed = true;\n }\n\n /**Amount of visible rows that can be selected */\n get amount_selectable(): number {\n return this.#rows.size;\n }\n\n /**Amount of visible rows that are selected */\n get amount_selected(): number {\n return this.#shown;\n }\n\n is_selected(key: K): boolean {\n return this.#counts.has(key);\n }\n\n // _ _ _____ ______ _____\n // | | | |/ ____| ____| __ \\\n // | | | | (___ | |__ | |__) |\n // | | | |\\___ \\| __| | _ /\n // | |__| |____) | |____| | \\ \\\n // \\____/|_____/|______|_| \\_\\\n //Every user action writes the state, the rows show the change when the state gives it back\n\n /**Keys of the selectable rows from one row to another in display order, both included */\n #range(from: K, to: K): K[] {\n const keys: K[] = [];\n let inside = false;\n const rows = this.#box.querySelectorAll(\"list-row\");\n const from_row = this.#rows.get(from);\n const to_row = this.#rows.get(to);\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const edge = row === from_row || row === to_row;\n if (edge || inside) {\n const key = (row as unknown as { selection_key: K | undefined })\n .selection_key;\n if (key !== undefined && this.#rows.get(key) === row) keys.push(key);\n }\n if (edge) {\n if (inside || from_row === to_row) break;\n inside = true;\n }\n }\n return keys;\n }\n\n #select_range(to: K, add: boolean) {\n if (!this.#rows.has(to)) return;\n const anchor =\n this.#anchor !== undefined && this.#rows.has(this.#anchor)\n ? this.#anchor\n : to;\n const keys = this.#range(anchor, to);\n this.#anchor = anchor;\n if (!add) return this.#write(state.a.write.fresh(keys), to);\n const added = keys.filter((key) => !this.#counts.has(key));\n if (added.length) this.#write(state.a.write.push(...added), to);\n }\n\n /**Replaces the selection with only the row */\n select_only(key: K) {\n if (!this.#rows.has(key)) return;\n this.#anchor = key;\n if (this.#keys.length === 1 && this.#keys[0] === key) return;\n this.#write(state.a.write.fresh([key]), key);\n }\n\n /**Adds the row to the selection, in single mode it replaces the selection */\n select(key: K) {\n if (!this.multi) return this.select_only(key);\n if (!this.#rows.has(key)) return;\n this.#anchor = key;\n if (!this.#counts.has(key)) this.#write(state.a.write.push(key), key);\n }\n\n /**Removes the row from the selection */\n deselect(key: K) {\n if (this.#counts.has(key)) this.#write(state.a.write.delete(key), key);\n }\n\n /**Toggles the row, in single mode selecting replaces the selection */\n toggle(key: K) {\n if (!this.#rows.has(key)) return;\n if (this.#counts.has(key)) {\n this.#anchor = key;\n this.deselect(key);\n } else this.select(key);\n }\n\n /**Replaces the selection with all visible selectable rows, multi mode only */\n select_all() {\n if (this.multi) this.#write(state.a.write.fresh([...this.#rows.keys()]));\n }\n\n /**Clears the selection, also of keys without a visible row */\n clear() {\n if (this.#keys.length) this.#write(state.a.write.fresh([]));\n }\n\n /**Click on the checkbox or radio button of a row */\n check_click(key: K) {\n if (this.multi) this.toggle(key);\n else this.select_only(key);\n }\n\n /**Click on a row outside its checkbox or radio button */\n click(key: K, e: MouseEvent) {\n if (this.multi && e.shiftKey)\n this.#select_range(key, e.ctrlKey || e.metaKey);\n else if (e.ctrlKey || e.metaKey) this.toggle(key);\n else this.select_only(key);\n }\n\n /**Focus moved to a row with the arrow keys, only shift in multi mode extends the range, otherwise the focus moves alone and space selects */\n focus_moved(key: K, e: KeyboardEvent) {\n if (this.multi && e.shiftKey)\n this.#select_range(key, e.ctrlKey || e.metaKey);\n }\n\n /**Handles selection keys pressed on a row, returns true when the key was used */\n key_down(key: K | undefined, e: KeyboardEvent): boolean {\n if (e.key === \" \") {\n if (key === undefined) return true;\n if (this.multi || e.ctrlKey || e.metaKey) this.toggle(key);\n else this.select_only(key);\n } else if (e.key === \"Escape\") this.clear();\n else if (this.multi && (e.ctrlKey || e.metaKey) && e.key === \"a\")\n this.select_all();\n else return false;\n return true;\n }\n}\n\n/**Checkbox or radio button cell in front of a row or in the header, its look comes from the selected class of the row or the header */\nexport class ListCheckField extends Base {\n static element_name() {\n return \"checkfield\";\n }\n static element_name_space() {\n return \"list\";\n }\n}\ndefine_element(ListCheckField);\n","import { Base, define_element } from \"#base\";\nimport ctm, { ContextMenu, type ContextMenuLines } from \"#context-menu\";\nimport { none, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { state, type State, type StateInferSub } from \"@chocbite/ts-lib/state\";\nimport state_ui from \"#state_ui\";\nimport { ListAddRow, type ListAddRowOptions } from \"./add_row\";\nimport type { ListDragField } from \"./drag\";\nimport { list_rows_error_update, ListError, type ListRowsError } from \"./error\";\nimport { list_align_apply, type ListField } from \"./field\";\nimport { ListKeyField, type ListKeyFieldOptions } from \"./key_field\";\nimport \"./row.scss\";\nimport { ListCheckField, type ListSelection } from \"./selection\";\nimport type {\n ListParentRows,\n ListRoot,\n ListRowParent,\n ListRowTransformer,\n ListType,\n} from \"./types\";\n\n/**Shown when the user tries to select a row that can not be selected */\nconst NOT_SELECTABLE = \"This row cannot be selected\";\n\nexport type ListSubRows<R> = () => R[] | State<R[]>;\n\nexport interface ListRowOptions<R, T extends {}, S extends boolean> {\n opened?: boolean;\n openable?: boolean | State<boolean>;\n key_field?: ListKeyFieldOptions;\n sub_rows?: S extends true ? ListSubRows<R> : never;\n add_row?: ListAddRowOptions;\n context_menu?: ContextMenu | (() => Option<ContextMenu>);\n /**Whether the row can be selected when the list has selection, true when undefined */\n selectable?: boolean;\n values: T;\n}\n\nexport class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>\n extends Base\n implements ListRowParent<A>\n{\n static element_name() {\n return \"row\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n #root: ListRoot<R, T, A, S>;\n #parent: ListRowParent<A>;\n #sub_rows?: ListSubRows<R>;\n readonly depth: number;\n #key_field?: ListKeyField<A>;\n /**Drag handle cell, only with reorder */\n #drag?: ListDragField;\n /**Checkbox or radio button cell, only with selection */\n #check?: ListCheckField;\n #data!: R;\n /**Sub rows of a closed row given for a drop, used when it opens so the sub rows function is called once */\n #drop_rows?: R[] | State<R[]>;\n /**Key of the row in the selection, undefined when the row can not be selected */\n selection_key?: unknown;\n #field_box: HTMLDivElement;\n #child_box: HTMLSpanElement;\n #add_row?: ListAddRow<R, T, A, S>;\n #fields: ListField[];\n #values!: T;\n /**Shown instead of the fields while the row is invalid */\n #invalid?: ListError;\n /**Shown instead of the sub rows while their state has an error */\n #error?: ListRowsError<A>;\n #open_pending = false;\n #sub_row_menu = false;\n #state_sub?: StateInferSub<State<R[]>>;\n state!: ListParentRows<A>;\n\n constructor(root: ListRoot<R, T, A, S>, parent: ListRowParent<A>, data: R) {\n super();\n this.#root = root;\n this.#parent = parent;\n this.depth = parent.depth + 1;\n this.style.setProperty(\"--i-\" + this.depth, \"var(--c)\");\n if (this.#root.sub_rows) {\n this.#key_field = new ListKeyField(this);\n if (this.#root.observer)\n this.#key_field.attach_to_intersect_observer(this.#root.observer);\n }\n this.#field_box = this.appendChild(document.createElement(\"div\"));\n this.#child_box = this.appendChild(document.createElement(\"span\"));\n if (this.#root.reorder) this.#drag = this.#root.reorder.handle(this);\n if (this.#root.selection) this.#selection_setup(this.#root.selection);\n //A right click on a sub row without its own menu reaches the child box before this row\n if (this.#root.sub_rows)\n this.#child_box.oncontextmenu = () => {\n this.#sub_row_menu = true;\n };\n this.#fields = this.#generate_fields();\n this.#show_cells(this.#fields);\n\n //Updates row data\n this.data = data;\n }\n\n #generate_fields(): ListField[] {\n return this.#root.columns_visible.map((key) => {\n const column = this.#root.columns.get(key)!;\n const field = column.field_gen();\n list_align_apply(field, column.align);\n if (this.#root.observer)\n field.attach_to_intersect_observer(this.#root.observer);\n return field;\n });\n }\n\n /**Shows the cells after the key field, which stays so an invalid row keeps its indent and arrow key navigation */\n #show_cells(cells: readonly HTMLElement[]) {\n const lead: HTMLElement[] = [];\n if (this.#drag) lead.push(this.#drag);\n if (this.#check) lead.push(this.#check);\n if (this.#key_field) lead.push(this.#key_field);\n this.#field_box.replaceChildren(...lead, ...cells);\n }\n\n #apply_values() {\n this.#root.columns_visible.forEach((key, index) => {\n this.#root.columns\n .get(key)!\n .field_apply(this.#fields[index], this.#values[key]);\n });\n }\n\n /**Regenerates the fields of the row and its sub rows after the columns changed */\n columns_changed() {\n this.#fields = this.#generate_fields();\n //An invalid row has no values, the new fields are shown when it becomes valid\n if (!this.#invalid) {\n this.#show_cells(this.#fields);\n this.#apply_values();\n }\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n (this.#child_box.children[i] as ListRow<R, T, A, S>).columns_changed();\n }\n\n // _____ _____ ______ _ _ _______\n // | __ \\ /\\ | __ \\| ____| \\ | |__ __|\n // | |__) / \\ | |__) | |__ | \\| | | |\n // | ___/ /\\ \\ | _ /| __| | . ` | | |\n // | | / ____ \\| | \\ \\| |____| |\\ | | |\n // |_| /_/ \\_\\_| \\_\\______|_| \\_| |_|\n\n select_adjacent(\n direction: \"next\" | \"previous\" | \"p_next\" | \"p_previous\" | \"last\",\n field: Option<number>,\n ) {\n if (!this.#key_field && !this.#check) return;\n //Open is not enough, an open row can show an error instead of sub rows\n const has_rows = this.#child_box.childElementCount > 0;\n if (direction === \"next\" || direction === \"p_next\") {\n if (direction === \"next\" && has_rows)\n (this.#child_box.firstElementChild! as ListRow<R, T, A, S>).#focus();\n else {\n const sibling = this.nextElementSibling;\n if (sibling instanceof ListRow) sibling.#focus();\n else this.#parent.select_adjacent(\"p_next\", field);\n }\n } else if (direction === \"previous\") {\n const sibling = this.previousElementSibling;\n if (sibling instanceof ListRow) {\n if (sibling.open) sibling.select_adjacent(\"last\", field);\n else sibling.#focus();\n } else this.#parent.select_adjacent(\"p_previous\", field);\n } else if (direction === \"p_previous\") this.#focus();\n else if (direction === \"last\") {\n if (has_rows) {\n (\n this.#child_box.lastElementChild as ListRow<R, T, A, S>\n ).select_adjacent(\"last\", field);\n } else this.#focus();\n }\n }\n\n /**Focuses the cell used for keyboard navigation, the key field or else the checkbox */\n #focus(options?: FocusOptions) {\n (this.#key_field ?? this.#check)?.focus(options);\n }\n\n /**Focuses the cell used for keyboard navigation */\n focus_cell() {\n this.#focus({ preventScroll: true });\n }\n\n /**Moves the focus to the keyboard cell after a click, so the selection keys work right away\n * Unless the click focused something in the row itself, like an input of a field */\n #focus_after_click() {\n const active = document.activeElement;\n if (active && active !== document.body && this.#field_box.contains(active))\n return;\n const cell = this.#key_field ?? this.#check;\n if (!cell) return;\n //Without scrolling, the sticky cell would scroll the list sideways\n cell.focus({ preventScroll: true });\n //Focus from script shows the focus ring, which a click should not, removed again by a key or blur\n cell.classList.add(\"click-focus\");\n }\n\n key_down(e: KeyboardEvent): boolean {\n const selection = this.#root.selection;\n if (e.altKey && (e.key === \"ArrowDown\" || e.key === \"ArrowUp\")) {\n if (!this.#root.reorder) return false;\n void this.#root.reorder.key_move(this, e.key === \"ArrowDown\" ? 1 : -1);\n return true;\n }\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n this.select_adjacent(e.key === \"ArrowDown\" ? \"next\" : \"previous\", none());\n const focused = document.activeElement?.closest(\"list-row\");\n if (\n selection &&\n focused !== this &&\n focused instanceof ListRow &&\n focused.selection_key !== undefined\n )\n selection.focus_moved(focused.selection_key, e);\n return true;\n }\n if (!selection) return false;\n if (e.key === \" \" && this.selection_key === undefined) {\n selection.on_error?.(this, NOT_SELECTABLE);\n return true;\n }\n return selection.key_down(this.selection_key, e);\n }\n\n // _____ _______\n // | __ \\ /\\|__ __|/\\\n // | | | | / \\ | | / \\\n // | | | |/ /\\ \\ | | / /\\ \\\n // | |__| / ____ \\| |/ ____ \\\n // |_____/_/ \\_\\_/_/ \\_\\\n\n set data(data: R) {\n this.#data = data;\n this.#drop_rows = undefined;\n this.classList.toggle(\n \"movable\",\n Boolean(this.#drag) &&\n state.is.state(this.#parent.state) &&\n this.#parent.state.writable,\n );\n const result = this.#root.transform(\n data,\n this,\n //Only the container gives top level rows, rows are only parents of sub rows\n this.#parent.state as Parameters<ListRowTransformer<R, T, A, S>>[2],\n );\n if (!result.ok) {\n this.#set_invalid(result.error);\n return;\n }\n const row_options = result.value;\n if (this.#invalid) {\n this.#invalid = undefined;\n if (this.#key_field) this.#key_field.tail = undefined;\n this.#show_cells(this.#fields);\n }\n this.#selection_update(row_options.selectable ?? true, data);\n if (this.#key_field) this.#key_field.options = row_options.key_field;\n this.#sub_rows = row_options.sub_rows;\n\n this.add_row = row_options.add_row;\n\n this.#values = row_options.values;\n this.#apply_values();\n\n //Setup openable\n const was_open = this.open;\n if (state.is.state(row_options.openable)) {\n //Opening waits for the first value of the state, which is immediate when connected\n this.#open_pending = !was_open && Boolean(row_options.opened);\n this.attach_state_to_prop(\"openable\", row_options.openable, () =>\n some(false),\n );\n } else {\n this.#open_pending = false;\n this.detach_state_from_prop(\"openable\");\n this.openable = Boolean(row_options.openable);\n if (!was_open && row_options.opened) this.open = true;\n }\n\n //Refresh the sub rows of an open row\n if (was_open && this.open) {\n if (this.#sub_rows) this.rows = this.#sub_rows();\n else if (!row_options.opened) this.open = false;\n }\n\n //Setup context menu, blocked for right clicks bubbling up from sub rows\n ctm.detach(this);\n this.#sub_row_menu = false;\n //With sub rows a row gets open, close and close all lines and a selectable row select lines, in front of its own menu\n //Openable can be a state and rows open and close, the lines are made when the menu opens\n const menu =\n this.#root.sub_rows || this.selection_key !== undefined\n ? ctm.combine(\n () => this.#open_lines(),\n () => this.#selection_lines(),\n row_options.context_menu,\n )\n : row_options.context_menu;\n if (menu)\n ctm.attach(this, menu, () => {\n const from_sub_row = this.#sub_row_menu;\n this.#sub_row_menu = false;\n return from_sub_row;\n });\n }\n\n /**Replaces the fields with the text and removes everything else the row options gave */\n #set_invalid(text: string) {\n this.#selection_update(false);\n if (this.#key_field) this.#key_field.options = undefined;\n this.#sub_rows = undefined;\n this.add_row = undefined;\n this.#open_pending = false;\n this.detach_state_from_prop(\"openable\");\n this.openable = false;\n ctm.detach(this);\n this.#sub_row_menu = false;\n if (!this.#invalid) {\n this.#invalid = new ListError();\n //With sub rows the text is in the key field after the tree lines, it runs from the key column to the end\n if (this.#key_field) {\n this.#key_field.tail = this.#invalid;\n this.#show_cells([]);\n } else this.#show_cells([this.#invalid]);\n }\n this.#invalid.text = text;\n }\n\n set add_row(options: ListAddRowOptions | undefined) {\n if (!options && this.#add_row) {\n this.#add_row.remove();\n this.classList.remove(\"addrow\");\n this.#add_row = undefined;\n } else if (options) {\n if (!this.#add_row) {\n this.classList.add(\"addrow\");\n this.#add_row = this.appendChild(\n new ListAddRow<R, T, A, S>(this.#root, this),\n );\n }\n this.#add_row.options = options;\n }\n }\n\n // ____ _____ ______ _ _ _____ _ _ _____\n // / __ \\| __ \\| ____| \\ | |_ _| \\ | |/ ____|\n // | | | | |__) | |__ | \\| | | | | \\| | | __\n // | | | | ___/| __| | . ` | | | | . ` | | |_ |\n // | |__| | | | |____| |\\ |_| |_| |\\ | |__| |\n // \\____/|_| |______|_| \\_|_____|_| \\_|\\_____|\n\n set openable(value: boolean) {\n if (!value) this.open = false;\n if (this.#key_field) this.#key_field.openable = value;\n if (this.#open_pending) {\n this.#open_pending = false;\n if (value) this.open = true;\n }\n }\n get openable(): boolean {\n return this.#key_field?.openable ?? false;\n }\n\n set open(open: boolean) {\n if (!this.openable) return;\n if (open && this.#child_box.childElementCount === 0) {\n const rows = this.#drop_rows ?? this.#sub_rows?.();\n this.#drop_rows = undefined;\n if (rows) this.rows = rows;\n } else if (!open && this.open) this.rows = [];\n }\n get open(): boolean {\n return this.classList.contains(\"open\");\n }\n\n // _____ ______ _______\n // | __ \\ / __ \\ \\ / / ____|\n // | |__) | | | \\ \\ /\\ / / (___\n // | _ /| | | |\\ \\/ \\/ / \\___ \\\n // | | \\ \\| |__| | \\ /\\ / ____) |\n // |_| \\_\\\\____/ \\/ \\/ |_____/\n\n get index(): number {\n return Array.prototype.indexOf.call(this.parentElement!.children, this);\n }\n\n amount_rows(rec: boolean = false): number {\n let count = this.#child_box.childElementCount;\n if (rec)\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n count += (\n this.#child_box.children[i] as ListRow<R, T, A, S>\n ).amount_rows(true);\n return count;\n }\n\n set rows(rows: R[] | State<R[]>) {\n if (this.#state_sub) this.detach_state(this.#state_sub);\n this.#state_sub = undefined;\n //R is the item type of A\n this.state = rows as ListParentRows<A>;\n if (state.is.state(rows))\n this.#state_sub = this.attach_state(rows, (r) =>\n this.#update_rows(r.ok ? r.value : [], r.ok ? undefined : r.error),\n );\n else this.#update_rows(rows);\n }\n\n #update_rows(rows: readonly R[], error?: string) {\n this.#error = list_rows_error_update(\n this.#child_box,\n this.#error,\n error,\n this.#root.sub_rows,\n this,\n );\n this.classList.toggle(\"open\", rows.length > 0 || error !== undefined);\n list_rows_apply(this.#root, this, this.#child_box, rows);\n }\n\n // _____ ______ _ ______ _____ _______ _____ ____ _ _\n // / ____| ____| | | ____/ ____|__ __|_ _/ __ \\| \\ | |\n // | (___ | |__ | | | |__ | | | | | || | | | \\| |\n // \\___ \\| __| | | | __|| | | | | || | | | . ` |\n // ____) | |____| |____| |___| |____ | | _| || |__| | |\\ |\n // |_____/|______|______|______\\_____| |_| |_____\\____/|_| \\_|\n\n #selection_setup(selection: ListSelection<unknown>) {\n const clear_click_focus = (e: Event) =>\n (e.currentTarget as HTMLElement).classList.remove(\"click-focus\");\n if (selection.column) {\n this.#check = new ListCheckField();\n //The key field is the keyboard cell when there is one\n if (!this.#key_field) this.#check.tabIndex = 0;\n this.#check.onkeydown = (e) => {\n if (this.key_down(e)) e.preventDefault();\n };\n this.#check.onclick = (e) => {\n e.stopPropagation();\n //Focus first, moving the focus after the warning would close it\n this.#focus_after_click();\n if (this.selection_key !== undefined)\n selection.check_click(this.selection_key);\n else selection.on_error?.(this, NOT_SELECTABLE);\n };\n }\n for (const cell of [this.#check, this.#key_field])\n if (cell) {\n cell.addEventListener(\"keydown\", clear_click_focus);\n cell.addEventListener(\"blur\", clear_click_focus);\n }\n this.#field_box.onclick = (e) => {\n //Focus first, moving the focus after the warning would close it\n this.#focus_after_click();\n if (this.selection_key !== undefined)\n selection.click(this.selection_key, e);\n else selection.on_error?.(this, NOT_SELECTABLE);\n };\n //Shift click would select text between the rows\n this.#field_box.onmousedown = (e) => {\n if (e.shiftKey && selection.multi) e.preventDefault();\n };\n }\n\n /**Registers the row in the selection with the key of its data, or removes it when not selectable */\n #selection_update(selectable: boolean, data?: R) {\n const selection = this.#root.selection;\n if (!selection) return;\n const key: unknown = selectable ? selection.key(data) : undefined;\n if (key === this.selection_key) return;\n if (this.selection_key !== undefined)\n selection.unregister(this.selection_key, this);\n this.selection_key = key;\n if (key !== undefined) selection.register(key, this);\n this.classList.toggle(\"selectable\", key !== undefined);\n }\n\n /**Context menu lines to open or close the sub rows of an openable row, and to close all rows while one is open\n * Close all is on every row, so a list without header can close all */\n #open_lines(): ContextMenuLines {\n const lines: ContextMenuLines = [];\n if (this.openable)\n lines.push(\n this.open\n ? ctm.line(\"Close\", () => (this.open = false))\n : ctm.line(\"Open\", () => (this.open = true)),\n );\n if (this.#root.any_open())\n lines.push(ctm.line(\"Close all\", () => this.#root.close_all()));\n return lines;\n }\n\n /**Context menu lines to select or deselect the row, and in multi mode all rows\n * Empty when the row can not be selected */\n #selection_lines(): ContextMenuLines {\n const selection = this.#root.selection;\n const key = this.selection_key;\n if (!selection || key === undefined) return [];\n const lines: ContextMenuLines = [\n selection.is_selected(key)\n ? ctm.line(\"Deselect\", () => selection.deselect(key))\n : ctm.line(\"Select\", () => selection.select(key)),\n ];\n if (selection.multi)\n lines.push(\n ctm.line(\n \"Select all\",\n () => selection.select_all(),\n undefined,\n \"Ctrl+A\",\n ),\n ctm.line(\"Deselect all\", () => selection.clear(), undefined, \"Esc\"),\n );\n return lines;\n }\n\n // __ __ ______ _______ _ _ _____\n // | \\/ |/ __ \\ \\ / /_ _| \\ | |/ ____|\n // | \\ / | | | \\ \\ / / | | | \\| | | __\n // | |\\/| | | | |\\ \\/ / | | | . ` | | |_ |\n // | | | | |__| | \\ / _| |_| |\\ | |__| |\n // |_| |_|\\____/ \\/ |_____|_| \\_|\\_____|\n\n get data(): R {\n return this.#data;\n }\n\n /**Moving of the list the row is in, undefined when its rows can not be moved */\n get reorder() {\n return this.#root.reorder;\n }\n\n /**Rows of the parent the row is in */\n get parent_rows(): ListParentRows<A> {\n return this.#parent.state;\n }\n\n /**Row the row is a sub row of, undefined for top level rows */\n get parent_row(): ListRow<R, T, A, S> | undefined {\n return this.#parent instanceof ListRow ? this.#parent : undefined;\n }\n\n get next_row(): ListRow<R, T, A, S> | undefined {\n const next = this.nextElementSibling;\n return next instanceof ListRow ? next : undefined;\n }\n\n get first_sub_row(): ListRow<R, T, A, S> | undefined {\n const first = this.#child_box.firstElementChild;\n return first instanceof ListRow ? first : undefined;\n }\n\n /**Whether the row has a handle and its parent rows can be written */\n get movable(): boolean {\n return this.classList.contains(\"movable\");\n }\n\n /**Whether rows can be dropped into the row, it must be openable with sub rows in a writable state */\n get droppable(): boolean {\n if (!this.openable) return false;\n const rows = this.drop_rows();\n return state.is.state(rows) && rows.writable;\n }\n\n /**The sub rows rows are dropped into, also of a closed row */\n drop_rows(): R[] | State<R[]> | undefined {\n if (this.open) return this.state;\n return (this.#drop_rows ??= this.#sub_rows?.());\n }\n\n /**Whether the row is selected in a list with multi selection, a drag of it moves all selected rows */\n get multi_selected(): boolean {\n return this.selected && Boolean(this.#root.selection?.multi);\n }\n\n /**Text naming the row while it is dragged, the key field text or the text of the first cell */\n get label(): string {\n const text =\n this.#key_field?.querySelector(\".text\")?.textContent ||\n this.#fields[0]?.textContent ||\n \"\";\n return text.trim();\n }\n\n /**First visible cell of the row, the row itself is display contents and has no box */\n get anchor(): Element | undefined {\n return this.#field_box.firstElementChild ?? undefined;\n }\n\n set selected(value: boolean) {\n this.classList.toggle(\"selected\", value);\n }\n get selected(): boolean {\n return this.classList.contains(\"selected\");\n }\n\n /**Removes the row and its sub rows from the selection, when the row is removed */\n selection_leave() {\n const selection = this.#root.selection;\n if (!selection) return;\n if (this.selection_key !== undefined)\n selection.unregister(this.selection_key, this);\n this.selection_key = undefined;\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n (this.#child_box.children[i] as ListRow<R, T, A, S>).selection_leave();\n }\n}\ndefine_element(ListRow);\n\n/**Applies rows to a row box, removed rows leave the selection, which updates once after all changes */\nexport function list_rows_apply<\n R,\n T extends {},\n A extends ListType<R>,\n S extends boolean,\n>(\n root: ListRoot<R, T, A, S>,\n parent: ListRowParent<A>,\n box: HTMLElement,\n rows: readonly R[],\n) {\n const apply = () =>\n state_ui.a.apply(box, rows, {\n create: (row) => new ListRow<R, T, A, S>(root, parent, row),\n update: (element, row) => (element.data = row),\n destroy: (element) => element.selection_leave(),\n });\n if (root.selection) root.selection.batch(apply);\n else apply();\n}\n","import { theme_init_variable_root } from \"#theme\";\nimport { BLUE, GREY, ORANGE, RED } from \"@chocbite/ts-lib/colors\";\n\nconst theme_root = theme_init_variable_root(\n \"list\",\n \"UI List Elements\",\n \"Theme variables for UI list elements\",\n);\n\n// _____ ______ _____ ____ _ _ _ __ __\n// | __ \\| ____| /\\ | __ \\ / __ \\| \\ | | | \\ \\ / /\n// | |__) | |__ / \\ | | | | | | | | \\| | | \\ \\_/ /\n// | _ /| __| / /\\ \\ | | | | | | | | . ` | | \\ /\n// | | \\ \\| |____ / ____ \\| |__| | | |__| | |\\ | |____| |\n// |_| \\_\\______/_/ \\_\\_____/ \\____/|_| \\_|______|_|\nconst read_only = theme_root.make_sub_group(\n \"read\",\n \"Read Only\",\n \"Settings for list elements in read only mode\",\n);\nread_only.make_variable(\n \"filter\",\n \"Read Only Filter\",\n \"Filter applied to list elements in read only mode\",\n \"opacity(0.6)\",\n \"opacity(0.6)\",\n \"Filter\",\n undefined,\n);\n\n//#################################################################################3\n//#################################################################################3\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors = theme_root.make_sub_group(\n \"colors\",\n \"Colors\",\n \"Colors used in all list elements\",\n);\n\n// _______ ________ _________ _____ ____ _ ____ _____ _____\n// |__ __| ____\\ \\ / /__ __| / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | |__ \\ V / | | | | | | | | | | | | | |__) | (___\n// | | | __| > < | | | | | | | | | | | | | _ / \\___ \\\n// | | | |____ / . \\ | | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |_| |______/_/ \\_\\ |_| \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_text = colors.make_sub_group(\n \"text\",\n \"Text Colors\",\n \"Text colors used in all list elements\",\n);\ncolors_text.make_variable(\n \"header\",\n \"Header Text Color\",\n \"Header text color in list elements\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"field\",\n \"Field Text Color\",\n \"Text color of list field elements\",\n GREY[\"800\"],\n GREY[\"100\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"key_field\",\n \"Special Column Text Color\",\n \"Text color of special first column elements\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"add\",\n \"Row Adder Text Color\",\n \"Text color of row adder button\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"error\",\n \"Error Text Color\",\n \"Text color of list errors and invalid rows\",\n RED[\"800\"],\n RED[\"200\"],\n \"Color\",\n undefined,\n);\n\n// _____ _____ ____ _ _ _____ ____ _ ____ _____ _____\n// |_ _/ ____/ __ \\| \\ | | / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | || | | | | | \\| | | | | | | | | | | | | |__) | (___\n// | || | | | | | . ` | | | | | | | | | | | | _ / \\___ \\\n// _| || |___| |__| | |\\ | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |_____\\_____\\____/|_| \\_| \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_icon = colors.make_sub_group(\n \"icon\",\n \"Icon Colors\",\n \"Icon colors used in all form elements\",\n);\ncolors_icon.make_variable(\n \"sub_opener\",\n \"Sub Row Opener Icon Color\",\n \"Color of the sub row opener icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"key_icon\",\n \"Key Field Icon Color\",\n \"Color of the key field icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"drag\",\n \"Drag Handle Color\",\n \"Color of the drag handles that move rows\",\n GREY[\"600\"],\n GREY[\"400\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"check\",\n \"Selection Checkbox Color\",\n \"Color of the selection checkboxes\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"add_icon\",\n \"Add Row Icon Color\",\n \"Color of the add row icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\n\n// ____ _____ _ _______ _____ ____ _ _ _ _ _____ _____ ____ _ ____ _____ _____\n// | _ \\ /\\ / ____| |/ / ____| __ \\ / __ \\| | | | \\ | | __ \\ / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | |_) | / \\ | | | ' / | __| |__) | | | | | | | \\| | | | | | | | | | | | | | | | |__) | (___\n// | _ < / /\\ \\| | | <| | |_ | _ /| | | | | | | . ` | | | | | | | | | | | | | | | _ / \\___ \\\n// | |_) / ____ \\ |____| . \\ |__| | | \\ \\| |__| | |__| | |\\ | |__| | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |____/_/ \\_\\_____|_|\\_\\_____|_| \\_\\\\____/ \\____/|_| \\_|_____/ \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_background = colors.make_sub_group(\n \"background\",\n \"Background Colors\",\n \"Background colors used in all list elements\",\n);\ncolors_background.make_variable(\n \"row_even\",\n \"Even Row Background Color\",\n \"Color of even row element backgrounds\",\n GREY[\"200\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_odd\",\n \"Odd Row Background Color\",\n \"Color of odd row element backgrounds\",\n GREY[\"50\"],\n GREY[\"900\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_hover\",\n \"Hover Row Background Color\",\n \"Color of row element backgrounds when hovering\",\n GREY[\"300\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_selected\",\n \"Selected Row Background Color\",\n \"Color of selected row element backgrounds\",\n BLUE[\"100\"],\n BLUE[\"900\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_selected_hover\",\n \"Selected Hover Row Background Color\",\n \"Color of selected row element backgrounds when hovering\",\n BLUE[\"200\"],\n BLUE[\"800\"],\n \"Color\",\n undefined,\n);\n\n// ____ ____ _____ _____ ______ _____ _____ ____ _ ____ _____ _____\n// | _ \\ / __ \\| __ \\| __ \\| ____| __ \\ / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | |_) | | | | |__) | | | | |__ | |__) | | | | | | | | | | | | |__) | (___\n// | _ <| | | | _ /| | | | __| | _ / | | | | | | | | | | | _ / \\___ \\\n// | |_) | |__| | | \\ \\| |__| | |____| | \\ \\ | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |____/ \\____/|_| \\_\\_____/|______|_| \\_\\ \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_border = colors.make_sub_group(\n \"border\",\n \"Border Colors\",\n \"Border colors used in all list elements\",\n);\ncolors_border.make_variable(\n \"header\",\n \"Header Border Color\",\n \"Color of borders under header\",\n GREY[\"600\"],\n GREY[\"400\"],\n \"Color\",\n undefined,\n);\ncolors_border.make_variable(\n \"row\",\n \"Row Border Color\",\n \"Color of borders between rows\",\n GREY[\"400\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\ncolors_border.make_variable(\n \"column\",\n \"Column Border Color\",\n \"Color of border between columns\",\n GREY[\"500\"],\n GREY[\"500\"],\n \"Color\",\n undefined,\n);\n\n// ______ ____ _____ _ _ _____\n// | ____/ __ \\ / ____| | | |/ ____|\n// | |__ | | | | | | | | | (___\n// | __|| | | | | | | | |\\___ \\\n// | | | |__| | |____| |__| |____) |\n// |_| \\____/ \\_____|\\____/|_____/\nconst colors_focus = colors.make_sub_group(\n \"focus\",\n \"Focus Colors\",\n \"Focus colors used in all list elements\",\n);\ncolors_focus.make_variable(\n \"normal\",\n \"Focus Color\",\n \"Color of focussed list element\",\n ORANGE[\"600\"],\n ORANGE[\"300\"],\n \"Color\",\n undefined,\n);\n\n//#################################################################################3\n//#################################################################################3\n// _____ _____ ____________ _____\n// / ____|_ _|___ / ____|/ ____|\n// | (___ | | / /| |__ | (___\n// \\___ \\ | | / / | __| \\___ \\\n// ____) |_| |_ / /__| |____ ____) |\n// |_____/|_____/_____|______|_____/\nconst sizes = theme_root.make_sub_group(\n \"size\",\n \"Size\",\n \"Sizes used in all list elements\",\n);\n\nsizes.make_variable(\n \"row_min\",\n \"Row Minimum Height\",\n \"Minimum height for list rows\",\n \"1.4rem\",\n \"1.4rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"touch_row_min\",\n \"Touch Row Minimum Height\",\n \"Minimum height for list rows on touch devices\",\n \"2.6rem\",\n \"2.6rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"add_min\",\n \"Add Row Minimum Height\",\n \"Minimum height for add row button\",\n \"1rem\",\n \"1rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"touch_add_min\",\n \"Touch Add Row Minimum Height\",\n \"Minimum height for add row button on touch devices\",\n \"2rem\",\n \"2rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\n//#################################################################################3\n//#################################################################################3\n// _ _ _____ __ __ _______ _____ ____ _ _\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | |\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ |\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_|\nconst animation = theme_root.make_sub_group(\n \"animation\",\n \"Animation\",\n \"Animation settings used in all list elements\",\n);\n\nanimation.make_variable(\n \"transitionType\",\n \"Transition Type\",\n \"Type of transition used in list element animations\",\n \"ease-in-out\",\n \"ease-in-out\",\n \"TransitionType\",\n undefined,\n);\n\nanimation.make_variable(\n \"transitionDuration\",\n \"Transition Duration\",\n \"Duration of transitions used in list element animations\",\n \"200ms\",\n \"200ms\",\n \"Time\",\n { min: 0, max: 5000 },\n);\n\n//#################################################################################3\n//#################################################################################3\n// ______ ____ _ _ _______\n// | ____/ __ \\| \\ | |__ __|\n// | |__ | | | | \\| | | |\n// | __|| | | | . ` | | |\n// | | | |__| | |\\ | | |\n// |_| \\____/|_| \\_| |_|\nconst font = theme_root.make_sub_group(\n \"font\",\n \"Font\",\n \"Font settings used in all list elements\",\n);\n\nfont.make_variable(\n \"size\",\n \"Font Size\",\n \"Default font size used in all list elements\",\n \"1rem\",\n \"1rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nfont.make_variable(\n \"touchSize\",\n \"Touch Font Size\",\n \"Font size used in all list elements for touch devices\",\n \"1.2rem\",\n \"1.2rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n","/**Shows why a write of the list failed as the validation message of the browser, at the row it is about, like the form elements do\n * One hidden input in the container is placed over the row before the message is shown, it clears after 5 seconds */\nexport class ListWarn {\n #container: HTMLElement;\n #input: HTMLInputElement;\n #timeout?: number;\n\n constructor(container: HTMLElement) {\n this.#container = container;\n this.#input = container.appendChild(document.createElement(\"input\"));\n this.#input.className = \"list-warn\";\n this.#input.tabIndex = -1;\n }\n\n /**Shows the message at the element, or at the top of the list without element\n * @param at element to point at, rows are display contents, so give one of their cells */\n show(at: Element | undefined, message: string) {\n const input = this.#input;\n const container = this.#container;\n const box = container.getBoundingClientRect();\n const rect = at?.getBoundingClientRect() ?? box;\n input.style.top = rect.top - box.top + container.scrollTop + \"px\";\n input.style.left =\n Math.max(rect.left - box.left, 0) + container.scrollLeft + \"px\";\n input.style.width = rect.width + \"px\";\n input.style.height = rect.height + \"px\";\n //Showing the message can move the focus to the input, the keyboard cell keeps it\n const focused = document.activeElement;\n input.setCustomValidity(message);\n input.reportValidity();\n if (focused instanceof HTMLElement && focused !== document.activeElement)\n focused.focus({ preventScroll: true });\n if (this.#timeout) clearTimeout(this.#timeout);\n this.#timeout = window.setTimeout(() => {\n input.setCustomValidity(\"\");\n input.reportValidity();\n }, 5000);\n }\n}\n","import { Base, define_element, type BaseIntersectObserver } from \"#base\";\nimport ctm from \"#context-menu\";\nimport { px_to_rem } from \"#theme\";\nimport {\n state,\n type State,\n type StateInferSub,\n type StateREAW,\n type StateSub,\n} from \"@chocbite/ts-lib/state\";\nimport type { Result } from \"@chocbite/ts-lib/result\";\nimport { ListAddRow, type ListAddRowOptions } from \"./add_row\";\nimport { ListDragField, ListReorder, type ListReorderOptions } from \"./drag\";\nimport \"./container.scss\";\nimport { list_rows_error_update, type ListRowsError } from \"./error\";\nimport { list_align_apply } from \"./field\";\nimport { list_rows_apply, ListRow } from \"./row\";\nimport {\n ListCheckField,\n ListSelection,\n type ListSelectionOptions,\n} from \"./selection\";\nimport \"./shared\";\nimport { ListWarn } from \"./warn\";\nimport type {\n ListColumnOptions,\n ListRoot,\n ListRowParent,\n ListRowTransformer,\n ListType,\n ListTypeExtract,\n} from \"./types.ts\";\n\n/**Most rows open all opens at a time, a mistake making the sub rows recursive would otherwise never end */\nconst OPEN_ALL_LIMIT = 1000;\n\nclass HeaderField extends Base {\n static element_name() {\n return \"headerfield\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n #box = this.appendChild(document.createElement(\"div\"));\n #text = this.#box.appendChild(document.createElement(\"span\"));\n #sizer?: HTMLDivElement;\n\n constructor(text?: string) {\n super();\n if (text) this.text = text;\n }\n\n /**Elements shown instead of the text */\n set nodes(nodes: Node[]) {\n this.#text.replaceChildren(...nodes);\n }\n\n set text(value: string) {\n this.#text.textContent = value;\n }\n\n sizable(sizeable: boolean, sizer: (width: number | undefined) => void) {\n if (sizeable) {\n this.#sizer = this.#box.appendChild(document.createElement(\"div\"));\n let double_timeout: number;\n this.#sizer.onpointerdown = (e) => {\n e.preventDefault();\n if (double_timeout) {\n sizer(undefined);\n return;\n }\n double_timeout = window.setTimeout(() => {\n double_timeout = 0;\n }, 300);\n this.setPointerCapture(e.pointerId);\n const handle = e.currentTarget as HTMLElement;\n handle.classList.add(\"active\");\n const start_x = e.pageX;\n const start_width = this.#box.offsetWidth;\n this.onpointermove = (ev: PointerEvent) => {\n sizer(px_to_rem(start_width + (ev.pageX - start_x)));\n };\n //A cancel or lost capture also ends the resize, a touch the browser takes for something else cancels\n const end = () => {\n if (this.hasPointerCapture(e.pointerId))\n this.releasePointerCapture(e.pointerId);\n handle.classList.remove(\"active\");\n this.onpointermove = null;\n this.onpointerup = null;\n this.onpointercancel = null;\n this.onlostpointercapture = null;\n };\n this.onpointerup = end;\n this.onpointercancel = end;\n this.onlostpointercapture = end;\n };\n } else if (this.#sizer) {\n this.#sizer.remove();\n this.#sizer = undefined;\n }\n }\n}\ndefine_element(HeaderField);\n\nclass HeaderRow<\n R,\n T extends {},\n A extends ListType<R>,\n S extends boolean,\n> extends Base {\n static element_name() {\n return \"headerrow\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n set fields(fields: HeaderField[]) {\n const lead: HTMLElement[] = [];\n if (this.#drag_header) lead.push(this.#drag_header);\n if (this.#check_header) lead.push(this.#check_header);\n if (this.#key_header) lead.push(this.#key_header);\n this.replaceChildren(...lead, ...fields);\n }\n\n /**Header of the key field column, only with sub rows */\n get key_header(): HTMLElement | undefined {\n return this.#key_header;\n }\n\n /**Header of the key field column, only with sub rows */\n #key_header?: HeaderField;\n /**Empty header of the drag handle column */\n #drag_header?: ListDragField;\n /**Header of the checkbox or radio button column, in multi mode it selects or deselects all rows */\n #check_header?: ListCheckField;\n\n constructor(\n root: ListRoot<R, T, A, S>,\n key_sizer: (width: number | undefined) => void,\n ) {\n super();\n if (root.sub_rows) {\n const key = (this.#key_header = new HeaderField());\n key.classList.add(\"key\");\n const button = (kind: string, action: () => void) => {\n const span = document.createElement(\"span\");\n span.className = `list-${kind}-all`;\n span.onclick = action;\n return span;\n };\n key.nodes = [\n button(\"close\", () => root.close_all()),\n button(\"open\", () => root.open_all()),\n ];\n ctm.attach(\n key,\n ctm.menu([\n ctm.line(\"Open all\", () => root.open_all()),\n ctm.line(\"Close all\", () => root.close_all()),\n ]),\n );\n key.sizable(true, key_sizer);\n }\n if (root.reorder) this.#drag_header = new ListDragField();\n const selection = root.selection;\n if (selection?.column) this.#check_header = new ListCheckField();\n if (selection?.multi) {\n const check = this.#check_header!;\n check.onclick = () => {\n if (selection.amount_selected > 0) selection.clear();\n else selection.select_all();\n };\n ctm.attach(\n check,\n ctm.menu([\n ctm.line(\n \"Select all\",\n () => selection.select_all(),\n undefined,\n \"Ctrl+A\",\n ),\n ctm.line(\"Deselect all\", () => selection.clear(), undefined, \"Esc\"),\n ]),\n );\n selection.on_change = () => {\n const selected = selection.amount_selected;\n check.classList.toggle(\"some\", selected > 0);\n check.classList.toggle(\n \"all\",\n selected > 0 && selected === selection.amount_selectable,\n );\n };\n }\n }\n}\ndefine_element(HeaderRow);\n\ninterface ContainerOptions<S extends boolean = false, R = unknown, K = R> {\n /**Should header row be omitted */\n headless?: boolean;\n /**Can rows have sub rows */\n sub_rows?: S;\n /**Options for an add row button */\n add_row?: ListAddRowOptions;\n /**If list should use a container to give fields the option of attach/detach to states when visible */\n observer?: BaseIntersectObserver;\n /**Lets the user select rows, only rows that are visible can be selected */\n selection?: ListSelectionOptions<R, K>;\n /**Lets the user move rows with a drag handle in front of the rows, rows in a writable array state can be moved */\n reorder?: ListReorderOptions<R>;\n}\n\nclass Container<\n A extends ListType<any>,\n T extends { [key: string]: ListColumnOptions<any, any> },\n S extends boolean = false,\n R = ListTypeExtract<A>,\n K = R,\n> extends Base {\n static element_name() {\n return \"container\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n #root: ListRoot<R, T, A, S>;\n #selection?: ListSelection<K>;\n #selection_sub?: StateSub<Result<K[], string>>;\n #parent: ListRowParent<A>;\n #box = this.appendChild(document.createElement(\"div\"));\n #header?: HeaderRow<R, T, A, S>;\n #child_box: HTMLDivElement;\n #error?: ListRowsError<A>;\n #add_row?: ListAddRow<R, T, A, S>;\n #state_sub?: StateInferSub<State<R[]>>;\n /**Width of the key field column in rem set by resizing, fits the key fields when undefined */\n #key_width?: number;\n /**Shows why a write failed, or that open all stopped */\n #warn?: ListWarn;\n\n constructor(\n columns: { [C in keyof T]: ListColumnOptions<T[C], any> },\n transform: ListRowTransformer<R, T, A, S>,\n rows: A,\n options?: ContainerOptions<S, R, K>,\n ) {\n super();\n this.#root = {\n sub_rows: options?.sub_rows ?? (false as S),\n columns: new Map(),\n columns_visible: [],\n transform,\n observer: options?.observer,\n open_all: () => this.open_all(),\n close_all: () => this.close_all(),\n any_open: () => this.#open_rows().length > 0,\n };\n this.#parent = {\n depth: -1,\n open: false,\n select_adjacent() {},\n state: rows,\n };\n\n this.#child_box = document.createElement(\"div\");\n //Shows why a write of the selection or a move failed\n const warn =\n options?.selection || options?.reorder || options?.sub_rows\n ? new ListWarn(this)\n : undefined;\n this.#warn = warn;\n if (options?.reorder) {\n this.#root.reorder = new ListReorder(this, options.reorder, warn!);\n this.#box.classList.add(\"drag\");\n }\n if (options?.selection) {\n this.#selection = new ListSelection(\n options.selection,\n this.#child_box,\n Boolean(options.sub_rows),\n );\n this.#root.selection = this.#selection;\n if (this.#selection.column) this.#box.classList.add(\"check\");\n this.#box.classList.add(this.#selection.multi ? \"multi\" : \"single\");\n this.#selection.on_error = (row, message) =>\n warn!.show(row?.anchor ?? this.#header ?? this.#box, message);\n }\n //Columns in front of the key field column, the error and add rows start after them\n const lead =\n Number(Boolean(options?.reorder)) +\n Number(Boolean(this.#selection?.column));\n if (lead) this.#box.classList.add(\"lead-\" + lead);\n\n if (!options?.headless)\n this.#header = this.#box.appendChild(\n new HeaderRow(this.#root, (width) => {\n this.#key_width = width;\n this.#update_column_widths();\n }),\n );\n this.#box.appendChild(this.#child_box);\n if (options?.sub_rows) this.#box.classList.add(\"sub-rows\");\n this.add_row = options?.add_row;\n\n this.columns = columns;\n this.rows = rows;\n //Selection works without a bound state, in a state of its own nobody else can reach\n if (this.#selection) this.bind({});\n }\n\n set columns(columns: { [C in keyof T]: ListColumnOptions<T[C], any> }) {\n this.#root.columns.clear();\n const order = new Map<keyof T, number>();\n let index = 0;\n for (const key in columns) {\n //Copied, so resizing does not write into the callers options\n this.#root.columns.set(key, { ...columns[key as keyof T] });\n order.set(key, columns[key].order ?? index);\n index++;\n }\n this.#root.columns_visible = [...order.keys()].sort(\n (a, b) => order.get(a)! - order.get(b)!,\n );\n\n if (this.#header) {\n const headers = this.#root.columns_visible.map((key) => {\n const column = this.#root.columns.get(key)!;\n const header = new HeaderField(column.title);\n list_align_apply(header, column.align);\n header.sizable(typeof column.fixed_width === \"undefined\", (width) => {\n if (width !== undefined) this.#freeze_auto_widths(headers);\n column.init_width = width;\n this.#update_column_widths();\n });\n return header;\n });\n this.#header.fields = headers;\n }\n this.#update_column_widths();\n\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n (this.#child_box.children[i] as ListRow<R, T, A, S>).columns_changed();\n }\n\n /**Gives the auto width columns their current width, so resizing one column does not resize the others\n * Only measures while there are auto width columns, so after the first resize a move does no layout here*/\n #freeze_auto_widths(headers: HeaderField[]) {\n const auto = this.#root.columns_visible.flatMap((key, i) => {\n const col = this.#root.columns.get(key)!;\n return col.fixed_width === undefined && !col.init_width ? [i] : [];\n });\n //Measured before any is set, setting one would change the layout of the rest\n const widths = auto.map((i) => px_to_rem(headers[i].offsetWidth));\n auto.forEach((i, j) => {\n this.#root.columns.get(this.#root.columns_visible[i])!.init_width =\n widths[j];\n });\n }\n\n /**Opens every openable row, level by level so the upper levels are open first\n * Stops with a warning after opening OPEN_ALL_LIMIT rows, against huge or recursive sub rows, opening all again continues */\n open_all() {\n let opened = 0;\n let level = this.#top_rows();\n while (level.length) {\n const next: ListRow<R, T, A, S>[] = [];\n for (const row of level) {\n if (row.openable && !row.open) {\n if (opened >= OPEN_ALL_LIMIT) {\n this.#warn?.show(\n this.#header?.key_header ?? this.#box,\n `Stopped after opening ${OPEN_ALL_LIMIT} rows, open all again for more`,\n );\n return;\n }\n row.open = true;\n opened += row.amount_rows();\n }\n for (let sub = row.first_sub_row; sub; sub = sub.next_row)\n next.push(sub);\n }\n level = next;\n }\n }\n\n /**Closes every open row, closing the top rows removes everything below them */\n close_all() {\n for (const row of this.#open_rows()) row.open = false;\n }\n\n #top_rows(): ListRow<R, T, A, S>[] {\n return [...this.#child_box.children] as ListRow<R, T, A, S>[];\n }\n\n #open_rows(): ListRow<R, T, A, S>[] {\n return this.#top_rows().filter((row) => row.open);\n }\n\n #update_column_widths() {\n const widths: string[] = this.#root.columns_visible.map((key) => {\n const col = this.#root.columns.get(key)!;\n //Without a header nothing can resize, so init_width, the start of a resize, does not apply\n const width =\n col.fixed_width ?? (this.#header ? col.init_width : undefined);\n if (width) {\n if (width === \"min\") return \"min-content\";\n else if (width === \"max\") return \"max-content\";\n return `${Math.max(width, 1)}rem`;\n }\n return \"auto\";\n });\n //The key fields get the width instead of the column, so it never gets smaller than its widest key field minimum\n //Without value columns it fills the list unless resized\n if (this.#root.sub_rows)\n widths.unshift(widths.length || this.#key_width ? \"max-content\" : \"auto\");\n this.#box.classList.toggle(\"key-sized\", Boolean(this.#key_width));\n if (this.#key_width)\n this.#box.style.setProperty(\n \"--list-key-width\",\n `${Math.max(this.#key_width, 1)}rem`,\n );\n else this.#box.style.removeProperty(\"--list-key-width\");\n if (this.#selection?.column) widths.unshift(\"var(--list-check-width)\");\n if (this.#root.reorder) widths.unshift(\"var(--list-drag-width)\");\n this.#box.style.gridTemplateColumns = widths.join(\" \");\n }\n\n set add_row(options: ListAddRowOptions | undefined) {\n if (!options && this.#add_row) {\n this.#add_row.remove();\n this.#box.classList.remove(\"addrow\");\n this.#add_row = undefined;\n } else if (options) {\n if (!this.#add_row) {\n this.#box.classList.add(\"addrow\");\n this.#add_row = this.#box.appendChild(\n new ListAddRow<R, T, A, S>(this.#root, this.#parent),\n );\n }\n this.#add_row.options = options;\n }\n }\n\n // _____ ______ _______\n // | __ \\ / __ \\ \\ / / ____|\n // | |__) | | | \\ \\ /\\ / / (___\n // | _ /| | | |\\ \\/ \\/ / \\___ \\\n // | | \\ \\| |__| | \\ /\\ / ____) |\n // |_| \\_\\\\____/ \\/ \\/ |_____/\n\n amount_rows(rec: boolean = false): number {\n let count = this.#child_box.childElementCount;\n if (rec)\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n count += (\n this.#child_box.children[i] as ListRow<R, T, A, S>\n ).amount_rows(true);\n return count;\n }\n\n set rows(rows: R[] | State<R[]>) {\n if (this.#state_sub) this.detach_state(this.#state_sub);\n this.#state_sub = undefined;\n this.#parent.state = rows as A;\n if (state.is.state(rows))\n this.#state_sub = this.attach_state(rows, (r) =>\n this.#update_rows(r.ok ? r.value : [], r.ok ? undefined : r.error),\n );\n else this.#update_rows(rows);\n }\n\n #update_rows(rows: readonly R[], error?: string) {\n this.#error = list_rows_error_update(\n this.#child_box,\n this.#error,\n error,\n this.#root.sub_rows,\n this.#parent,\n );\n list_rows_apply(this.#root, this.#parent, this.#child_box, rows);\n }\n\n /**Binds the selection to an array state of keys, which can be shared with other lists and elements\n * The list shows the keys that have a visible row, and only writes the state on user actions,\n * with array write instructions, so it must be a state that applies them, like a local writable state\n * Without a state the selection is kept in a state of the list that nobody else can reach\n * Needs the selection option */\n bind(opts: { selection?: StateREAW<K[], any, K[]> }): this {\n const selection = this.#selection;\n if (!selection) {\n if (opts.selection) console.error(\"List has no selection option\", this);\n return this;\n }\n if (this.#selection_sub) this.detach_state(this.#selection_sub);\n const target = opts.selection ?? state.ok_w<K[]>([]);\n selection.target = target;\n this.#selection_sub = this.attach_state(\n target as StateREAW<K[]>,\n (value: Result<K[], string>) => selection.apply(value),\n );\n return this;\n }\n}\ndefine_element(Container);\n\nexport function container<\n A extends ListType<any>,\n T extends {},\n S extends boolean = false,\n R = ListTypeExtract<A>,\n K = R,\n>(\n columns: { [C in keyof T]: ListColumnOptions<T[C], any> },\n transform: ListRowTransformer<R, NoInfer<T>, A, S>,\n rows: A,\n options?: ContainerOptions<S, R, K>,\n) {\n return new Container<A, T, S, R, K>(columns, transform, rows, options);\n}\n","import type { BaseIntersectObserver } from \"#base\";\nimport { type Option, type Result } from \"@chocbite/ts-lib/result\";\nimport type { State } from \"@chocbite/ts-lib/state\";\nimport list from \".\";\nimport type { ListField, ListTextField } from \"./field\";\nimport type { ListRow, ListRowOptions } from \"./row\";\nimport type { ListReorder } from \"./drag\";\nimport type { ListSelection } from \"./selection\";\n\nexport type ListType<R> = R[] | State<R[]>;\n\nexport type ListTypeExtract<A extends ListType<any>> = A extends (infer U)[]\n ? U\n : A extends State<(infer U)[]>\n ? U\n : never;\n\n/**Rows of a row parent, the top level rows or sub rows, which can be an array or a state regardless of the top level rows */\nexport type ListParentRows<A extends ListType<any>> =\n A | ListType<ListTypeExtract<A>>;\n\nexport const ListDataType = {\n number: \"number\",\n string: \"string\",\n bool: \"bool\",\n} as const;\nexport type ListDataType = (typeof ListDataType)[keyof typeof ListDataType];\n\nexport type ListColumnAlign = \"left\" | \"center\" | \"right\";\n\nexport interface ListColumnOptions<V, C extends ListField> {\n /**Initial width of the column in rem, auto when undefined, ignored in a headless list as nothing can resize it*/\n init_width?: number;\n /**If the column has a fixed width in rem, overrides init_width and disables resizing*/\n fixed_width?: number | \"min\" | \"max\";\n /**Initial order of the column, lower numbers appear first, will order by column object if undefined\n * A column without order uses its position in the column object as order*/\n order?: number;\n /**Whether the column is reorderable by the user*/\n reorderable?: boolean;\n /**Data type of the column, used for sorting, will attempt auto detect if undefined*/\n type?: ListDataType;\n /**Horizontal alignment of the title and the fields, center when undefined\n * Text, number and node fields follow it, more complex fields like form fields do not */\n align?: ListColumnAlign;\n /**Column title*/\n title: string;\n /**Generates the field element, only called during row or column creation */\n field_gen(): C;\n /**Applies the value to the field */\n field_apply(field: C, value: V): void;\n}\n\n/**Helper to create a column object */\nexport function column<V, C extends ListField>(\n options: ListColumnOptions<V, C>,\n): ListColumnOptions<V, C> {\n return options;\n}\n\n/**Special helper to create a string value column */\nexport function column_string(\n /**Column title*/\n title: string,\n options?: { align?: ListColumnAlign },\n): ListColumnOptions<string, ListTextField> {\n return {\n title,\n align: options?.align,\n field_gen: () => list.text_field(),\n field_apply: (field, value) => (field.text = value),\n };\n}\n\n/**Transforms the data of a row into row options\n * Returning an error makes the row invalid, the error text then replaces the fields of the row\n * An invalid row is for failures with no other options, so it has no sub rows, add row or context menu */\nexport type ListRowTransformer<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n> = (\n /**Data of the row */\n data: R,\n /**The row the options are for */\n row: ListRow<R, T, A, S>,\n /**Rows the data is from, sub rows can come from an array or a state regardless of the top level rows */\n state: S extends true ? A | ListType<R> : A,\n) => Result<ListRowOptions<R, T, S>, string>;\n\nexport interface ListRoot<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n> {\n /**Sub rows */\n readonly sub_rows: S;\n /**Columns options mapped by column key */\n readonly columns: Map<keyof T, ListColumnOptions<T[keyof T], ListField>>;\n /**Order of visible columns by column key */\n columns_visible: (keyof T)[];\n /**Function to transform a row data into row options */\n transform: ListRowTransformer<R, T, A, S>;\n /**Observer for the container if observer is active */\n observer?: BaseIntersectObserver;\n /**Selection of rows, when enabled */\n selection?: ListSelection<any>;\n /**Moving of rows, when enabled */\n reorder?: ListReorder<R>;\n /**Opens every openable row, a limited amount of rows at a time */\n open_all(): void;\n /**Closes every open row */\n close_all(): void;\n /**Whether any row is open */\n any_open(): boolean;\n}\n\nexport interface ListRowParent<A extends ListType<any>> {\n /**Sub row depth */\n readonly depth: number;\n /**Whether the row is open to show sub rows */\n open: boolean;\n /**Selects the adjacent row in the given direction */\n select_adjacent(\n direction: \"next\" | \"previous\" | \"p_next\" | \"p_previous\" | \"last\",\n field: Option<number>,\n ): void;\n /**Rows of the parent, the rows of the container or the sub rows of a row */\n state: ListParentRows<A>;\n /**Handles a key pressed in the key field before the key field does, returns true when the key was used */\n key_down?(e: KeyboardEvent): boolean;\n}\n","import { container } from \"./container\";\nimport { ListDragGroup } from \"./drag\";\nimport { node_field, number_field, text_field } from \"./field\";\nimport { column, column_string } from \"./types\";\n\nexport const list = {\n column,\n column_string,\n container,\n text_field,\n number_field,\n node_field,\n /**Group of lists that can give rows to each other by dragging, all lists of a group must have the same row type */\n drag_group<R>(): ListDragGroup<R> {\n return new ListDragGroup<R>();\n },\n};\n\nexport { ListField } from \"./field\";\nexport type { ListDragGroup, ListDropTarget, ListReorderOptions } from \"./drag\";\n\nexport default list;\n"],"mappings":";;;;;;;;;;AAeA,IAAa,eAAb,cAA2D,KAAK;CAC9D,OAAO,eAAe;EACpB,OAAO;CACT;CACA,OAAO,qBAAqB;EAC1B,OAAO;CACT;CAEA;CACA;CACA;CACA;CAEA,YAAY,QAA0B;EACpC,MAAM;EACN,KAAK,WAAW;EAEhB,KAAK,MAAM,YAAY,oBAAoB,OAAO,OAAO,KAAK,CAAC;EAC/D,KAAK,aAAa,MAAM;GACtB,IAAI,OAAO,WAAW,CAAC,GAAG,EAAE,eAAe;QACtC,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK,OAAO,OAAO,CAAC,OAAO;QAC9D,IAAI,EAAE,QAAQ,cAAc,OAAO,OAAO;QAC1C,IAAI,EAAE,QAAQ,aAAa,OAAO,OAAO;QACzC,IAAI,EAAE,QAAQ,aAAa,OAAO,gBAAgB,QAAQ,KAAK,CAAC;QAChE,IAAI,EAAE,QAAQ,WAAW,OAAO,gBAAgB,YAAY,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IAAI,QACJ,IAAI,QACJ,SACA,KAAA,CACF;AAQA,MAAM,cAAc,OAAO,eACzB,QACA,eACA,uCACF;AACA,YAAY,cACV,cACA,6BACA,oCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,YACA,wBACA,+BACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,QACA,qBACA,4CACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,SACA,4BACA,qCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,YACA,sBACA,6BACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAQA,MAAM,oBAAoB,OAAO,eAC/B,cACA,qBACA,6CACF;AACA,kBAAkB,cAChB,YACA,6BACA,yCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,WACA,4BACA,wCACA,KAAK,OACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,aACA,8BACA,kDACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,gBACA,iCACA,6CACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,sBACA,uCACA,2DACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAQA,MAAM,gBAAgB,OAAO,eAC3B,UACA,iBACA,yCACF;AACA,cAAc,cACZ,UACA,uBACA,iCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,cAAc,cACZ,OACA,oBACA,iCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,cAAc,cACZ,UACA,uBACA,mCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAQqB,OAAO,eAC1B,SACA,gBACA,wCAES,CAAC,CAAC,cACX,UACA,eACA,kCACA,OAAO,QACP,OAAO,QACP,SACA,KAAA,CACF;AAUA,M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