@embedpdf/core-ui 3.0.0-next.15 → 3.0.0-next.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -831,5 +831,55 @@ declare function formatShortcut(shortcut: string, options: {
831
831
  isMac: boolean;
832
832
  }): string;
833
833
  //#endregion
834
- export { type AddItemOptions, type BarChild, type BarEdge, type BarGroup, type BarItem, type BarPlace, type BarSchema, type BarSections, type CollapsedGroupView, type CompileBarOptions, type CustomItem, type CustomSlotCtx, DEFAULT_IMPORTANCE, EXPANDED_MIN_WIDTH_PX, FLOAT_POSITIONS, type FitMetrics, type FitResult, type FloatPosition, type GroupAssignment, type GroupDisclosureView, type Importance, type KeyStroke, type Layout, type LayoutBar, type LayoutCommandItem, type LayoutCustomItem, type LayoutData, type LayoutEnv, type LayoutFunction, type LayoutGroup, type LayoutGroupObject, type LayoutItem, type LayoutKnownIds, type LayoutMenu, type LayoutMenuSection, type LayoutOption, type LayoutPanel, type LayoutPanelPatch, type LayoutSection, type LiveGroup, type LiveSection, MEDIUM_MIN_WIDTH_PX, MODES_GROUP, type MenuSection, type NormalizedBar, type NormalizedGroup, type NormalizedSection, type NormalizedUnit, type OmissionCommand, type OverflowMenuView, type OverflowRow, type OverflowSection, PINNED, type PanelPresentation, type PanelPresentationBySize, type PanelWidth, type ParsedShortcut, type RemoveItemOptions, type ResolveMenuTarget, type SectionName, type SelectionTarget, type StripGroup, type StripView, type StripViewGroup, type TabsVisibility, type ToolbarCommand, type ToolbarLayout, type ToolbarLayoutInput, type ToolbarMeasureKeys, type ToolbarPart, type UnitAssignment, VIEW_MODE_COMMAND, type Variant, type ViewerSize, barsAt, barsFloating, barsInMode, barsOnEdge, barsWith, closestMatch, commandOfUnit, compileBar, createLayout, custom, didYouMean, edgeOf, edgeStackOf, editDistance, filterBar, floatOf, floatStackOf, formatShortcut, group, groupMenuView, hasVisibleUnits, hostOf, isLayout, isStandaloneUnit, item, itemCommandOf, itemIdOf, layoutToolbar, matchShortcut, menuOf, modeCommandOf, modesOf, normalizeBar, omittedCommandsOf, panelCommandOf, panelPresentationsOf, panelWidthFieldsOf, parseShortcut, projectOverflow, projectShed, projectStrip, resolveLayout, sameLayoutEnv, sameShortcut, sameStripGroups, selectionOf, sizeOf, solve, stripGroupsOf, tabsOf, validateLayout };
834
+ //#region src/tree-keys.d.ts
835
+ /**
836
+ * The keyboard of a tree view, as the ARIA tree pattern has it — pure.
837
+ * A view hands in the rows that show (in order, each with its depth, whether
838
+ * it has children and whether they show), the focused row and the key
839
+ * (`KeyboardEvent.key`); it gets back what the key does, and does it. A key
840
+ * that does nothing returns `null`, so the view lets the event go on.
841
+ *
842
+ * ArrowDown, ArrowUp the next, the previous row
843
+ * ArrowRight a collapsed parent expands; an expanded one moves to its first child
844
+ * ArrowLeft an expanded parent collapses; any other row moves to its parent
845
+ * Home, End the first, the last row
846
+ * * every collapsed sibling of the focused row expands
847
+ * Enter the row activates
848
+ * F2, Delete the row is renamed or deleted, when the tree is editable
849
+ */
850
+ /** A row as the keyboard sees it. */
851
+ interface TreeKeyRow {
852
+ /** How deep it sits: 0 at the top level. */
853
+ readonly depth: number;
854
+ readonly hasChildren: boolean;
855
+ /** Whether its children show. */
856
+ readonly expanded: boolean;
857
+ }
858
+ /** What a key does, naming rows by their index in the rows handed in. */
859
+ type TreeKeyAction = {
860
+ readonly type: 'focus';
861
+ readonly row: number;
862
+ } | {
863
+ readonly type: 'expand';
864
+ readonly rows: readonly number[];
865
+ } | {
866
+ readonly type: 'collapse';
867
+ readonly row: number;
868
+ } | {
869
+ readonly type: 'activate';
870
+ readonly row: number;
871
+ } | {
872
+ readonly type: 'rename';
873
+ readonly row: number;
874
+ } | {
875
+ readonly type: 'delete';
876
+ readonly row: number;
877
+ };
878
+ interface TreeKeyOptions {
879
+ /** Whether F2 and Delete edit the tree. Off by default: a reader's tree only moves and opens. */
880
+ readonly editable?: boolean;
881
+ }
882
+ declare function treeKeyAction(rows: readonly TreeKeyRow[], focused: number, key: string, options?: TreeKeyOptions): TreeKeyAction | null;
883
+ //#endregion
884
+ export { type AddItemOptions, type BarChild, type BarEdge, type BarGroup, type BarItem, type BarPlace, type BarSchema, type BarSections, type CollapsedGroupView, type CompileBarOptions, type CustomItem, type CustomSlotCtx, DEFAULT_IMPORTANCE, EXPANDED_MIN_WIDTH_PX, FLOAT_POSITIONS, type FitMetrics, type FitResult, type FloatPosition, type GroupAssignment, type GroupDisclosureView, type Importance, type KeyStroke, type Layout, type LayoutBar, type LayoutCommandItem, type LayoutCustomItem, type LayoutData, type LayoutEnv, type LayoutFunction, type LayoutGroup, type LayoutGroupObject, type LayoutItem, type LayoutKnownIds, type LayoutMenu, type LayoutMenuSection, type LayoutOption, type LayoutPanel, type LayoutPanelPatch, type LayoutSection, type LiveGroup, type LiveSection, MEDIUM_MIN_WIDTH_PX, MODES_GROUP, type MenuSection, type NormalizedBar, type NormalizedGroup, type NormalizedSection, type NormalizedUnit, type OmissionCommand, type OverflowMenuView, type OverflowRow, type OverflowSection, PINNED, type PanelPresentation, type PanelPresentationBySize, type PanelWidth, type ParsedShortcut, type RemoveItemOptions, type ResolveMenuTarget, type SectionName, type SelectionTarget, type StripGroup, type StripView, type StripViewGroup, type TabsVisibility, type ToolbarCommand, type ToolbarLayout, type ToolbarLayoutInput, type ToolbarMeasureKeys, type ToolbarPart, type TreeKeyAction, type TreeKeyOptions, type TreeKeyRow, type UnitAssignment, VIEW_MODE_COMMAND, type Variant, type ViewerSize, barsAt, barsFloating, barsInMode, barsOnEdge, barsWith, closestMatch, commandOfUnit, compileBar, createLayout, custom, didYouMean, edgeOf, edgeStackOf, editDistance, filterBar, floatOf, floatStackOf, formatShortcut, group, groupMenuView, hasVisibleUnits, hostOf, isLayout, isStandaloneUnit, item, itemCommandOf, itemIdOf, layoutToolbar, matchShortcut, menuOf, modeCommandOf, modesOf, normalizeBar, omittedCommandsOf, panelCommandOf, panelPresentationsOf, panelWidthFieldsOf, parseShortcut, projectOverflow, projectShed, projectStrip, resolveLayout, sameLayoutEnv, sameShortcut, sameStripGroups, selectionOf, sizeOf, solve, stripGroupsOf, tabsOf, treeKeyAction, validateLayout };
835
885
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -831,5 +831,55 @@ declare function formatShortcut(shortcut: string, options: {
831
831
  isMac: boolean;
832
832
  }): string;
