@akohn/dashql-react 0.0.0-stage → 0.0.20-dev.661.gda3ac9a7e
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/LICENSE +373 -0
- package/NOTICE +66 -0
- package/README.md +46 -2
- package/dist/_virtual/_vite/preload-helper.js +100 -0
- package/dist/brand/brand.d.ts +13 -0
- package/dist/brand/brand.js +14 -0
- package/dist/brand/landing_backdrop.d.ts +56 -0
- package/dist/brand/landing_backdrop.js +1019 -0
- package/dist/brand/wobble_morph.d.ts +54 -0
- package/dist/brand/wobble_morph.js +439 -0
- package/dist/components/action_list.d.ts +31 -0
- package/dist/components/action_list.js +63 -0
- package/dist/components/action_list.module.js +11 -0
- package/dist/components/anchored_overlay.d.ts +28 -0
- package/dist/components/anchored_overlay.js +93 -0
- package/dist/components/button.d.ts +42 -0
- package/dist/components/button.js +97 -0
- package/dist/components/button.module.js +20 -0
- package/dist/components/button_group.d.ts +7 -0
- package/dist/components/button_group.js +18 -0
- package/dist/components/button_group.module.js +3 -0
- package/dist/components/card_placeholder.d.ts +9 -0
- package/dist/components/card_placeholder.js +39 -0
- package/dist/components/card_placeholder.module.js +6 -0
- package/dist/components/clipboard.d.ts +19 -0
- package/dist/components/clipboard.js +54 -0
- package/dist/components/data_table/computation_tables.d.ts +12 -0
- package/dist/components/data_table/computation_tables.js +42 -0
- package/dist/components/data_table/data_table.d.ts +38 -0
- package/dist/components/data_table/data_table.js +378 -0
- package/dist/components/data_table/data_table.module.js +41 -0
- package/dist/components/data_table/data_table_cell.d.ts +7 -0
- package/dist/components/data_table/data_table_cell.js +9 -0
- package/dist/components/data_table/data_table_cell_data.d.ts +21 -0
- package/dist/components/data_table/data_table_cell_data.js +99 -0
- package/dist/components/data_table/data_table_cell_header_name.d.ts +17 -0
- package/dist/components/data_table/data_table_cell_header_name.js +73 -0
- package/dist/components/data_table/data_table_cell_header_plots.d.ts +31 -0
- package/dist/components/data_table/data_table_cell_header_plots.js +122 -0
- package/dist/components/data_table/data_table_colors.d.ts +19 -0
- package/dist/components/data_table/data_table_colors.js +27 -0
- package/dist/components/data_table/data_table_column_resize.d.ts +21 -0
- package/dist/components/data_table/data_table_column_resize.js +121 -0
- package/dist/components/data_table/data_table_focus.d.ts +15 -0
- package/dist/components/data_table/data_table_focus.js +53 -0
- package/dist/components/data_table/data_table_layout.d.ts +18 -0
- package/dist/components/data_table/data_table_layout.js +103 -0
- package/dist/components/data_table/data_table_ordering.d.ts +9 -0
- package/dist/components/data_table/data_table_ordering.js +39 -0
- package/dist/components/data_table/data_table_portals.d.ts +9 -0
- package/dist/components/data_table/data_table_portals.js +29 -0
- package/dist/components/data_table/data_table_sticky_views.d.ts +34 -0
- package/dist/components/data_table/data_table_sticky_views.js +161 -0
- package/dist/components/data_table/data_table_window.d.ts +18 -0
- package/dist/components/data_table/data_table_window.js +118 -0
- package/dist/components/data_table/format_peek.d.ts +2 -0
- package/dist/components/data_table/format_peek.js +17 -0
- package/dist/components/data_table/histogram_bars.d.ts +36 -0
- package/dist/components/data_table/histogram_bars.js +100 -0
- package/dist/components/data_table/histogram_brush.d.ts +23 -0
- package/dist/components/data_table/histogram_brush.js +107 -0
- package/dist/components/data_table/histogram_cell.d.ts +19 -0
- package/dist/components/data_table/histogram_cell.js +325 -0
- package/dist/components/data_table/histogram_cell.module.js +9 -0
- package/dist/components/data_table/histogram_label.d.ts +1 -0
- package/dist/components/data_table/histogram_label.js +7 -0
- package/dist/components/data_table/memo_props.d.ts +1 -0
- package/dist/components/data_table/memo_props.js +17 -0
- package/dist/components/data_table/mostfrequent_cell.d.ts +17 -0
- package/dist/components/data_table/mostfrequent_cell.js +316 -0
- package/dist/components/data_table/mostfrequent_cell.module.js +10 -0
- package/dist/components/data_table/use_cross_filters.d.ts +14 -0
- package/dist/components/data_table/use_cross_filters.js +47 -0
- package/dist/components/deferred.d.ts +11 -0
- package/dist/components/deferred.js +41 -0
- package/dist/components/deferred.module.js +5 -0
- package/dist/components/error_boundary.d.ts +18 -0
- package/dist/components/error_boundary.js +15 -0
- package/dist/components/graph.module.js +15 -0
- package/dist/components/graph_port.d.ts +10 -0
- package/dist/components/graph_port.js +34 -0
- package/dist/components/inspector_overlay.d.ts +32 -0
- package/dist/components/inspector_overlay.js +72 -0
- package/dist/components/inspector_overlay.module.js +18 -0
- package/dist/components/json/json_arrow_symbol.d.ts +4 -0
- package/dist/components/json/json_arrow_symbol.js +25 -0
- package/dist/components/json/json_copy_button.d.ts +11 -0
- package/dist/components/json/json_copy_button.js +61 -0
- package/dist/components/json/json_ellipsis_symbol.d.ts +7 -0
- package/dist/components/json/json_ellipsis_symbol.js +11 -0
- package/dist/components/json/json_item_count.d.ts +5 -0
- package/dist/components/json/json_item_count.js +12 -0
- package/dist/components/json/json_key_name.d.ts +6 -0
- package/dist/components/json/json_key_name.js +40 -0
- package/dist/components/json/json_key_values.d.ts +12 -0
- package/dist/components/json/json_key_values.js +99 -0
- package/dist/components/json/json_literal.d.ts +8 -0
- package/dist/components/json/json_literal.js +140 -0
- package/dist/components/json/json_nested_close.d.ts +11 -0
- package/dist/components/json/json_nested_close.js +31 -0
- package/dist/components/json/json_nested_open.d.ts +18 -0
- package/dist/components/json/json_nested_open.js +150 -0
- package/dist/components/json/json_nested_state.d.ts +14 -0
- package/dist/components/json/json_nested_state.js +28 -0
- package/dist/components/json/json_tool_state.d.ts +18 -0
- package/dist/components/json/json_tool_state.js +46 -0
- package/dist/components/json/json_value.d.ts +10 -0
- package/dist/components/json/json_value.js +46 -0
- package/dist/components/json/json_view.d.ts +14 -0
- package/dist/components/json/json_view.js +37 -0
- package/dist/components/json/json_view.module.js +41 -0
- package/dist/components/json/json_view_state.d.ts +14 -0
- package/dist/components/json/json_view_state.js +32 -0
- package/dist/components/json/unique_key.d.ts +1 -0
- package/dist/components/json/unique_key.js +8 -0
- package/dist/components/keyvalue_list.d.ts +25 -0
- package/dist/components/keyvalue_list.js +106 -0
- package/dist/components/keyvalue_list.module.js +15 -0
- package/dist/components/name_input.d.ts +11 -0
- package/dist/components/name_input.js +51 -0
- package/dist/components/overlay.d.ts +53 -0
- package/dist/components/overlay.js +183 -0
- package/dist/components/overlay.module.js +32 -0
- package/dist/components/panel_resize_handle.d.ts +12 -0
- package/dist/components/panel_resize_handle.js +39 -0
- package/dist/components/portal.d.ts +8 -0
- package/dist/components/portal.js +53 -0
- package/dist/components/progress_bar.d.ts +7 -0
- package/dist/components/progress_bar.js +21 -0
- package/dist/components/progress_bar.module.js +3 -0
- package/dist/components/query_history_viewer.d.ts +33 -0
- package/dist/components/query_history_viewer.js +268 -0
- package/dist/components/query_history_viewer.module.js +7 -0
- package/dist/components/query_profile/engine_profile_view.d.ts +19 -0
- package/dist/components/query_profile/engine_profile_view.js +94 -0
- package/dist/components/query_profile/numeric_limits.d.ts +1 -0
- package/dist/components/query_profile/numeric_limits.js +2 -0
- package/dist/components/query_profile/profile_execution_controller.d.ts +14 -0
- package/dist/components/query_profile/profile_execution_controller.js +56 -0
- package/dist/components/query_profile/profile_fit.d.ts +24 -0
- package/dist/components/query_profile/profile_fit.js +22 -0
- package/dist/components/query_profile/profile_navigation.d.ts +3 -0
- package/dist/components/query_profile/profile_navigation.js +34 -0
- package/dist/components/query_profile/profile_scene.d.ts +64 -0
- package/dist/components/query_profile/profile_scene.js +422 -0
- package/dist/components/query_profile/query_profile_view.d.ts +44 -0
- package/dist/components/query_profile/query_profile_view.js +961 -0
- package/dist/components/query_profile/query_profile_view.module.js +23 -0
- package/dist/components/query_progress/query_profile_overlay.d.ts +7 -0
- package/dist/components/query_progress/query_profile_overlay.js +67 -0
- package/dist/components/query_progress/query_profile_overlay.module.js +6 -0
- package/dist/components/query_progress/query_progress_panel.d.ts +14 -0
- package/dist/components/query_progress/query_progress_panel.js +255 -0
- package/dist/components/query_progress/query_progress_panel.module.js +10 -0
- package/dist/components/query_result/cell_detail_overlay.d.ts +34 -0
- package/dist/components/query_result/cell_detail_overlay.js +277 -0
- package/dist/components/query_result/cell_detail_overlay.module.js +21 -0
- package/dist/components/query_result/query_result_action_menu.d.ts +12 -0
- package/dist/components/query_result/query_result_action_menu.js +62 -0
- package/dist/components/query_result/query_result_action_menu.module.js +2 -0
- package/dist/components/query_result/query_result_details.d.ts +17 -0
- package/dist/components/query_result/query_result_details.js +46 -0
- package/dist/components/query_result/query_result_details.module.js +5 -0
- package/dist/components/query_result/query_result_download_button.d.ts +8 -0
- package/dist/components/query_result/query_result_download_button.js +38 -0
- package/dist/components/query_result/query_result_header.d.ts +21 -0
- package/dist/components/query_result/query_result_header.js +71 -0
- package/dist/components/query_result/query_result_header.module.js +3 -0
- package/dist/components/query_result/query_result_search_controls.d.ts +12 -0
- package/dist/components/query_result/query_result_search_controls.js +141 -0
- package/dist/components/query_result/query_result_search_controls.module.js +7 -0
- package/dist/components/query_result/query_result_toolbar.d.ts +21 -0
- package/dist/components/query_result/query_result_toolbar.js +74 -0
- package/dist/components/query_result/result_table_overlay.d.ts +9 -0
- package/dist/components/query_result/result_table_overlay.js +73 -0
- package/dist/components/query_result/result_table_overlay.module.js +6 -0
- package/dist/components/query_result/use_query_result_search.d.ts +8 -0
- package/dist/components/query_result/use_query_result_search.js +28 -0
- package/dist/components/segmented_control.d.ts +58 -0
- package/dist/components/segmented_control.js +116 -0
- package/dist/components/segmented_control.module.js +17 -0
- package/dist/components/separator.d.ts +21 -0
- package/dist/components/separator.js +79 -0
- package/dist/components/separator.module.js +7 -0
- package/dist/components/size_observer.d.ts +7 -0
- package/dist/components/size_observer.js +57 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +14 -0
- package/dist/components/skeleton.module.js +2 -0
- package/dist/components/spinners.d.ts +8 -0
- package/dist/components/spinners.js +33 -0
- package/dist/components/spinners.module.js +8 -0
- package/dist/components/status_indicator.d.ts +36 -0
- package/dist/components/status_indicator.js +182 -0
- package/dist/components/status_indicator.module.js +3 -0
- package/dist/components/symbol_icon.d.ts +65 -0
- package/dist/components/symbol_icon.js +213 -0
- package/dist/components/tab_header.d.ts +11 -0
- package/dist/components/tab_header.js +55 -0
- package/dist/components/tab_header.module.js +7 -0
- package/dist/components/tag.d.ts +10 -0
- package/dist/components/tag.js +17 -0
- package/dist/components/tag.module.js +4 -0
- package/dist/components/text_field.d.ts +44 -0
- package/dist/components/text_field.js +159 -0
- package/dist/components/text_field.module.js +15 -0
- package/dist/components/text_input.d.ts +25 -0
- package/dist/components/text_input.js +90 -0
- package/dist/components/text_input.module.js +13 -0
- package/dist/components/text_input_action.d.ts +19 -0
- package/dist/components/text_input_action.js +33 -0
- package/dist/components/text_input_action.module.js +2 -0
- package/dist/components/toggle_switch.d.ts +7 -0
- package/dist/components/toggle_switch.js +22 -0
- package/dist/components/toggle_switch.module.js +6 -0
- package/dist/components/tooltip.d.ts +22 -0
- package/dist/components/tooltip.js +139 -0
- package/dist/components/tooltip.module.js +2 -0
- package/dist/components/tree_entry.d.ts +17 -0
- package/dist/components/tree_entry.js +48 -0
- package/dist/components/tree_entry.module.js +9 -0
- package/dist/components/value_list.d.ts +17 -0
- package/dist/components/value_list.js +70 -0
- package/dist/components/value_list.module.js +8 -0
- package/dist/components/vegalite_chart.d.ts +18 -0
- package/dist/components/vegalite_chart.js +151 -0
- package/dist/components/vegalite_chart.module.js +3 -0
- package/dist/components/vegalite_view.d.ts +27 -0
- package/dist/components/vegalite_view.js +248 -0
- package/dist/components/vegalite_view.module.js +5 -0
- package/dist/components/vertical_scroll_shadows.d.ts +14 -0
- package/dist/components/vertical_scroll_shadows.js +55 -0
- package/dist/components/vertical_scroll_shadows.module.js +5 -0
- package/dist/components/vertical_split.d.ts +15 -0
- package/dist/components/vertical_split.js +112 -0
- package/dist/components/vertical_split.module.js +5 -0
- package/dist/components/vertical_tabs.d.ts +36 -0
- package/dist/components/vertical_tabs.js +169 -0
- package/dist/components/vertical_tabs.module.js +23 -0
- package/dist/components/visualization/capped_rows.d.ts +9 -0
- package/dist/components/visualization/capped_rows.js +23 -0
- package/dist/components/visualization/capped_rows.module.js +3 -0
- package/dist/components/visualization/chart_download_button.d.ts +12 -0
- package/dist/components/visualization/chart_download_button.js +41 -0
- package/dist/components/visualization/kpi_view.d.ts +10 -0
- package/dist/components/visualization/kpi_view.js +215 -0
- package/dist/components/visualization/kpi_view.module.js +17 -0
- package/dist/components/visualization/markdown_view.d.ts +17 -0
- package/dist/components/visualization/markdown_view.js +154 -0
- package/dist/components/visualization/markdown_view.module.js +4 -0
- package/dist/components/visualization/result_rows.d.ts +17 -0
- package/dist/components/visualization/result_rows.js +82 -0
- package/dist/components/visualization/vegalite_preview.d.ts +8 -0
- package/dist/components/visualization/vegalite_preview.js +17 -0
- package/dist/components/visualization/vegalite_preview.module.js +2 -0
- package/dist/components/visualization/visualization_dispatch.d.ts +14 -0
- package/dist/components/visualization/visualization_dispatch.js +41 -0
- package/dist/components/visualization/visualization_panel.d.ts +10 -0
- package/dist/components/visualization/visualization_panel.js +37 -0
- package/dist/components/visualization/visualization_panel.module.js +3 -0
- package/dist/dom/anchored_position.d.ts +42 -0
- package/dist/dom/anchored_position.js +255 -0
- package/dist/dom/app_host.d.ts +6 -0
- package/dist/dom/app_host.js +13 -0
- package/dist/dom/calm_frames.d.ts +24 -0
- package/dist/dom/calm_frames.js +96 -0
- package/dist/dom/classnames.d.ts +8 -0
- package/dist/dom/classnames.js +20 -0
- package/dist/dom/download_file.d.ts +1 -0
- package/dist/dom/download_file.js +12 -0
- package/dist/dom/focus.d.ts +29 -0
- package/dist/dom/focus.js +84 -0
- package/dist/dom/graph_edges.d.ts +53 -0
- package/dist/dom/graph_edges.js +450 -0
- package/dist/dom/key_events.d.ts +9 -0
- package/dist/dom/key_events.js +33 -0
- package/dist/dom/media_query.d.ts +2 -0
- package/dist/dom/media_query.js +15 -0
- package/dist/dom/outside_click.d.ts +8 -0
- package/dist/dom/outside_click.js +32 -0
- package/dist/dom/rerender_ref.d.ts +2 -0
- package/dist/dom/rerender_ref.js +11 -0
- package/dist/dom/row_context_menu.d.ts +7 -0
- package/dist/dom/row_context_menu.js +32 -0
- package/dist/dom/scrollbar.d.ts +3 -0
- package/dist/dom/scrollbar.js +23 -0
- package/dist/format/format.d.ts +11 -0
- package/dist/format/format.js +72 -0
- package/dist/format/query_progress_format.d.ts +17 -0
- package/dist/format/query_progress_format.js +69 -0
- package/dist/format/time_format.d.ts +5 -0
- package/dist/format/time_format.js +45 -0
- package/dist/hooks.d.ts +71 -0
- package/dist/hooks.js +302 -0
- package/dist/host.d.ts +10 -0
- package/dist/host.js +12 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.js +6 -0
- package/dist/models/computation_model.d.ts +14 -0
- package/dist/models/computation_model.js +27 -0
- package/dist/models/query_model.d.ts +12 -0
- package/dist/models/query_model.js +27 -0
- package/dist/models/script_model.d.ts +17 -0
- package/dist/models/script_model.js +69 -0
- package/dist/style.css +4226 -0
- package/dist/svg_symbols.d.ts +2 -0
- package/dist/svg_symbols.js +2 -0
- package/dist/symbols.svg +1197 -0
- package/dist/theme/color_scheme.d.ts +4 -0
- package/dist/theme/color_scheme.js +28 -0
- package/dist/theme/xcode_palette.d.ts +22 -0
- package/dist/theme/xcode_palette.js +4 -0
- package/dist/theme/xcode_palettes.js +41 -0
- package/dist/utils/plan_engine.d.ts +2 -0
- package/dist/utils/plan_engine.js +13 -0
- package/dist/vegalite/vegalite_check.d.ts +1 -0
- package/dist/vegalite/vegalite_check.js +7 -0
- package/dist/vegalite/vegalite_crossfilter.d.ts +54 -0
- package/dist/vegalite/vegalite_crossfilter.js +187 -0
- package/dist/vegalite/vegalite_image.d.ts +16 -0
- package/dist/vegalite/vegalite_image.js +28 -0
- package/dist/vegalite/vegalite_loader.d.ts +7 -0
- package/dist/vegalite/vegalite_loader.js +15 -0
- package/dist/vegalite/vegalite_rows.d.ts +3 -0
- package/dist/vegalite/vegalite_rows.js +17 -0
- package/dist/vegalite/vegalite_theme.d.ts +11 -0
- package/dist/vegalite/vegalite_theme.js +125 -0
- package/fonts/InstrumentSans-Bold.ttf +0 -0
- package/fonts/InstrumentSans-Medium.ttf +0 -0
- package/fonts/InstrumentSans-OFL.txt +93 -0
- package/fonts/InstrumentSans-Regular.ttf +0 -0
- package/fonts/InstrumentSans-SemiBold.ttf +0 -0
- package/fonts/JetBrainsMono-Bold.ttf +0 -0
- package/fonts/JetBrainsMono-Medium.ttf +0 -0
- package/fonts/JetBrainsMono-OFL.txt +93 -0
- package/fonts/JetBrainsMono-Regular.ttf +0 -0
- package/fonts/JetBrainsMono-SemiBold.ttf +0 -0
- package/fonts/fonts.css +61 -0
- package/package.json +43 -4
- package/styles/colors.css +110 -0
- package/styles/flavors/dbcom.css +48 -0
- package/styles/tokens.css +192 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { symbol_arrow, symbol_arrow_container } from "./json_view.module.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import symbols from "../../svg_symbols.js";
|
|
5
|
+
function JsonArrowSymbol(props) {
|
|
6
|
+
const style = {
|
|
7
|
+
transform: `rotate(${props.isExpanded ? "0" : "-90"}deg)`,
|
|
8
|
+
transition: "all 0.3s"
|
|
9
|
+
};
|
|
10
|
+
return /* @__PURE__ */ jsx("span", {
|
|
11
|
+
className: symbol_arrow_container,
|
|
12
|
+
"data-expanded": props.isExpanded,
|
|
13
|
+
style: {
|
|
14
|
+
transform: "rotate(0deg)",
|
|
15
|
+
transition: "all 0.3s",
|
|
16
|
+
...style
|
|
17
|
+
},
|
|
18
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
19
|
+
className: symbol_arrow,
|
|
20
|
+
fill: "currentColor",
|
|
21
|
+
children: /* @__PURE__ */ jsx("use", { xlinkHref: `${symbols}#chevron_down_24` })
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export { JsonArrowSymbol };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface SectionElementResult<T extends object, K = string | number> {
|
|
3
|
+
value?: T;
|
|
4
|
+
parentValue?: T;
|
|
5
|
+
keyName?: K;
|
|
6
|
+
keyPath?: K[];
|
|
7
|
+
}
|
|
8
|
+
export interface JsonCopyButtonProps<T extends object> extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'value'>, SectionElementResult<T> {
|
|
9
|
+
expandKey: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function JsonCopyButton<T extends object>(props: JsonCopyButtonProps<T>): React.JSX.Element | null;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { copy_button, copy_button_copied } from "./json_view.module.js";
|
|
2
|
+
import { useJsonViewerState } from "./json_view_state.js";
|
|
3
|
+
import { useToolVisibility } from "./json_tool_state.js";
|
|
4
|
+
import { bigIntToString } from "./json_literal.js";
|
|
5
|
+
import { classNames } from "../../dom/classnames.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import symbols from "../../svg_symbols.js";
|
|
9
|
+
function JsonCopyButton(props) {
|
|
10
|
+
const { keyName, value, parentValue, expandKey, keyPath, ...other } = props;
|
|
11
|
+
const { beforeCopy } = useJsonViewerState();
|
|
12
|
+
const isShowTools = useToolVisibility(expandKey);
|
|
13
|
+
const [copied, setCopied] = React.useState(false);
|
|
14
|
+
if (!isShowTools) return null;
|
|
15
|
+
const click = (event) => {
|
|
16
|
+
event.stopPropagation();
|
|
17
|
+
let copyText;
|
|
18
|
+
if (typeof value === "string") copyText = value;
|
|
19
|
+
else if (typeof value === "number" && value === Infinity) copyText = "Infinity";
|
|
20
|
+
else if (typeof value === "number" && isNaN(value)) copyText = "NaN";
|
|
21
|
+
else if (typeof value === "bigint") copyText = bigIntToString(value);
|
|
22
|
+
else if (value instanceof Date) copyText = value.toLocaleString();
|
|
23
|
+
else copyText = JSON.stringify(value, (_, v) => typeof v === "bigint" ? bigIntToString(v) : v, 2);
|
|
24
|
+
if (beforeCopy) copyText = beforeCopy(copyText, keyName, value, parentValue, expandKey, keyPath);
|
|
25
|
+
setCopied(true);
|
|
26
|
+
(navigator.clipboard || { writeText(text) {
|
|
27
|
+
return new Promise((reslove, reject) => {
|
|
28
|
+
const textarea = document.createElement("textarea");
|
|
29
|
+
textarea.style.position = "absolute";
|
|
30
|
+
textarea.style.opacity = "0";
|
|
31
|
+
textarea.style.left = "-99999999px";
|
|
32
|
+
textarea.value = text;
|
|
33
|
+
document.body.appendChild(textarea);
|
|
34
|
+
textarea.select();
|
|
35
|
+
if (!document.execCommand("copy")) reject();
|
|
36
|
+
else reslove();
|
|
37
|
+
textarea.remove();
|
|
38
|
+
});
|
|
39
|
+
} }).writeText(copyText).then(() => {
|
|
40
|
+
const timer = setTimeout(() => {
|
|
41
|
+
setCopied(false);
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
}, 3e3);
|
|
44
|
+
}).catch((_error) => {});
|
|
45
|
+
};
|
|
46
|
+
const sym = copied ? "clipboard_copied" : "clipboard_copy";
|
|
47
|
+
return /* @__PURE__ */ jsx("button", {
|
|
48
|
+
...other,
|
|
49
|
+
type: "button",
|
|
50
|
+
"aria-label": copied ? "JSON copied" : "Copy JSON value",
|
|
51
|
+
"data-testid": "json-copy-value",
|
|
52
|
+
className: classNames(copy_button, { [copy_button_copied]: copied }),
|
|
53
|
+
onClick: click,
|
|
54
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
55
|
+
viewBox: "0 0 32 36",
|
|
56
|
+
"aria-hidden": "true",
|
|
57
|
+
children: /* @__PURE__ */ jsx("use", { xlinkHref: `${symbols}#${sym}` })
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export { JsonCopyButton };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface EllipsisCompProps<T extends object> {
|
|
3
|
+
value?: T;
|
|
4
|
+
keyName: string | number;
|
|
5
|
+
isExpanded: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function JsonEllipsisSymbol<T extends object>({ isExpanded, value }: EllipsisCompProps<T>): React.JSX.Element | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { symbol_ellipsis } from "./json_view.module.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function JsonEllipsisSymbol({ isExpanded, value }) {
|
|
5
|
+
if (isExpanded || typeof value === "object" && Object.keys(value).length == 0) return null;
|
|
6
|
+
return /* @__PURE__ */ jsx("span", {
|
|
7
|
+
className: symbol_ellipsis,
|
|
8
|
+
children: "..."
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export { JsonEllipsisSymbol };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { item_count } from "./json_view.module.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function JsonItemCount(props) {
|
|
5
|
+
const len = Object.keys(props.value ?? {}).length;
|
|
6
|
+
const children = `${len} item${len === 1 ? "" : "s"}`;
|
|
7
|
+
return /* @__PURE__ */ jsx("span", {
|
|
8
|
+
className: item_count,
|
|
9
|
+
children
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export { JsonItemCount };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { explorer_key, explorer_key_number, object_key_colon, object_key_name_number, object_key_name_string, object_key_quotes } from "./json_view.module.js";
|
|
2
|
+
import { useJsonViewerState } from "./json_view_state.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
function JsonKeyName(props) {
|
|
6
|
+
const { variant } = useJsonViewerState();
|
|
7
|
+
const isNumber = typeof props.keyName === "number";
|
|
8
|
+
if (variant === "explorer") return /* @__PURE__ */ jsx("span", {
|
|
9
|
+
className: isNumber ? explorer_key_number : explorer_key,
|
|
10
|
+
children: props.keyName
|
|
11
|
+
});
|
|
12
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
13
|
+
/* @__PURE__ */ jsx(Quote, {
|
|
14
|
+
isNumber,
|
|
15
|
+
"data-placement": "left"
|
|
16
|
+
}),
|
|
17
|
+
/* @__PURE__ */ jsx("span", {
|
|
18
|
+
className: isNumber ? object_key_name_number : object_key_name_string,
|
|
19
|
+
children: props.keyName
|
|
20
|
+
}),
|
|
21
|
+
/* @__PURE__ */ jsx(Quote, {
|
|
22
|
+
isNumber,
|
|
23
|
+
"data-placement": "right"
|
|
24
|
+
})
|
|
25
|
+
] }), /* @__PURE__ */ jsx(Colon, {})] });
|
|
26
|
+
}
|
|
27
|
+
function Quote(props) {
|
|
28
|
+
if (props.isNumber) return null;
|
|
29
|
+
return /* @__PURE__ */ jsx("span", {
|
|
30
|
+
className: object_key_quotes,
|
|
31
|
+
children: "\""
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function Colon() {
|
|
35
|
+
return /* @__PURE__ */ jsx("span", {
|
|
36
|
+
className: object_key_colon,
|
|
37
|
+
children: ":"
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export { JsonKeyName };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface KeyValuesProps<T extends object> {
|
|
3
|
+
expandKey?: string;
|
|
4
|
+
level: number;
|
|
5
|
+
value: T;
|
|
6
|
+
parentValue?: T;
|
|
7
|
+
keyName?: (string | number);
|
|
8
|
+
keyPath: (string | number)[];
|
|
9
|
+
}
|
|
10
|
+
export declare function JsonKeyValues<T extends object>(props: KeyValuesProps<T>): React.JSX.Element | null;
|
|
11
|
+
export declare function KeyValuesItem<T extends object>(props: KeyValuesProps<T>): React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { object_entries_line } from "./json_view.module.js";
|
|
2
|
+
import { expandedInitially, useJsonViewerState } from "./json_view_state.js";
|
|
3
|
+
import { useNestedExpansionState } from "./json_nested_state.js";
|
|
4
|
+
import { useToolVisibilityDispatch } from "./json_tool_state.js";
|
|
5
|
+
import { JsonLiteral } from "./json_literal.js";
|
|
6
|
+
import { JsonKeyName } from "./json_key_name.js";
|
|
7
|
+
import { JsonValue } from "./json_value.js";
|
|
8
|
+
import { JsonCopyButton } from "./json_copy_button.js";
|
|
9
|
+
import { useUniqueKey } from "./unique_key.js";
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
function JsonKeyValues(props) {
|
|
13
|
+
const value = props.value ?? {};
|
|
14
|
+
const { expandKey = "", level, keyPath = [] } = props;
|
|
15
|
+
const { arrayPageSize, collapsed } = useJsonViewerState();
|
|
16
|
+
const [arrayPage, setArrayPage] = React.useState({
|
|
17
|
+
value,
|
|
18
|
+
itemCount: arrayPageSize
|
|
19
|
+
});
|
|
20
|
+
if (!(useNestedExpansionState()[expandKey] ?? expandedInitially(collapsed, level))) return null;
|
|
21
|
+
const isMyArray = Array.isArray(value);
|
|
22
|
+
let entries = isMyArray ? Object.entries(value).map((m) => [Number(m[0]), m[1]]) : Object.entries(value);
|
|
23
|
+
const visibleItemCount = arrayPage.value === value ? arrayPage.itemCount : arrayPageSize;
|
|
24
|
+
const hiddenItemCount = isMyArray && arrayPageSize > 0 ? Math.max(0, entries.length - visibleItemCount) : 0;
|
|
25
|
+
if (hiddenItemCount > 0) entries = entries.slice(0, visibleItemCount);
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
27
|
+
className: "w-rjv-wrap",
|
|
28
|
+
style: {
|
|
29
|
+
borderLeft: "var(--w-rjv-border-left-width, 1px) var(--w-rjv-line-style, solid) var(--w-rjv-line-color, #ebebeb)",
|
|
30
|
+
paddingLeft: 15,
|
|
31
|
+
marginLeft: 6
|
|
32
|
+
},
|
|
33
|
+
children: [entries.map(([key, val], idx) => {
|
|
34
|
+
return /* @__PURE__ */ jsx(KeyValuesItem, {
|
|
35
|
+
parentValue: value,
|
|
36
|
+
keyName: key,
|
|
37
|
+
keyPath: [...keyPath, key],
|
|
38
|
+
value: val,
|
|
39
|
+
level
|
|
40
|
+
}, idx);
|
|
41
|
+
}), hiddenItemCount > 0 && /* @__PURE__ */ jsxs("button", {
|
|
42
|
+
type: "button",
|
|
43
|
+
className: "dashql_array_load_more_SEHnAA",
|
|
44
|
+
"data-testid": "json-array-load-more",
|
|
45
|
+
onClick: () => setArrayPage({
|
|
46
|
+
value,
|
|
47
|
+
itemCount: visibleItemCount + arrayPageSize
|
|
48
|
+
}),
|
|
49
|
+
children: [
|
|
50
|
+
"Show ",
|
|
51
|
+
Math.min(arrayPageSize, hiddenItemCount),
|
|
52
|
+
" more (",
|
|
53
|
+
hiddenItemCount,
|
|
54
|
+
" remaining)"
|
|
55
|
+
]
|
|
56
|
+
})]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function KeyValuesItem(props) {
|
|
60
|
+
const dispatch = useToolVisibilityDispatch();
|
|
61
|
+
const subkeyid = useUniqueKey();
|
|
62
|
+
const isMyArray = Array.isArray(props.value);
|
|
63
|
+
const isMySet = props.value instanceof Set;
|
|
64
|
+
const isMyMap = props.value instanceof Map;
|
|
65
|
+
const isDate = props.value instanceof Date;
|
|
66
|
+
const isUrl = props.value instanceof URL;
|
|
67
|
+
if (props.value && typeof props.value === "object" && !isMyArray && !isMySet && !isMyMap && !isDate && !isUrl || isMyArray || isMySet || isMyMap) {
|
|
68
|
+
const mappedValue = isMySet ? Array.from(props.value) : isMyMap ? Object.fromEntries(props.value) : props.value;
|
|
69
|
+
return /* @__PURE__ */ jsx(JsonValue, {
|
|
70
|
+
keyName: props.keyName,
|
|
71
|
+
keyPath: props.keyPath,
|
|
72
|
+
value: mappedValue,
|
|
73
|
+
parentValue: props.parentValue,
|
|
74
|
+
initialValue: props.value,
|
|
75
|
+
level: props.level + 1
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
79
|
+
className: object_entries_line,
|
|
80
|
+
"data-testid": "json-entry-line",
|
|
81
|
+
onMouseEnter: () => dispatch({ [subkeyid]: true }),
|
|
82
|
+
onMouseLeave: () => dispatch({ [subkeyid]: false }),
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ jsx(JsonKeyName, {
|
|
85
|
+
keyName: props.keyName,
|
|
86
|
+
keyPath: props.keyPath
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ jsx(JsonLiteral, { value: props.value }),
|
|
89
|
+
/* @__PURE__ */ jsx(JsonCopyButton, {
|
|
90
|
+
keyName: props.keyName,
|
|
91
|
+
keyPath: props.keyPath,
|
|
92
|
+
value: props.value,
|
|
93
|
+
parentValue: props.parentValue,
|
|
94
|
+
expandKey: subkeyid
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export { JsonKeyValues, KeyValuesItem };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function isFloat(n: number): boolean;
|
|
3
|
+
interface ValueProps {
|
|
4
|
+
value: unknown;
|
|
5
|
+
}
|
|
6
|
+
export declare function JsonLiteral(props: ValueProps): React.JSX.Element | null;
|
|
7
|
+
export declare function bigIntToString(bi?: bigint | string): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { explorer_placeholder, literal_bigint, literal_date, literal_false, literal_float, literal_int, literal_nan, literal_null, literal_quotes, literal_string, literal_string_short, literal_true, literal_undefined, literal_url } from "./json_view.module.js";
|
|
2
|
+
import { useJsonViewerState } from "./json_view_state.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
function isFloat(n) {
|
|
6
|
+
return Number(n) === n && n % 1 !== 0 || isNaN(n);
|
|
7
|
+
}
|
|
8
|
+
function JsonLiteral(props) {
|
|
9
|
+
const { value } = props;
|
|
10
|
+
if (value instanceof URL) return /* @__PURE__ */ jsx(UrlLiteral, { children: value });
|
|
11
|
+
if (typeof value === "string") return /* @__PURE__ */ jsx(StringLiteral, { children: value });
|
|
12
|
+
if (value === true) return /* @__PURE__ */ jsx(TrueLiteral, {});
|
|
13
|
+
if (value === false) return /* @__PURE__ */ jsx(FalseLiteral, {});
|
|
14
|
+
if (value === null) return /* @__PURE__ */ jsx(NullLiteral, {});
|
|
15
|
+
if (value === void 0) return /* @__PURE__ */ jsx(UndefinedLiteral, {});
|
|
16
|
+
if (value instanceof Date) return /* @__PURE__ */ jsx(DateLiteral, { children: value });
|
|
17
|
+
if (typeof value === "number" && isNaN(value)) return /* @__PURE__ */ jsx(NanLiteral, {});
|
|
18
|
+
else if (typeof value === "number" && isFloat(value)) return /* @__PURE__ */ jsx(FloatLiteral, { children: value });
|
|
19
|
+
else if (typeof value === "bigint") return /* @__PURE__ */ jsx(BigintLiteral, { children: value });
|
|
20
|
+
else if (typeof value === "number") return /* @__PURE__ */ jsx(IntLiteral, { children: value });
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function bigIntToString(bi) {
|
|
24
|
+
if (bi === void 0) return "0n";
|
|
25
|
+
else if (typeof bi === "string") try {
|
|
26
|
+
bi = BigInt(bi);
|
|
27
|
+
} catch {
|
|
28
|
+
return "0n";
|
|
29
|
+
}
|
|
30
|
+
return bi ? bi.toString() + "n" : "0n";
|
|
31
|
+
}
|
|
32
|
+
function StringLiteral(props) {
|
|
33
|
+
const { variant, shortenTextAfterLength: length } = useJsonViewerState();
|
|
34
|
+
const childrenStr = props.children;
|
|
35
|
+
const [shorten, setShorten] = React.useState(length && childrenStr.length > length);
|
|
36
|
+
React.useEffect(() => setShorten(length && childrenStr.length > length), [length, childrenStr.length]);
|
|
37
|
+
const style = length > 0 ? { cursor: childrenStr.length <= length ? "initial" : "pointer" } : {};
|
|
38
|
+
const onClick = length > 0 && childrenStr.length > length ? () => setShorten(!shorten) : void 0;
|
|
39
|
+
const text = shorten ? `${childrenStr.slice(0, length)}...` : childrenStr;
|
|
40
|
+
const cls = shorten ? literal_string_short : literal_string;
|
|
41
|
+
if (variant === "explorer") {
|
|
42
|
+
if (childrenStr.length === 0) return /* @__PURE__ */ jsx("span", {
|
|
43
|
+
className: explorer_placeholder,
|
|
44
|
+
children: "empty"
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ jsx("span", {
|
|
47
|
+
className: cls,
|
|
48
|
+
style,
|
|
49
|
+
onClick,
|
|
50
|
+
children: text
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
54
|
+
/* @__PURE__ */ jsx(LiteralQuotes, {}),
|
|
55
|
+
/* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: cls,
|
|
57
|
+
style,
|
|
58
|
+
onClick,
|
|
59
|
+
children: text
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ jsx(LiteralQuotes, {})
|
|
62
|
+
] });
|
|
63
|
+
}
|
|
64
|
+
function LiteralQuotes() {
|
|
65
|
+
const { variant } = useJsonViewerState();
|
|
66
|
+
if (variant === "explorer") return null;
|
|
67
|
+
return /* @__PURE__ */ jsx("span", {
|
|
68
|
+
className: literal_quotes,
|
|
69
|
+
children: "\""
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function TrueLiteral() {
|
|
73
|
+
return /* @__PURE__ */ jsx("span", {
|
|
74
|
+
className: literal_true,
|
|
75
|
+
children: true.toString()
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function FalseLiteral() {
|
|
79
|
+
return /* @__PURE__ */ jsx("span", {
|
|
80
|
+
className: literal_false,
|
|
81
|
+
children: false.toString()
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function FloatLiteral(props) {
|
|
85
|
+
return /* @__PURE__ */ jsx("span", {
|
|
86
|
+
className: literal_float,
|
|
87
|
+
children: props.children.toString()
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function IntLiteral(props) {
|
|
91
|
+
return /* @__PURE__ */ jsx("span", {
|
|
92
|
+
className: literal_int,
|
|
93
|
+
children: props.children.toString()
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function BigintLiteral(props) {
|
|
97
|
+
return /* @__PURE__ */ jsx("span", {
|
|
98
|
+
className: literal_bigint,
|
|
99
|
+
children: bigIntToString(props.children.toString())
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function UrlLiteral(props) {
|
|
103
|
+
return /* @__PURE__ */ jsxs("a", {
|
|
104
|
+
className: literal_url,
|
|
105
|
+
href: props.children?.href,
|
|
106
|
+
target: "_blank",
|
|
107
|
+
rel: "noopener noreferrer",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsx(LiteralQuotes, {}),
|
|
110
|
+
props.children?.href,
|
|
111
|
+
/* @__PURE__ */ jsx(LiteralQuotes, {})
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function DateLiteral(props) {
|
|
116
|
+
const childStr = props.children instanceof Date ? props.children.toLocaleString() : props.children;
|
|
117
|
+
return /* @__PURE__ */ jsx("span", {
|
|
118
|
+
className: literal_date,
|
|
119
|
+
children: childStr
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function UndefinedLiteral() {
|
|
123
|
+
return /* @__PURE__ */ jsx("span", {
|
|
124
|
+
className: literal_undefined,
|
|
125
|
+
children: "undefined"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function NullLiteral() {
|
|
129
|
+
return /* @__PURE__ */ jsx("span", {
|
|
130
|
+
className: literal_null,
|
|
131
|
+
children: "null"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function NanLiteral() {
|
|
135
|
+
return /* @__PURE__ */ jsx("span", {
|
|
136
|
+
className: literal_nan,
|
|
137
|
+
children: "nan"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
export { JsonLiteral, bigIntToString, isFloat };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface JsonNestedCloseProps {
|
|
3
|
+
expandKey: string;
|
|
4
|
+
level: number;
|
|
5
|
+
parentValue?: object;
|
|
6
|
+
value: object;
|
|
7
|
+
keyName?: (string | number);
|
|
8
|
+
keyPath: (string | number)[];
|
|
9
|
+
}
|
|
10
|
+
export declare function JsonNestedClose(props: JsonNestedCloseProps): React.JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { object_close } from "./json_view.module.js";
|
|
2
|
+
import { expandedInitially, useJsonViewerState } from "./json_view_state.js";
|
|
3
|
+
import { useNestedExpansionState } from "./json_nested_state.js";
|
|
4
|
+
import { JsonBracketsClose } from "./json_nested_open.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function JsonNestedClose(props) {
|
|
8
|
+
const expands = useNestedExpansionState();
|
|
9
|
+
const { variant, collapsed } = useJsonViewerState();
|
|
10
|
+
const isExpanded = expands[props.expandKey] ?? expandedInitially(collapsed, props.level);
|
|
11
|
+
if (variant === "explorer") return null;
|
|
12
|
+
const len = Object.keys(props.value).length;
|
|
13
|
+
if (!isExpanded || len === 0) return null;
|
|
14
|
+
const compProps = {
|
|
15
|
+
keyName: props.keyName,
|
|
16
|
+
keyPath: props.keyPath,
|
|
17
|
+
value: props.value,
|
|
18
|
+
parentValue: props.parentValue
|
|
19
|
+
};
|
|
20
|
+
const isArray = Array.isArray(props.value);
|
|
21
|
+
const isMySet = props.value instanceof Set;
|
|
22
|
+
return /* @__PURE__ */ jsx("div", {
|
|
23
|
+
className: object_close,
|
|
24
|
+
children: /* @__PURE__ */ jsx(JsonBracketsClose, {
|
|
25
|
+
isBrackets: isArray || isMySet,
|
|
26
|
+
...compProps,
|
|
27
|
+
isVisible: true
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { JsonNestedClose };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface NestedOpenProps {
|
|
3
|
+
expandKey: string;
|
|
4
|
+
keyName?: (string | number);
|
|
5
|
+
keyPath: (string | number)[];
|
|
6
|
+
level: number;
|
|
7
|
+
value: object;
|
|
8
|
+
initialValue: object;
|
|
9
|
+
parentValue?: object;
|
|
10
|
+
}
|
|
11
|
+
export declare function JsonNestedOpen(props: NestedOpenProps): React.JSX.Element;
|
|
12
|
+
export declare function JsonBracketsOpen(props: {
|
|
13
|
+
isBrackets: boolean;
|
|
14
|
+
}): React.JSX.Element;
|
|
15
|
+
export declare function JsonBracketsClose(props: {
|
|
16
|
+
isBrackets: boolean;
|
|
17
|
+
isVisible: boolean;
|
|
18
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { expand_button, explorer_arrow_spacer, explorer_placeholder, explorer_row, explorer_summary, object_curly_brackets_close, object_curly_brackets_open, object_header_set, object_square_brackets_open } from "./json_view.module.js";
|
|
2
|
+
import { useNestedExpansionDispatch, useNestedExpansionState } from "./json_nested_state.js";
|
|
3
|
+
import { expandedInitially, useJsonViewerState } from "./json_view_state.js";
|
|
4
|
+
import { JsonCopyButton } from "./json_copy_button.js";
|
|
5
|
+
import { JsonItemCount } from "./json_item_count.js";
|
|
6
|
+
import { JsonArrowSymbol } from "./json_arrow_symbol.js";
|
|
7
|
+
import { JsonEllipsisSymbol } from "./json_ellipsis_symbol.js";
|
|
8
|
+
import { JsonKeyName } from "./json_key_name.js";
|
|
9
|
+
import "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
function JsonNestedOpen(props) {
|
|
12
|
+
const nodeExpansions = useNestedExpansionState();
|
|
13
|
+
const dispatchExpands = useNestedExpansionDispatch();
|
|
14
|
+
const { variant, collapsed } = useJsonViewerState();
|
|
15
|
+
const isExpanded = nodeExpansions[props.expandKey] ?? expandedInitially(collapsed, props.level);
|
|
16
|
+
const click = () => dispatchExpands({ [props.expandKey]: !isExpanded });
|
|
17
|
+
const style = {
|
|
18
|
+
display: "inline-flex",
|
|
19
|
+
alignItems: "center"
|
|
20
|
+
};
|
|
21
|
+
const len = Object.keys(props.value ?? {}).length;
|
|
22
|
+
const isObject = typeof props.value === "object";
|
|
23
|
+
const isArray = Array.isArray(props.value);
|
|
24
|
+
const isMySet = props.value instanceof Set;
|
|
25
|
+
const showArrow = len !== 0 && (isArray || isMySet || isObject);
|
|
26
|
+
const childProps = {
|
|
27
|
+
keyName: props.keyName,
|
|
28
|
+
keyPath: props.keyPath,
|
|
29
|
+
value: props.value,
|
|
30
|
+
parentValue: props.parentValue
|
|
31
|
+
};
|
|
32
|
+
if (variant === "explorer") return /* @__PURE__ */ jsxs("div", {
|
|
33
|
+
className: explorer_row,
|
|
34
|
+
onClick: showArrow ? click : void 0,
|
|
35
|
+
children: [
|
|
36
|
+
showArrow ? /* @__PURE__ */ jsx("button", {
|
|
37
|
+
type: "button",
|
|
38
|
+
className: expand_button,
|
|
39
|
+
"aria-label": isExpanded ? "Collapse value" : "Expand value",
|
|
40
|
+
"aria-expanded": isExpanded,
|
|
41
|
+
onClick: (e) => {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
click();
|
|
44
|
+
},
|
|
45
|
+
children: /* @__PURE__ */ jsx(JsonArrowSymbol, { isExpanded })
|
|
46
|
+
}) : /* @__PURE__ */ jsx("span", { className: explorer_arrow_spacer }),
|
|
47
|
+
(props.keyName || typeof props.keyName === "number") && /* @__PURE__ */ jsx(JsonKeyName, { ...childProps }),
|
|
48
|
+
/* @__PURE__ */ jsx(ExplorerSummary, {
|
|
49
|
+
value: props.value,
|
|
50
|
+
initialValue: props.initialValue
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx(JsonCopyButton, {
|
|
53
|
+
keyName: props.keyName,
|
|
54
|
+
value: props.value,
|
|
55
|
+
expandKey: props.expandKey,
|
|
56
|
+
parentValue: props.parentValue,
|
|
57
|
+
keyPath: props.keyPath
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
62
|
+
style,
|
|
63
|
+
children: [
|
|
64
|
+
showArrow && /* @__PURE__ */ jsx("button", {
|
|
65
|
+
type: "button",
|
|
66
|
+
className: "dashql_expand_button_KeYcWC",
|
|
67
|
+
"aria-label": isExpanded ? "Collapse JSON value" : "Expand JSON value",
|
|
68
|
+
"aria-expanded": isExpanded,
|
|
69
|
+
onClick: click,
|
|
70
|
+
children: /* @__PURE__ */ jsx(JsonArrowSymbol, { isExpanded })
|
|
71
|
+
}),
|
|
72
|
+
(props.keyName || typeof props.keyName === "number") && /* @__PURE__ */ jsx(JsonKeyName, { ...childProps }),
|
|
73
|
+
/* @__PURE__ */ jsx(SetHeader, { value: props.initialValue }),
|
|
74
|
+
/* @__PURE__ */ jsx(MapHeader, { value: props.initialValue }),
|
|
75
|
+
/* @__PURE__ */ jsx(JsonBracketsOpen, { isBrackets: isArray || isMySet }),
|
|
76
|
+
/* @__PURE__ */ jsx(JsonEllipsisSymbol, {
|
|
77
|
+
keyName: props.keyName,
|
|
78
|
+
value: props.value,
|
|
79
|
+
isExpanded
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ jsx(JsonBracketsClose, {
|
|
82
|
+
isVisible: !isExpanded || !showArrow,
|
|
83
|
+
isBrackets: isArray || isMySet
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx(JsonItemCount, { value: props.value }),
|
|
86
|
+
/* @__PURE__ */ jsx(JsonCopyButton, {
|
|
87
|
+
keyName: props.keyName,
|
|
88
|
+
value: props.value,
|
|
89
|
+
expandKey: props.expandKey,
|
|
90
|
+
parentValue: props.parentValue,
|
|
91
|
+
keyPath: props.keyPath
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function ExplorerSummary(props) {
|
|
97
|
+
const len = Object.keys(props.value ?? {}).length;
|
|
98
|
+
if (len === 0) return /* @__PURE__ */ jsx("span", {
|
|
99
|
+
className: explorer_placeholder,
|
|
100
|
+
children: "empty"
|
|
101
|
+
});
|
|
102
|
+
let noun;
|
|
103
|
+
if (props.initialValue instanceof Map) noun = len === 1 ? "entry" : "entries";
|
|
104
|
+
else if (Array.isArray(props.value) || props.initialValue instanceof Set) noun = len === 1 ? "item" : "items";
|
|
105
|
+
else noun = len === 1 ? "field" : "fields";
|
|
106
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
107
|
+
className: explorer_summary,
|
|
108
|
+
children: [
|
|
109
|
+
len,
|
|
110
|
+
" ",
|
|
111
|
+
noun
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function SetHeader(props) {
|
|
116
|
+
if (!(props.value instanceof Set)) return null;
|
|
117
|
+
return /* @__PURE__ */ jsx("span", {
|
|
118
|
+
className: object_header_set,
|
|
119
|
+
"data-type": "set",
|
|
120
|
+
children: "Set"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function MapHeader(props) {
|
|
124
|
+
if (!(props.value instanceof Map)) return null;
|
|
125
|
+
return /* @__PURE__ */ jsx("span", {
|
|
126
|
+
className: object_header_set,
|
|
127
|
+
"data-type": "map",
|
|
128
|
+
children: "Map"
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function JsonBracketsOpen(props) {
|
|
132
|
+
return props.isBrackets ? /* @__PURE__ */ jsx("span", {
|
|
133
|
+
className: object_square_brackets_open,
|
|
134
|
+
children: "["
|
|
135
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
136
|
+
className: object_curly_brackets_open,
|
|
137
|
+
children: "{"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function JsonBracketsClose(props) {
|
|
141
|
+
if (!props.isVisible) return null;
|
|
142
|
+
return props.isBrackets ? /* @__PURE__ */ jsx("span", {
|
|
143
|
+
className: object_curly_brackets_open,
|
|
144
|
+
children: "]"
|
|
145
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
146
|
+
className: object_curly_brackets_close,
|
|
147
|
+
children: "}"
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
export { JsonBracketsClose, JsonBracketsOpen, JsonNestedOpen };
|