xmlui 0.7.27 → 0.7.28

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.
Files changed (54) hide show
  1. package/dist/{apiInterceptorWorker-Ca5HMlfW.mjs → apiInterceptorWorker-FalV8U3I.mjs} +1 -1
  2. package/dist/{index-BMOK5q0U.mjs → index-CTUFRo8v.mjs} +8230 -8042
  3. package/dist/scripts/src/components/APICall/APICall.js +31 -29
  4. package/dist/scripts/src/components/AppHeader/AppHeader.js +4 -4
  5. package/dist/scripts/src/components/Badge/Badge.js +2 -2
  6. package/dist/scripts/src/components/Bookmark/Bookmark.js +7 -7
  7. package/dist/scripts/src/components/Bookmark/BookmarkNative.js +2 -2
  8. package/dist/scripts/src/components/Button/Button.js +1 -7
  9. package/dist/scripts/src/components/Carousel/Carousel.js +3 -1
  10. package/dist/scripts/src/components/Checkbox/Checkbox.js +0 -1
  11. package/dist/scripts/src/components/ColorPicker/ColorPicker.js +1 -1
  12. package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +2 -1
  13. package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +13 -4
  14. package/dist/scripts/src/components/FlowLayout/FlowLayout.js +18 -8
  15. package/dist/scripts/src/components/FlowLayout/FlowLayoutNative.js +5 -1
  16. package/dist/scripts/src/components/Form/Form.js +53 -17
  17. package/dist/scripts/src/components/Form/FormNative.js +9 -1
  18. package/dist/scripts/src/components/FormItem/FormItem.js +11 -5
  19. package/dist/scripts/src/components/FormItem/FormItemNative.js +6 -1
  20. package/dist/scripts/src/components/Heading/Heading.js +23 -4
  21. package/dist/scripts/src/components/Heading/HeadingNative.js +9 -4
  22. package/dist/scripts/src/components/Icon/Icon.js +6 -2
  23. package/dist/scripts/src/components/Icon/IconNative.js +2 -2
  24. package/dist/scripts/src/components/Image/Image.js +5 -1
  25. package/dist/scripts/src/components/Items/Items.js +4 -2
  26. package/dist/scripts/src/components/Items/ItemsNative.js +1 -3
  27. package/dist/scripts/src/components/Link/Link.js +13 -4
  28. package/dist/scripts/src/components/List/List.js +22 -5
  29. package/dist/scripts/src/components/Markdown/Markdown.js +8 -4
  30. package/dist/scripts/src/components/ModalDialog/ModalDialog.js +12 -6
  31. package/dist/scripts/src/components/NavLink/NavLink.js +28 -10
  32. package/dist/scripts/src/components/NoResult/NoResult.js +6 -2
  33. package/dist/scripts/src/components/NumberBox/NumberBox.js +22 -6
  34. package/dist/scripts/src/components/ProgressBar/ProgressBar.js +5 -1
  35. package/dist/scripts/src/components/Spinner/Spinner.js +10 -2
  36. package/dist/scripts/src/components/Splitter/Splitter.js +38 -13
  37. package/dist/scripts/src/components/Stack/Stack.js +39 -11
  38. package/dist/scripts/src/components/StickyBox/StickyBox.js +7 -2
  39. package/dist/scripts/src/components/Switch/Switch.js +0 -1
  40. package/dist/scripts/src/components/Table/Table.js +35 -18
  41. package/dist/scripts/src/components/TableOfContents/TableOfContents.js +13 -4
  42. package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +15 -22
  43. package/dist/scripts/src/components/Tabs/Tabs.js +8 -3
  44. package/dist/scripts/src/components/Text/Text.js +20 -8
  45. package/dist/scripts/src/components/TextArea/TextArea.js +30 -13
  46. package/dist/scripts/src/components/Theme/Theme.js +6 -2
  47. package/dist/scripts/src/components/abstractions.js +14 -3
  48. package/dist/scripts/src/components-core/TableOfContentsContext.js +57 -17
  49. package/dist/style.css +1 -1
  50. package/dist/xmlui-metadata.mjs +9161 -5514
  51. package/dist/xmlui-metadata.umd.js +17 -17
  52. package/dist/xmlui-standalone.umd.js +165 -165
  53. package/dist/xmlui.mjs +1 -1
  54. package/package.json +1 -1