833
833
  //#endregion
834
- export { type AddItemOptions, type BarChild, type BarEdge, type BarGroup, type BarItem, type BarPlace, type BarSchema, type BarSections, type CollapsedGroupView, type CompileBarOptions, type CustomItem, type CustomSlotCtx, DEFAULT_IMPORTANCE, EXPANDED_MIN_WIDTH_PX, FLOAT_POSITIONS, type FitMetrics, type FitResult, type FloatPosition, type GroupAssignment, type GroupDisclosureView, type Importance, type KeyStroke, type Layout, type LayoutBar, type LayoutCommandItem, type LayoutCustomItem, type LayoutData, type LayoutEnv, type LayoutFunction, type LayoutGroup, type LayoutGroupObject, type LayoutItem, type LayoutKnownIds, type LayoutMenu, type LayoutMenuSection, type LayoutOption, type LayoutPanel, type LayoutPanelPatch, type LayoutSection, type LiveGroup, type LiveSection, MEDIUM_MIN_WIDTH_PX, MODES_GROUP, type MenuSection, type NormalizedBar, type NormalizedGroup, type NormalizedSection, type NormalizedUnit, type OmissionCommand, type OverflowMenuView, type OverflowRow, type OverflowSection, PINNED, type PanelPresentation, type PanelPresentationBySize, type PanelWidth, type ParsedShortcut, type RemoveItemOptions, type ResolveMenuTarget, type SectionName, type SelectionTarget, type StripGroup, type StripView, type StripViewGroup, type TabsVisibility, type ToolbarCommand, type ToolbarLayout, type ToolbarLayoutInput, type ToolbarMeasureKeys, type ToolbarPart, type UnitAssignment, VIEW_MODE_COMMAND, type Variant, type ViewerSize, barsAt, barsFloating, barsInMode, barsOnEdge, barsWith, closestMatch, commandOfUnit, compileBar, createLayout, custom, didYouMean, edgeOf, edgeStackOf, editDistance, filterBar, floatOf, floatStackOf, formatShortcut, group, groupMenuView, hasVisibleUnits, hostOf, isLayout, isStandaloneUnit, item, itemCommandOf, itemIdOf, layoutToolbar, matchShortcut, menuOf, modeCommandOf, modesOf, normalizeBar, omittedCommandsOf, panelCommandOf, panelPresentationsOf, panelWidthFieldsOf, parseShortcut, projectOverflow, projectShed, projectStrip, resolveLayout, sameLayoutEnv, sameShortcut, sameStripGroups, selectionOf, sizeOf, solve, stripGroupsOf, tabsOf, validateLayout };
834
+ //#region src/tree-keys.d.ts
835
+ /**
836
+ * The keyboard of a tree view, as the ARIA tree pattern has it — pure.
837
+ * A view hands in the rows that show (in order, each with its depth, whether
838
+ * it has children and whether they show), the focused row and the key
839
+ * (`KeyboardEvent.key`); it gets back what the key does, and does it. A key
840
+ * that does nothing returns `null`, so the view lets the event go on.
841
+ *
842
+ * ArrowDown, ArrowUp the next, the previous row
843
+ * ArrowRight a collapsed parent expands; an expanded one moves to its first child
844
+ * ArrowLeft an expanded parent collapses; any other row moves to its parent
845
+ * Home, End the first, the last row
846
+ * * every collapsed sibling of the focused row expands
847
+ * Enter the row activates
848
+ * F2, Delete the row is renamed or deleted, when the tree is editable
849
+ */
850
+ /** A row as the keyboard sees it. */
851
+ interface TreeKeyRow {
852
+ /** How deep it sits: 0 at the top level. */
853
+ readonly depth: number;
854
+ readonly hasChildren: boolean;
855
+ /** Whether its children show. */
856
+ readonly expanded: boolean;
857
+ }
858
+ /** What a key does, naming rows by their index in the rows handed in. */
859
+ type TreeKeyAction = {
860
+ readonly type: 'focus';
861
+ readonly row: number;
862
+ } | {
863
+ readonly type: 'expand';
864
+ readonly rows: readonly number[];
865
+ } | {
866
+ readonly type: 'collapse';
867
+ readonly row: number;
868
+ } | {
869
+ readonly type: 'activate';
870
+ readonly row: number;
871
+ } | {
872
+ readonly type: 'rename';
873
+ readonly row: number;
874
+ } | {
875
+ readonly type: 'delete';
876
+ readonly row: number;
877
+ };
878
+ interface TreeKeyOptions {
879
+ /** Whether F2 and Delete edit the tree. Off by default: a reader's tree only moves and opens. */
880
+ readonly editable?: boolean;
881
+ }
882
+ declare function treeKeyAction(rows: readonly TreeKeyRow[], focused: number, key: string, options?: TreeKeyOptions): TreeKeyAction | null;
883
+ //#endregion
884
+ export { type AddItemOptions, type BarChild, type BarEdge, type BarGroup, type BarItem, type BarPlace, type BarSchema, type BarSections, type CollapsedGroupView, type CompileBarOptions, type CustomItem, type CustomSlotCtx, DEFAULT_IMPORTANCE, EXPANDED_MIN_WIDTH_PX, FLOAT_POSITIONS, type FitMetrics, type FitResult, type FloatPosition, type GroupAssignment, type GroupDisclosureView, type Importance, type KeyStroke, type Layout, type LayoutBar, type LayoutCommandItem, type LayoutCustomItem, type LayoutData, type LayoutEnv, type LayoutFunction, type LayoutGroup, type LayoutGroupObject, type LayoutItem, type LayoutKnownIds, type LayoutMenu, type LayoutMenuSection, type LayoutOption, type LayoutPanel, type LayoutPanelPatch, type LayoutSection, type LiveGroup, type LiveSection, MEDIUM_MIN_WIDTH_PX, MODES_GROUP, type MenuSection, type NormalizedBar, type NormalizedGroup, type NormalizedSection, type NormalizedUnit, type OmissionCommand, type OverflowMenuView, type OverflowRow, type OverflowSection, PINNED, type PanelPresentation, type PanelPresentationBySize, type PanelWidth, type ParsedShortcut, type RemoveItemOptions, type ResolveMenuTarget, type SectionName, type SelectionTarget, type StripGroup, type StripView, type StripViewGroup, type TabsVisibility, type ToolbarCommand, type ToolbarLayout, type ToolbarLayoutInput, type ToolbarMeasureKeys, type ToolbarPart, type TreeKeyAction, type TreeKeyOptions, type TreeKeyRow, type UnitAssignment, VIEW_MODE_COMMAND, type Variant, type ViewerSize, barsAt, barsFloating, barsInMode, barsOnEdge, barsWith, closestMatch, commandOfUnit, compileBar, createLayout, custom, didYouMean, edgeOf, edgeStackOf, editDistance, filterBar, floatOf, floatStackOf, formatShortcut, group, groupMenuView, hasVisibleUnits, hostOf, isLayout, isStandaloneUnit, item, itemCommandOf, itemIdOf, layoutToolbar, matchShortcut, menuOf, modeCommandOf, modesOf, normalizeBar, omittedCommandsOf, panelCommandOf, panelPresentationsOf, panelWidthFieldsOf, parseShortcut, projectOverflow, projectShed, projectStrip, resolveLayout, sameLayoutEnv, sameShortcut, sameStripGroups, selectionOf, sizeOf, solve, stripGroupsOf, tabsOf, treeKeyAction, validateLayout };
835
885
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1575,6 +1575,84 @@ function capitalize(text) {
1575
1575
  return text.charAt(0).toUpperCase() + text.slice(1);
1576
1576
  }
1577
1577
  //#endregion
1578
- export { DEFAULT_IMPORTANCE, EXPANDED_MIN_WIDTH_PX, FLOAT_POSITIONS, MEDIUM_MIN_WIDTH_PX, MODES_GROUP, PINNED, VIEW_MODE_COMMAND, barsAt, barsFloating, barsInMode, barsOnEdge, barsWith, closestMatch, commandOfUnit, compileBar, createLayout, custom, didYouMean, edgeOf, edgeStackOf, editDistance, filterBar, floatOf, floatStackOf, formatShortcut, group, groupMenuView, hasVisibleUnits, hostOf, isLayout, isStandaloneUnit, item, itemCommandOf, itemIdOf, layoutToolbar, matchShortcut, menuOf, modeCommandOf, modesOf, normalizeBar, omittedCommandsOf, panelCommandOf, panelPresentationsOf, panelWidthFieldsOf, parseShortcut, projectOverflow, projectShed, projectStrip, resolveLayout, sameLayoutEnv, sameShortcut, sameStripGroups, selectionOf, sizeOf, solve, stripGroupsOf, tabsOf, validateLayout };
1578
+ //#region src/tree-keys.ts
1579
+ /** The row `row` sits under: the nearest one above it that is one level up, or -1 at the top. */
1580
+ function parentOf(rows, row) {
1581
+ const depth = rows[row].depth;
1582
+ for (let i = row - 1; i >= 0; i -= 1) if (rows[i].depth < depth) return i;
1583
+ return -1;
1584
+ }
1585
+ /** The rows that share `row`'s parent, `row` among them, in order. */
1586
+ function siblingsOf(rows, row) {
1587
+ const depth = rows[row].depth;
1588
+ const siblings = [];
1589
+ for (let i = parentOf(rows, row) + 1; i < rows.length; i += 1) {
1590
+ if (rows[i].depth < depth) break;
1591
+ if (rows[i].depth === depth) siblings.push(i);
1592
+ }
1593
+ return siblings;
1594
+ }
1595
+ function treeKeyAction(rows, focused, key, options = {}) {
1596
+ if (rows.length === 0) return null;
1597
+ const last = rows.length - 1;
1598
+ if (focused < 0 || focused > last) {
1599
+ if (key === "ArrowDown" || key === "Home") return {
1600
+ type: "focus",
1601
+ row: 0
1602
+ };
1603
+ if (key === "ArrowUp" || key === "End") return {
1604
+ type: "focus",
1605
+ row: last
1606
+ };
1607
+ return null;
1608
+ }
1609
+ const current = rows[focused];
1610
+ const focus = (row) => row === focused ? null : {
1611
+ type: "focus",
1612
+ row
1613
+ };
1614
+ switch (key) {
1615
+ case "ArrowDown": return focus(Math.min(focused + 1, last));
1616
+ case "ArrowUp": return focus(Math.max(focused - 1, 0));
1617
+ case "Home": return focus(0);
1618
+ case "End": return focus(last);
1619
+ case "ArrowRight":
1620
+ if (!current.hasChildren) return null;
1621
+ return current.expanded ? focus(focused + 1) : {
1622
+ type: "expand",
1623
+ rows: [focused]
1624
+ };
1625
+ case "ArrowLeft": {
1626
+ if (current.hasChildren && current.expanded) return {
1627
+ type: "collapse",
1628
+ row: focused
1629
+ };
1630
+ const parent = parentOf(rows, focused);
1631
+ return parent < 0 ? null : focus(parent);
1632
+ }
1633
+ case "*": {
1634
+ const collapsed = siblingsOf(rows, focused).filter((row) => rows[row].hasChildren && !rows[row].expanded);
1635
+ return collapsed.length > 0 ? {
1636
+ type: "expand",
1637
+ rows: collapsed
1638
+ } : null;
1639
+ }
1640
+ case "Enter": return {
1641
+ type: "activate",
1642
+ row: focused
1643
+ };
1644
+ case "F2": return options.editable ? {
1645
+ type: "rename",
1646
+ row: focused
1647
+ } : null;
1648
+ case "Delete": return options.editable ? {
1649
+ type: "delete",
1650
+ row: focused
1651
+ } : null;
1652
+ default: return null;
1653
+ }
1654
+ }
1655
+ //#endregion
1656
+ export { DEFAULT_IMPORTANCE, EXPANDED_MIN_WIDTH_PX, FLOAT_POSITIONS, MEDIUM_MIN_WIDTH_PX, MODES_GROUP, PINNED, VIEW_MODE_COMMAND, barsAt, barsFloating, barsInMode, barsOnEdge, barsWith, closestMatch, commandOfUnit, compileBar, createLayout, custom, didYouMean, edgeOf, edgeStackOf, editDistance, filterBar, floatOf, floatStackOf, formatShortcut, group, groupMenuView, hasVisibleUnits, hostOf, isLayout, isStandaloneUnit, item, itemCommandOf, itemIdOf, layoutToolbar, matchShortcut, menuOf, modeCommandOf, modesOf, normalizeBar, omittedCommandsOf, panelCommandOf, panelPresentationsOf, panelWidthFieldsOf, parseShortcut, projectOverflow, projectShed, projectStrip, resolveLayout, sameLayoutEnv, sameShortcut, sameStripGroups, selectionOf, sizeOf, solve, stripGroupsOf, tabsOf, treeKeyAction, validateLayout };
1579
1657
 
1580
1658
  //# sourceMappingURL=index.js.map