@@ -22,18 +22,25 @@ exports.TableMd = (0, ComponentDefs_1.createMetadata)({
22
22
  description: `\`${COMP}\` is a component that displays cells organized into rows and columns. The \`${COMP}\` ` +
23
23
  `component is virtualized so it only renders visible cells.`,
24
24
  props: {
25
- items: (0, ComponentDefs_1.d)(`You can use \`items\` as an alias for the \`data\` property. ` +
25
+ items: (0, metadata_helpers_1.dInternal)(`You can use \`items\` as an alias for the \`data\` property. ` +
26
26
  `When you bind the table to a data source (e.g. an API endpoint), ` +
27
27
  `the \`data\` acts as the property that accepts a URL to fetch information from an API. ` +
28
28
  `When both \`items\` and \`data\` are used, \`items\` has priority.`),
29
29
  data: (0, ComponentDefs_1.d)(`The component receives data via this property. The \`data\` property is a list of items ` +
30
30
  `that the \`Table\` can display.`),
31
- isPaginated: (0, ComponentDefs_1.d)(`This property adds pagination controls to the \`${COMP}\`.`),
31
+ isPaginated: {
32
+ description: `This property adds pagination controls to the \`${COMP}\`.`,
33
+ valueType: "boolean",
34
+ defaultValue: false,
35
+ },
32
36
  loading: (0, ComponentDefs_1.d)(`This boolean property indicates if the component is fetching (or processing) data. This ` +
33
37
  `property is useful when data is loaded conditionally or receiving it takes some time.`),
34
38
  headerHeight: (0, ComponentDefs_1.d)(`This optional property is used to specify the height of the table header.`),
35
39
  rowsSelectable: (0, ComponentDefs_1.d)(`Indicates whether the rows are selectable (\`true\`) or not (\`false\`).`),
36
- pageSizes: (0, ComponentDefs_1.d)(`Describes how big a page should be for pagination.`),
40
+ pageSizes: {
41
+ description: "This property holds an array of page sizes (numbers) the user can select for " +
42
+ "pagination. If this property is not defined, the component allows only a page size of 10 items.",
43
+ },
37
44
  rowDisabledPredicate: (0, ComponentDefs_1.d)(`This property defines a predicate function with a return value that determines if the ` +
38
45
  `row should be disabled. The function retrieves the item to display and should return ` +
39
46
  `a Boolean-like value.`),
@@ -42,21 +49,31 @@ exports.TableMd = (0, ComponentDefs_1.createMetadata)({
42
49
  sortDirection: (0, ComponentDefs_1.d)(`This property determines the sort order to be \`ascending\` or \`descending\`. This ` +
43
50
  `property only works if the [\`sortBy\`](#sortby) property is also set.`),
44
51
  autoFocus: (0, metadata_helpers_1.dAutoFocus)(),
45
- hideHeader: (0, ComponentDefs_1.d)(`Set the header visibility using this property. Set it to \`true\` to hide the header.`),
46
- iconNoSort: (0, ComponentDefs_1.d)(`Allows the customization of the icon displayed in the ${COMP} column header when ` +
47
- `when sorting is enabled and sorting is not done according to the column.`),
48
- iconSortAsc: (0, ComponentDefs_1.d)(`Allows the customization of the icon displayed in the ${COMP} column header when sorting ` +
49
- `is enabled, sorting is done according to the column, and the column is sorted in ` +
50
- `ascending order.`),
51
- iconSortDesc: (0, ComponentDefs_1.d)(`Allows the customization of the icon displayed in the ${COMP} column header when sorting ` +
52
- `is enabled, sorting is done according to the column, and the column is sorted in ` +
53
- `descending order.`),
54
- enableMultiRowSelection: (0, ComponentDefs_1.d)(`This boolean property indicates whether you can select multiple rows in the table. ` +
55
- `This property only has an effect when the rowsSelectable property is set. Setting it ` +
56
- `to \`false\` limits selection to a single row.`),
57
- alwaysShowSelectionHeader: (0, ComponentDefs_1.d)("This property indicates when the row selection header is displayed. When the value is " +
58
- "`true,` the selection header is always visible. Otherwise, it is displayed only " +
59
- "when hovered.", null, "boolean", false),
52
+ hideHeader: {
53
+ description: "Set the header visibility using this property. Set it to \`true\` to hide the header.",
54
+ valueType: "boolean",
55
+ defaultValue: false,
56
+ },
57
+ iconNoSort: (0, ComponentDefs_1.d)(`Allows setting the icon displayed in the ${COMP} column header when sorting is ` +
58
+ `enabled, but the column remains unsorted.`),
59
+ iconSortAsc: (0, ComponentDefs_1.d)(`Allows setting the icon displayed in the ${COMP} column header when sorting is enabled, ` +
60
+ `and the column is sorted in ascending order.`),
61
+ iconSortDesc: (0, ComponentDefs_1.d)(`Allows setting the icon displayed in the ${COMP} column header when sorting is enabled, ` +
62
+ `and the column is sorted in descending order.`),
63
+ enableMultiRowSelection: {
64
+ description: `This boolean property indicates whether you can select multiple rows in the table. ` +
65
+ `This property only has an effect when the rowsSelectable property is set. Setting it ` +
66
+ `to \`false\` limits selection to a single row.`,
67
+ valueType: "boolean",
68
+ defaultValue: true,
69
+ },
70
+ alwaysShowSelectionHeader: {
71
+ description: "This property indicates when the row selection header is displayed. When the value is " +
72
+ "`true,` the selection header is always visible. Otherwise, it is displayed only " +
73
+ "when hovered.",
74
+ valueType: "boolean",
75
+ defaultValue: false,
76
+ },
60
77
  },
61
78
  events: {
62
79
  sortingDidChange: (0, ComponentDefs_1.d)(`This event is fired when the table data sorting has changed. It has two arguments: ` +
@@ -17,10 +17,19 @@ exports.TableOfContentsMd = (0, ComponentDefs_1.createMetadata)({
17
17
  `and displays them in a tree representing their hierarchy. When you select an item ` +
18
18
  `in this tree, the component navigates the page to the selected position.`,
19
19
  props: {
20
- smoothScrolling: (0, ComponentDefs_1.d)(`This property indicates that smooth scrolling is used while scrolling the selected table ` +
21
- `of contents items into view.`),
22
- maxHeadingLevel: (0, ComponentDefs_1.d)("Defines the maximum heading level to include in the table of contents. Headings " +
23
- "with a level greater than this value will be excluded."),
20
+ smoothScrolling: {
21
+ description: `This property indicates that smooth scrolling is used while scrolling the selected table ` +
22
+ `of contents items into view.`,
23
+ valueType: "boolean",
24
+ defaultValue: "false",
25
+ },
26
+ maxHeadingLevel: {
27
+ description: "Defines the maximum heading level (1 to 6) to include in the table of contents. " +
28
+ "For example, if it is 2, then `H1` and `H2` are displayed, but lower levels " +
29
+ "(`H3` to `H6`) are not.",
30
+ valueType: "number",
31
+ defaultValue: "6",
32
+ },
24
33
  },
25
34
  themeVars: (0, themeVars_1.parseScssVar)(TableOfContents_module_scss_1.default.themeVars),
26
35
  defaultThemeVars: {
@@ -12,15 +12,19 @@ const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
12
12
  const classnames_1 = __importDefault(require("classnames"));
13
13
  const TableOfContents_module_scss_1 = __importDefault(require("./TableOfContents.module.scss"));
14
14
  const TableOfContentsContext_1 = require("../../components-core/TableOfContentsContext");
15
- const react_router_dom_1 = require("react-router-dom");
16
15
  exports.TableOfContents = (0, react_1.forwardRef)(function TableOfContents({ style, smoothScrolling, maxHeadingLevel = 6 }, forwardedRef) {
17
16
  const tocRef = (0, react_1.useRef)(null);
18
- const { headings, setObserveIntersection, activeAnchorId, setActiveAnchorId } = (0, TableOfContentsContext_1.useTableOfContents)();
17
+ const [activeAnchorId, setActiveId] = (0, react_1.useState)(null);
18
+ const { headings, scrollToAnchor, subscribeToActiveAnchorChange } = (0, TableOfContentsContext_1.useTableOfContents)();
19
+ (0, react_1.useLayoutEffect)(() => {
20
+ return subscribeToActiveAnchorChange((id) => {
21
+ const foundHeading = headings.find((heading) => heading.id === id);
22
+ if (foundHeading.level <= maxHeadingLevel) {
23
+ setActiveId(id);
24
+ }
25
+ });
26
+ }, [headings, maxHeadingLevel, subscribeToActiveAnchorChange]);
19
27
  const ref = forwardedRef ? (0, react_compose_refs_1.composeRefs)(tocRef, forwardedRef) : tocRef;
20
- const navigate = (0, react_router_dom_1.useNavigate)();
21
- (0, react_1.useEffect)(() => {
22
- setObserveIntersection(true);
23
- }, [setObserveIntersection]);
24
28
  (0, react_1.useEffect)(() => {
25
29
  if (activeAnchorId && (tocRef === null || tocRef === void 0 ? void 0 : tocRef.current)) {
26
30
  const activeAnchor = tocRef.current.querySelector(`#${activeAnchorId}`);
@@ -47,22 +51,11 @@ exports.TableOfContents = (0, react_1.forwardRef)(function TableOfContents({ sty
47
51
  [TableOfContents_module_scss_1.default.head_5]: value.level === 5,
48
52
  [TableOfContents_module_scss_1.default.head_6]: value.level === 6,
49
53
  }), to: `#${value.id}`, onClick: (event) => {
50
- event.preventDefault();
51
- value.anchor.scrollIntoView({
52
- block: "start",
53
- inline: "start",
54
- behavior: smoothScrolling ? "smooth" : "auto",
55
- });
56
- setActiveAnchorId(value.id);
57
- requestAnimationFrame(() => {
58
- navigate({
59
- hash: `#${value.id}`,
60
- }, {
61
- state: {
62
- preventHashScroll: true
63
- },
64
- });
65
- });
54
+ // cmd/ctrl + click - open in new tab, don't prevent that
55
+ if (!event.ctrlKey && !event.metaKey && !event.metaKey) {
56
+ event.preventDefault();
57
+ }
58
+ scrollToAnchor(value.id, smoothScrolling);
66
59
  }, id: value.id, children: value.text }) }, value.id));
67
60
  }
68
61
  return null;
@@ -19,9 +19,14 @@ exports.TabsMd = (0, ComponentDefs_1.createMetadata)({
19
19
  props: {
20
20
  activeTab: (0, ComponentDefs_1.d)(`This property indicates the index of the active tab. The indexing starts from 0, ` +
21
21
  `representing the starting (leftmost) tab.`),
22
- orientation: (0, ComponentDefs_1.d)(`This property indicates the orientation of the component. In horizontal orientation, ` +
23
- `the tab sections are laid out on the left side of the content panel, while in vertical ` +
24
- `orientation, the buttons are at the top.`),
22
+ orientation: {
23
+ description: `This property indicates the orientation of the component. In horizontal orientation, ` +
24
+ `the tab sections are laid out on the left side of the content panel, while in vertical ` +
25
+ `orientation, the buttons are at the top.`,
26
+ availableValues: ["horizontal", "vertical"],
27
+ defaultValue: "vertical",
28
+ valueType: "string",
29
+ },
25
30
  tabTemplate: (0, metadata_helpers_1.dComponent)(`This property declares the template for the clickable tab area.`),
26
31
  },
27
32
  apis: {
@@ -29,14 +29,26 @@ exports.TextMd = (0, ComponentDefs_1.createMetadata)({
29
29
  props: {
30
30
  value: (0, ComponentDefs_1.d)(`The text to be displayed. This value can also be set via nesting the text into ` +
31
31
  `the \`${COMP}\` component.`),
32
- variant: (0, ComponentDefs_1.d)(`Optional string value that provides named presets for text variants with a ` +
33
- `unique combination of font style, weight, size, color and other parameters.`, abstractions_1.variantOptionsMd),
34
- maxLines: (0, ComponentDefs_1.d)(`This property determines the maximum number of lines the component can wrap to. ` +
35
- `If there is no space to display all the contents, the component displays up to ` +
36
- `as many lines as specified in this property.`),
37
- preserveLinebreaks: (0, ComponentDefs_1.d)(`This property indicates if linebreaks should be preserved when displaying text.`),
38
- ellipses: (0, ComponentDefs_1.d)(`This property indicates whether ellipses should be displayed when the text is ` +
39
- `cropped (\`true\`) or not (\`false\`).`),
32
+ variant: {
33
+ description: "An optional string value that provides named presets for text variants with a " +
34
+ "unique combination of font style, weight, size, color, and other parameters. " +
35
+ "If not defined, the text uses the current style of its context.",
36
+ availableValues: abstractions_1.variantOptionsMd,
37
+ },
38
+ maxLines: (0, ComponentDefs_1.d)("This property determines the maximum number of lines the component can wrap to. " +
39
+ "If there is no space to display all the contents, the component displays up to as " +
40
+ "many lines as specified in this property. When the value is not defined, there is no limit on the displayed lines."),
41
+ preserveLinebreaks: {
42
+ description: `This property indicates if linebreaks should be preserved when displaying text.`,
43
+ valueType: "boolean",
44
+ defaultValue: "false",
45
+ },
46
+ ellipses: {
47
+ description: "This property indicates whether ellipses should be displayed when the text is " +
48
+ "cropped (\`true\`) or not (\`false\`).",
49
+ valueType: "boolean",
50
+ defaultValue: false,
51
+ },
40
52
  },
41
53
  themeVars: (0, themeVars_1.parseScssVar)(Text_module_scss_1.default.themeVars),
42
54
  defaultThemeVars: {
@@ -13,7 +13,7 @@ const metadata_helpers_1 = require("../metadata-helpers");
13
13
  const TextAreaNative_1 = require("./TextAreaNative");
14
14
  const COMP = "TextArea";
15
15
  exports.resizeOptionsMd = [
16
- { value: "undefined", description: "No resizing" },
16
+ { value: "(undefined)", description: "No resizing" },
17
17
  { value: "horizontal", description: "Can only resize horizontally" },
18
18
  { value: "vertical", description: "Can only resize vertically" },
19
19
  { value: "both", description: "Can resize in both dimensions" },
@@ -22,16 +22,31 @@ exports.TextAreaMd = (0, ComponentDefs_1.createMetadata)({
22
22
  status: "experimental",
23
23
  description: `\`${COMP}\` is a component that provides a multiline text input area.`,
24
24
  props: {
25
- enterSubmits: (0, ComponentDefs_1.d)(`This optional boolean property indicates whether pressing the \`Enter\` key on the ` +
26
- `keyboard prompts the parent \`Form\` component to submit. The default value is is \`true\`.`),
27
- escResets: (0, ComponentDefs_1.d)(`This boolean property indicates whether the ${COMP} contents should be reset when pressing ` +
28
- `the ESC key.`),
29
- maxRows: (0, ComponentDefs_1.d)(`This optional number property maximizes the number of lines the \`${COMP}\` can grow to.`),
30
- minRows: (0, ComponentDefs_1.d)(`This optional number property indicates the minimum number of lines the \`${COMP}\` ` +
31
- `has and specifies its size accordingly.`),
32
- rows: (0, ComponentDefs_1.d)(`Specifies the number of lines or rows (and thus, its size) the component has.`),
33
- autoSize: (0, ComponentDefs_1.d)(`If set to \`true\`, this boolean property enables the \`${COMP}\` to resize ` +
34
- `automatically based on the number of lines inside it.`, null, "boolean", false),
25
+ enterSubmits: {
26
+ description: "This optional boolean property indicates whether pressing the \`Enter\` key on the " +
27
+ "keyboard prompts the parent \`Form\` component to submit.",
28
+ valueType: "boolean",
29
+ defaultValue: true,
30
+ },
31
+ escResets: {
32
+ description: `This boolean property indicates whether the ${COMP} contents should be reset when pressing ` +
33
+ `the ESC key.`,
34
+ valueType: "boolean",
35
+ defaultValue: false,
36
+ },
37
+ maxRows: (0, ComponentDefs_1.d)(`This optional property sets the maximum number of text rows the \`${COMP}\` can grow.`),
38
+ minRows: (0, ComponentDefs_1.d)(`This optional property sets the minimum number of text rows the \`${COMP}\` can shrink.`),
39
+ rows: {
40
+ description: `Specifies the number of rows the component initially has.`,
41
+ valueType: "number",
42
+ defaultValue: 2,
43
+ },
44
+ autoSize: {
45
+ description: `If set to \`true\`, this boolean property enables the \`${COMP}\` to resize ` +
46
+ `automatically based on the number of lines inside it.`,
47
+ valueType: "boolean",
48
+ defaultValue: false,
49
+ },
35
50
  placeholder: (0, metadata_helpers_1.dPlaceholder)(),
36
51
  initialValue: (0, metadata_helpers_1.dInitialValue)(),
37
52
  label: (0, metadata_helpers_1.dLabel)(),
@@ -44,8 +59,10 @@ exports.TextAreaMd = (0, ComponentDefs_1.createMetadata)({
44
59
  readOnly: (0, metadata_helpers_1.dReadonly)(),
45
60
  enabled: (0, metadata_helpers_1.dEnabled)(),
46
61
  validationStatus: (0, metadata_helpers_1.dValidationStatus)(),
47
- resize: (0, ComponentDefs_1.d)(`This optional property specifies in which dimensions can the \`TextArea\` ` +
48
- `be resized by the user.`, exports.resizeOptionsMd),
62
+ resize: { description: `This optional property specifies in which dimensions can the \`TextArea\` ` +
63
+ `be resized by the user.`,
64
+ availableValues: exports.resizeOptionsMd,
65
+ },
49
66
  },
50
67
  events: {
51
68
  gotFocus: (0, metadata_helpers_1.dGotFocus)(COMP),
@@ -25,8 +25,12 @@ exports.ThemeMd = (0, ComponentDefs_1.createMetadata)({
25
25
  allowArbitraryProps: true,
26
26
  props: {
27
27
  themeId: (0, ComponentDefs_1.d)(`This property specifies which theme to use by setting the theme's id.`),
28
- tone: (0, ComponentDefs_1.d)(`This property allows the setting of the current theme's tone. Tone is either ` +
29
- `\`light\` or \`dark\`.`),
28
+ tone: {
29
+ description: "This property allows the setting of the current theme's tone.",
30
+ availableValues: ["light", "dark"],
31
+ valueType: "string",
32
+ defaultValue: "light",
33
+ },
30
34
  root: (0, ComponentDefs_1.d)(`This property indicates whether the component is at the root of the application.`),
31
35
  },
32
36
  opaque: true,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VariantPropsKeys = exports.variantOptionsMd = exports.TextVariantElement = exports.orderingValues = exports.scrollAnchoringNames = exports.scrollAnchoringValues = exports.validationStatusMd = exports.validationStatusNames = exports.validationStatusValues = exports.triggerPositionNames = exports.labelPositionMd = exports.labelPositionNames = exports.labelPositionValues = exports.placementMd = exports.placementNames = exports.statusColorMd = exports.statusColorNames = exports.iconPositionMd = exports.iconPositionNames = exports.iconPositionValues = exports.orientationOptionMd = exports.orientationOptionNames = exports.alignmentOptionMd = exports.alignmentOptionNames = exports.alignmentOptionValues = exports.buttonAriaNames = exports.buttonVariantMd = exports.buttonVariantNames = exports.buttonTypesMd = exports.buttonTypeNames = exports.buttonTypeValues = exports.buttonThemeMd = exports.buttonThemeNames = exports.sizeNames = exports.sizeMd = exports.viewportSizeNames = exports.viewportSizeMd = exports.LinkTargetMd = exports.LinkTargetNames = void 0;
3
+ exports.httpMethodNames = exports.VariantPropsKeys = exports.variantOptionsMd = exports.TextVariantElement = exports.orderingValues = exports.scrollAnchoringNames = exports.scrollAnchoringValues = exports.validationStatusMd = exports.validationStatusNames = exports.validationStatusValues = exports.triggerPositionNames = exports.labelPositionMd = exports.labelPositionNames = exports.labelPositionValues = exports.placementMd = exports.placementNames = exports.statusColorMd = exports.statusColorNames = exports.iconPositionMd = exports.iconPositionNames = exports.iconPositionValues = exports.orientationOptionMd = exports.orientationOptionNames = exports.alignmentOptionMd = exports.alignmentOptionNames = exports.alignmentOptionValues = exports.buttonAriaNames = exports.buttonVariantMd = exports.buttonVariantNames = exports.buttonTypesMd = exports.buttonTypeNames = exports.buttonTypeValues = exports.buttonThemeMd = exports.buttonThemeNames = exports.sizeNames = exports.sizeMd = exports.viewportSizeNames = exports.viewportSizeMd = exports.LinkTargetMd = exports.LinkTargetNames = void 0;
4
4
  exports.LinkTargetNames = ["_self", "_blank", "_parent", "_top", "_unfencedTop"];
5
5
  exports.LinkTargetMd = [
6
6
  {
@@ -21,8 +21,8 @@ exports.LinkTargetMd = [
21
21
  },
22
22
  {
23
23
  value: "_unfencedTop",
24
- description: "Allows embedded fenced frames to navigate the top-level frame, i.e. traversing beyond the root of the fenced frame."
25
- }
24
+ description: "Allows embedded fenced frames to navigate the top-level frame, i.e. traversing beyond the root of the fenced frame.",
25
+ },
26
26
  ];
27
27
  // --- Available view sizes
28
28
  exports.viewportSizeMd = [
@@ -291,3 +291,14 @@ exports.variantOptionsMd = [
291
291
  const AbbreviationKeys = ["title"];
292
292
  const InsertedKeys = ["cite", "dateTime"];
293
293
  exports.VariantPropsKeys = [...AbbreviationKeys, ...InsertedKeys];
294
+ exports.httpMethodNames = [
295
+ "get",
296
+ "post",
297
+ "put",
298
+ "delete",
299
+ "patch",
300
+ "head",
301
+ "options",
302
+ "trace",
303
+ "connect",
304
+ ];
@@ -7,6 +7,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const react_1 = require("react");
8
8
  const hooks_1 = require("./utils/hooks");
9
9
  const react_2 = require("@remix-run/react");
10
+ const constants_1 = require("./constants");
11
+ const react_router_dom_1 = require("react-router-dom");
10
12
  /**
11
13
  * Several components work together to represent the hierarchy of a particular
12
14
  * app page as a TOC. This React component provides a context for storing this
@@ -18,9 +20,8 @@ exports.TableOfContentsContext = (0, react_1.createContext)(null);
18
20
  */
19
21
  function TableOfContentsProvider({ children }) {
20
22
  var _a, _b;
21
- const [headings, setHeadings] = (0, react_1.useState)({});
22
- const [observeIntersection, setObserveIntersection] = (0, react_1.useState)(false);
23
- const [activeId, setActiveId] = (0, react_1.useState)(null);
23
+ const [headings, setHeadings] = (0, react_1.useState)(constants_1.EMPTY_OBJECT);
24
+ const [callbacks, setCallbacks] = (0, react_1.useState)(constants_1.EMPTY_ARRAY);
24
25
  const observer = (0, react_1.useRef)(null);
25
26
  const initialHeading = (0, react_1.useRef)(null);
26
27
  const thisRef = (0, react_1.useRef)({
@@ -32,25 +33,33 @@ function TableOfContentsProvider({ children }) {
32
33
  thisRef.current.suspendPositionBasedSetActiveId = false;
33
34
  }, []),
34
35
  });
36
+ const notify = (0, react_1.useCallback)((id) => {
37
+ callbacks.forEach((cb) => cb(id));
38
+ }, [callbacks]);
35
39
  (0, react_1.useEffect)(() => {
36
- if (observeIntersection) {
40
+ if (callbacks.length) {
37
41
  const handleObserver = (entries) => {
38
42
  entries.forEach((entry) => {
39
43
  if (entry === null || entry === void 0 ? void 0 : entry.isIntersecting) {
40
44
  if (!thisRef.current.suspendPositionBasedSetActiveId) {
41
- setActiveId(entry.target.id);
45
+ notify(entry.target.id);
42
46
  }
43
47
  }
44
48
  });
45
49
  };
50
+ // stolen from nextra: https://github.com/shuding/nextra/blob/3729f67059f1fbdd3f98125bebabbe568c918694/packages/nextra-theme-docs/src/mdx-components/heading-anchor.client.tsx
51
+ // let headerHeight = getComputedStyle(scrollParent || document.body).getPropertyValue(
52
+ // '--header-abs-height'
53
+ // );
46
54
  observer.current = new IntersectionObserver(handleObserver, {
47
- rootMargin: "0px 0px -50%",
48
- threshold: [0, 1],
55
+ rootMargin: `0% 0% -80%`,
56
+ // root: scrollParent,
57
+ // threshold: [0, 1],
49
58
  });
50
59
  Object.values(headings).forEach((elem) => { var _a, _b; return (_b = (_a = observer === null || observer === void 0 ? void 0 : observer.current) === null || _a === void 0 ? void 0 : _a.observe) === null || _b === void 0 ? void 0 : _b.call(_a, elem.anchor); });
51
60
  return () => { var _a; return (_a = observer.current) === null || _a === void 0 ? void 0 : _a.disconnect(); };
52
61
  }
53
- }, [headings, observeIntersection]);
62
+ }, [callbacks.length, headings, notify, scrollParent]);
54
63
  const registerHeading = (0, react_1.useCallback)((headingItem) => {
55
64
  setHeadings((prevHeadings) => {
56
65
  return Object.assign(Object.assign({}, prevHeadings), { [headingItem.id]: headingItem });
@@ -63,12 +72,28 @@ function TableOfContentsProvider({ children }) {
63
72
  });
64
73
  };
65
74
  }, []);
66
- const setActiveAnchorId = (0, react_1.useCallback)((id) => {
67
- if (headings[id]) {
75
+ const navigate = (0, react_router_dom_1.useNavigate)();
76
+ const scrollToAnchor = (0, react_1.useCallback)((id, smoothScrolling) => {
77
+ const value = headings[id];
78
+ if (value) {
79
+ value.anchor.scrollIntoView({
80
+ block: "start",
81
+ inline: "start",
82
+ behavior: smoothScrolling ? "smooth" : "auto",
83
+ });
84
+ notify(id);
85
+ requestAnimationFrame(() => {
86
+ navigate({
87
+ hash: `#${value.id}`,
88
+ }, {
89
+ state: {
90
+ preventHashScroll: true,
91
+ },
92
+ });
93
+ });
68
94
  thisRef.current.suspendPositionBasedSetActiveId = true;
69
- setActiveId(id);
70
95
  }
71
- }, [headings]);
96
+ }, [headings, navigate, notify]);
72
97
  const sortedHeadings = (0, react_1.useMemo)(() => {
73
98
  return Object.values(headings).sort(function (a, b) {
74
99
  if (a.anchor === b.anchor)
@@ -100,16 +125,31 @@ function TableOfContentsProvider({ children }) {
100
125
  }
101
126
  }
102
127
  }, [location.hash, sortedHeadings]);
128
+ const subscribeToActiveAnchorChange = (0, react_1.useCallback)((cb) => {
129
+ setCallbacks((prev) => {
130
+ return [...prev, cb];
131
+ });
132
+ return () => {
133
+ setCallbacks((prev) => {
134
+ return prev.filter((item) => item !== cb);
135
+ });
136
+ };
137
+ }, []);
103
138
  const contextValue = (0, react_1.useMemo)(() => {
104
139
  return {
105
140
  registerHeading,
106
141
  headings: sortedHeadings,
107
- observeIntersection,
108
- setObserveIntersection,
109
- activeAnchorId: activeId,
110
- setActiveAnchorId,
142
+ scrollToAnchor,
143
+ subscribeToActiveAnchorChange,
144
+ hasTableOfContents: callbacks.length > 0,
111
145
  };
112
- }, [registerHeading, sortedHeadings, observeIntersection, activeId, setActiveAnchorId]);
146
+ }, [
147
+ registerHeading,
148
+ sortedHeadings,
149
+ scrollToAnchor,
150
+ subscribeToActiveAnchorChange,
151
+ callbacks.length,
152
+ ]);
113
153
  return ((0, jsx_runtime_1.jsx)(exports.TableOfContentsContext.Provider, { value: contextValue, children: children }));
114
154
  }
115
155
  function useTableOfContents() {