@perses-dev/components 0.54.0-beta.1 → 0.54.0-beta.2
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/AlignSelector/AlignSelector.js +1 -1
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +1 -1
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +1 -1
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +1 -1
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +1 -1
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/FormEditor/FormActions.js +1 -1
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.js +1 -1
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/JSONEditor.js +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +1 -1
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +1 -1
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +1 -1
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +1 -1
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +18 -4
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +1 -1
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +1 -1
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +1 -1
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +1 -1
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +25 -12
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +1 -1
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +1 -1
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +1 -1
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +20 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +56 -24
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +13 -1
- package/dist/Table/TableToolbar.d.ts.map +1 -1
- package/dist/Table/TableToolbar.js +15 -4
- package/dist/Table/TableToolbar.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +6 -4
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +151 -128
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +1 -1
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +5 -3
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.js +32 -13
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +42 -2
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +37 -19
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +25 -2
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeZoneSelector.js +1 -1
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +1 -1
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAxisLabel.js +1 -1
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/cjs/Legend/TableLegend.js +16 -2
- package/dist/cjs/Table/Table.js +24 -11
- package/dist/cjs/Table/TableHeaderCell.js +54 -22
- package/dist/cjs/Table/TableToolbar.js +13 -2
- package/dist/cjs/Table/VirtualizedTable.js +150 -127
- package/dist/cjs/Table/hooks/useFuzzySearch.js +30 -11
- package/dist/cjs/Table/model/table-model.js +43 -19
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +23 -0
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/value-mapping.js +16 -0
- package/dist/cjs/theme/typography.js +1 -1
- package/dist/cjs/utils/format.js +20 -0
- package/dist/context/ChartsProvider.js +1 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +1 -1
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +1 -1
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +1 -1
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/value-mapping.d.ts +35 -0
- package/dist/model/value-mapping.d.ts.map +1 -0
- package/dist/model/value-mapping.js +15 -0
- package/dist/model/value-mapping.js.map +1 -0
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/theme/typography.js +1 -1
- package/dist/theme/typography.js.map +1 -1
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +17 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/request-interpolation.d.ts +1 -1
- package/dist/utils/request-interpolation.d.ts.map +1 -1
- package/dist/utils/request-interpolation.js.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/ItemActionsProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, ReactNode, useCallback, useContext, useMemo, useState } from 'react';\n\nexport interface ItemActionStatus {\n loading: boolean;\n error?: Error;\n success?: boolean;\n}\n\nexport interface ActionStatus {\n loading: boolean;\n error?: Error;\n success?: boolean;\n itemStatuses?: Map<unknown, ItemActionStatus>;\n}\n\nexport interface ActionState<Id = unknown> {\n actionStatuses: Map<string, ActionStatus>;\n setActionStatus: (actionName: string, status: Partial<ActionStatus>, itemId?: Id) => void;\n clearActionStatus: (actionName?: string) => void;\n}\n\nexport interface ItemActionsProviderProps {\n children: ReactNode;\n}\n\nconst ItemActionsContext = createContext<ActionState<unknown> | undefined>(undefined);\n\nexport function ItemActionsProvider({ children }: ItemActionsProviderProps): ReactElement {\n const [actionStatuses, setActionStatuses] = useState(new Map<string, ActionStatus>());\n\n const setActionStatus = useCallback((actionName: string, status: Partial<ActionStatus>, itemId?: unknown) => {\n setActionStatuses((prev) => {\n const newMap = new Map(prev);\n const existingStatus = newMap.get(actionName) || { loading: false };\n\n if (itemId !== undefined) {\n // Update item-level status for individual actions\n const itemStatuses = new Map(existingStatus.itemStatuses || new Map());\n const existingItemStatus = itemStatuses.get(itemId) || { loading: false };\n itemStatuses.set(itemId, { ...existingItemStatus, ...status } as ItemActionStatus);\n newMap.set(actionName, { ...existingStatus, itemStatuses });\n } else {\n // Update action-level status for batch actions\n newMap.set(actionName, { ...existingStatus, ...status });\n }\n\n return newMap;\n });\n }, []);\n\n const clearActionStatus = useCallback((actionName?: string) => {\n setActionStatuses((prev) => {\n if (actionName === undefined) {\n return new Map();\n }\n if (!prev.has(actionName)) return prev;\n const newMap = new Map(prev);\n newMap.delete(actionName);\n return newMap;\n });\n }, []);\n\n const ctx = useMemo<ActionState<unknown>>(\n () => ({\n actionStatuses,\n setActionStatus,\n clearActionStatus,\n }),\n [actionStatuses, setActionStatus, clearActionStatus]\n );\n\n return <ItemActionsContext.Provider value={ctx}>{children}</ItemActionsContext.Provider>;\n}\n\nconst noOp = (): void => {};\nconst emptyActionStatuses = new Map<string, ActionStatus>();\nconst defaultState: ActionState<unknown> & { hasContext: false } = {\n actionStatuses: emptyActionStatuses,\n setActionStatus: noOp,\n clearActionStatus: noOp,\n hasContext: false,\n};\n\nexport function useItemActions<Id = string | number>(): ActionState<Id> & { hasContext: boolean } {\n const ctx = useContext(ItemActionsContext);\n\n const memoizedResult = useMemo(() => {\n if (!ctx) return defaultState as ActionState<Id> & { hasContext: false };\n\n return { ...ctx, hasContext: true } as ActionState<Id> & { hasContext: true };\n }, [ctx]);\n\n return memoizedResult;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useState","ItemActionsContext","undefined","ItemActionsProvider","children","actionStatuses","setActionStatuses","Map","setActionStatus","actionName","status","itemId","prev","newMap","existingStatus","get","loading","itemStatuses","existingItemStatus","set","clearActionStatus","has","delete","ctx","Provider","value","noOp","emptyActionStatuses","defaultState","hasContext","useItemActions","memoizedResult"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"sources":["../../src/context/ItemActionsProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, ReactNode, useCallback, useContext, useMemo, useState } from 'react';\n\nexport interface ItemActionStatus {\n loading: boolean;\n error?: Error;\n success?: boolean;\n}\n\nexport interface ActionStatus {\n loading: boolean;\n error?: Error;\n success?: boolean;\n itemStatuses?: Map<unknown, ItemActionStatus>;\n}\n\nexport interface ActionState<Id = unknown> {\n actionStatuses: Map<string, ActionStatus>;\n setActionStatus: (actionName: string, status: Partial<ActionStatus>, itemId?: Id) => void;\n clearActionStatus: (actionName?: string) => void;\n}\n\nexport interface ItemActionsProviderProps {\n children: ReactNode;\n}\n\nconst ItemActionsContext = createContext<ActionState<unknown> | undefined>(undefined);\n\nexport function ItemActionsProvider({ children }: ItemActionsProviderProps): ReactElement {\n const [actionStatuses, setActionStatuses] = useState(new Map<string, ActionStatus>());\n\n const setActionStatus = useCallback((actionName: string, status: Partial<ActionStatus>, itemId?: unknown) => {\n setActionStatuses((prev) => {\n const newMap = new Map(prev);\n const existingStatus = newMap.get(actionName) || { loading: false };\n\n if (itemId !== undefined) {\n // Update item-level status for individual actions\n const itemStatuses = new Map(existingStatus.itemStatuses || new Map());\n const existingItemStatus = itemStatuses.get(itemId) || { loading: false };\n itemStatuses.set(itemId, { ...existingItemStatus, ...status } as ItemActionStatus);\n newMap.set(actionName, { ...existingStatus, itemStatuses });\n } else {\n // Update action-level status for batch actions\n newMap.set(actionName, { ...existingStatus, ...status });\n }\n\n return newMap;\n });\n }, []);\n\n const clearActionStatus = useCallback((actionName?: string) => {\n setActionStatuses((prev) => {\n if (actionName === undefined) {\n return new Map();\n }\n if (!prev.has(actionName)) return prev;\n const newMap = new Map(prev);\n newMap.delete(actionName);\n return newMap;\n });\n }, []);\n\n const ctx = useMemo<ActionState<unknown>>(\n () => ({\n actionStatuses,\n setActionStatus,\n clearActionStatus,\n }),\n [actionStatuses, setActionStatus, clearActionStatus]\n );\n\n return <ItemActionsContext.Provider value={ctx}>{children}</ItemActionsContext.Provider>;\n}\n\nconst noOp = (): void => {};\nconst emptyActionStatuses = new Map<string, ActionStatus>();\nconst defaultState: ActionState<unknown> & { hasContext: false } = {\n actionStatuses: emptyActionStatuses,\n setActionStatus: noOp,\n clearActionStatus: noOp,\n hasContext: false,\n};\n\nexport function useItemActions<Id = string | number>(): ActionState<Id> & { hasContext: boolean } {\n const ctx = useContext(ItemActionsContext);\n\n const memoizedResult = useMemo(() => {\n if (!ctx) return defaultState as ActionState<Id> & { hasContext: false };\n\n return { ...ctx, hasContext: true } as ActionState<Id> & { hasContext: true };\n }, [ctx]);\n\n return memoizedResult;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useState","ItemActionsContext","undefined","ItemActionsProvider","children","actionStatuses","setActionStatuses","Map","setActionStatus","actionName","status","itemId","prev","newMap","existingStatus","get","loading","itemStatuses","existingItemStatus","set","clearActionStatus","has","delete","ctx","Provider","value","noOp","emptyActionStatuses","defaultState","hasContext","useItemActions","memoizedResult"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,aAAa,EAA2BC,WAAW,EAAEC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAyB3G,MAAMC,mCAAqBL,cAAgDM;AAE3E,OAAO,SAASC,oBAAoB,EAAEC,QAAQ,EAA4B;IACxE,MAAM,CAACC,gBAAgBC,kBAAkB,GAAGN,SAAS,IAAIO;IAEzD,MAAMC,kBAAkBX,YAAY,CAACY,YAAoBC,QAA+BC;QACtFL,kBAAkB,CAACM;YACjB,MAAMC,SAAS,IAAIN,IAAIK;YACvB,MAAME,iBAAiBD,OAAOE,GAAG,CAACN,eAAe;gBAAEO,SAAS;YAAM;YAElE,IAAIL,WAAWT,WAAW;gBACxB,kDAAkD;gBAClD,MAAMe,eAAe,IAAIV,IAAIO,eAAeG,YAAY,IAAI,IAAIV;gBAChE,MAAMW,qBAAqBD,aAAaF,GAAG,CAACJ,WAAW;oBAAEK,SAAS;gBAAM;gBACxEC,aAAaE,GAAG,CAACR,QAAQ;oBAAE,GAAGO,kBAAkB;oBAAE,GAAGR,MAAM;gBAAC;gBAC5DG,OAAOM,GAAG,CAACV,YAAY;oBAAE,GAAGK,cAAc;oBAAEG;gBAAa;YAC3D,OAAO;gBACL,+CAA+C;gBAC/CJ,OAAOM,GAAG,CAACV,YAAY;oBAAE,GAAGK,cAAc;oBAAE,GAAGJ,MAAM;gBAAC;YACxD;YAEA,OAAOG;QACT;IACF,GAAG,EAAE;IAEL,MAAMO,oBAAoBvB,YAAY,CAACY;QACrCH,kBAAkB,CAACM;YACjB,IAAIH,eAAeP,WAAW;gBAC5B,OAAO,IAAIK;YACb;YACA,IAAI,CAACK,KAAKS,GAAG,CAACZ,aAAa,OAAOG;YAClC,MAAMC,SAAS,IAAIN,IAAIK;YACvBC,OAAOS,MAAM,CAACb;YACd,OAAOI;QACT;IACF,GAAG,EAAE;IAEL,MAAMU,MAAMxB,QACV,IAAO,CAAA;YACLM;YACAG;YACAY;QACF,CAAA,GACA;QAACf;QAAgBG;QAAiBY;KAAkB;IAGtD,qBAAO,KAACnB,mBAAmBuB,QAAQ;QAACC,OAAOF;kBAAMnB;;AACnD;AAEA,MAAMsB,OAAO,KAAa;AAC1B,MAAMC,sBAAsB,IAAIpB;AAChC,MAAMqB,eAA6D;IACjEvB,gBAAgBsB;IAChBnB,iBAAiBkB;IACjBN,mBAAmBM;IACnBG,YAAY;AACd;AAEA,OAAO,SAASC;IACd,MAAMP,MAAMzB,WAAWG;IAEvB,MAAM8B,iBAAiBhC,QAAQ;QAC7B,IAAI,CAACwB,KAAK,OAAOK;QAEjB,OAAO;YAAE,GAAGL,GAAG;YAAEM,YAAY;QAAK;IACpC,GAAG;QAACN;KAAI;IAER,OAAOQ;AACT"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
15
15
|
const SelectionContext = /*#__PURE__*/ createContext(undefined);
|
|
16
16
|
const defaultGetId = (_item, index)=>index;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/SelectionProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n createContext,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nexport type GetIdFn<T, Id> = (item: T, index: number) => Id;\n\nexport interface SelectionState<T, Id = unknown> {\n selectionMap: Map<Id, T>;\n setSelection: (items: Array<{ id: Id; item: T }>) => void;\n toggleSelection: (item: T, id: Id) => void;\n removeFromSelection: (id: Id) => void;\n clearSelection: () => void;\n isSelected: (item: T, index: number) => boolean;\n}\n\nexport interface SelectionProviderProps {\n children: ReactNode;\n}\n\nexport interface UseSelectionOptions<T, Id = string | number> {\n getId?: GetIdFn<T, Id>;\n}\n\ninterface InternalState<T, Id> extends SelectionState<T, Id> {\n registerGetId: (fn: GetIdFn<T, Id>) => void;\n}\n\nconst SelectionContext = createContext<InternalState<unknown, unknown> | undefined>(undefined);\n\nconst defaultGetId = (_item: unknown, index: number): unknown => index;\n\n/**\n * Provides selection state to descendant components.\n */\nexport function SelectionProvider({ children }: SelectionProviderProps): ReactElement {\n const [selectionMap, setSelectionMap] = useState(new Map<unknown, unknown>());\n const getIdRef = useRef<GetIdFn<unknown, unknown>>(defaultGetId);\n\n // Allows consumers to register their own getId function. by default we use the index.\n const registerGetId = useCallback((fn: GetIdFn<unknown, unknown>) => {\n getIdRef.current = fn;\n }, []);\n\n const setSelection = useCallback((items: Array<{ id: unknown; item: unknown }>) => {\n const newMap = new Map<unknown, unknown>();\n items.forEach(({ item, id }) => newMap.set(id, item));\n setSelectionMap(newMap);\n }, []);\n\n const toggleSelection = useCallback((item: unknown, id: unknown) => {\n setSelectionMap((prev) => {\n const newMap = new Map(prev);\n if (newMap.has(id)) {\n newMap.delete(id);\n } else {\n newMap.set(id, item);\n }\n return newMap;\n });\n }, []);\n\n const removeFromSelection = useCallback((id: unknown) => {\n setSelectionMap((prev) => {\n if (!prev.has(id)) return prev;\n const newMap = new Map(prev);\n newMap.delete(id);\n return newMap;\n });\n }, []);\n\n const clearSelection = useCallback(() => setSelectionMap(new Map()), []);\n\n const isSelected = useCallback(\n (item: unknown, index: number) => selectionMap.has(getIdRef.current(item, index)),\n [selectionMap]\n );\n\n const ctx = useMemo<InternalState<unknown, unknown>>(\n () => ({\n selectionMap,\n setSelection,\n toggleSelection,\n removeFromSelection,\n clearSelection,\n isSelected,\n registerGetId,\n }),\n [selectionMap, setSelection, toggleSelection, removeFromSelection, clearSelection, isSelected, registerGetId]\n );\n\n return <SelectionContext.Provider value={ctx}>{children}</SelectionContext.Provider>;\n}\n\n/**\n * No-op functions and empty map for when there is no context available.\n * This allows components to use the hook without crashing given the optional nature of the provider.\n */\nconst noOp = (): void => {};\nconst noOpIsSelected = (): boolean => false;\nconst emptyMap = new Map<unknown, unknown>();\nconst defaultState: SelectionState<unknown, unknown> & { hasContext: false } = {\n selectionMap: emptyMap,\n setSelection: noOp,\n toggleSelection: noOp,\n removeFromSelection: noOp,\n clearSelection: noOp,\n isSelected: noOpIsSelected,\n hasContext: false,\n};\n\n/**\n * Hook to access selection state from context.\n * If used outside of a SelectionProvider, returns no-op functions and an empty selection map.\n *\n * @param options Optional configuration for the selection hook.\n * @param options.getId Function to get the unique identifier for an item, this allows the selection state to identify items.\n */\nexport function useSelection<T, Id = string | number>(\n options?: UseSelectionOptions<T, Id>\n): SelectionState<T, Id> & { hasContext: boolean } {\n const ctx = useContext(SelectionContext);\n\n useEffect(() => {\n if (ctx && options?.getId) {\n ctx.registerGetId(options.getId as GetIdFn<unknown, unknown>);\n }\n }, [ctx, options?.getId]);\n\n const memoizedResult = useMemo(() => {\n if (!ctx) return defaultState as SelectionState<T, Id> & { hasContext: false };\n\n const { registerGetId: _, ...rest } = ctx;\n return { ...rest, hasContext: true } as SelectionState<T, Id> & { hasContext: true };\n }, [ctx]);\n\n return memoizedResult;\n}\n"],"names":["createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","SelectionContext","undefined","defaultGetId","_item","index","SelectionProvider","children","selectionMap","setSelectionMap","Map","getIdRef","registerGetId","fn","current","setSelection","items","newMap","forEach","item","id","set","toggleSelection","prev","has","delete","removeFromSelection","clearSelection","isSelected","ctx","Provider","value","noOp","noOpIsSelected","emptyMap","defaultState","hasContext","useSelection","options","getId","memoizedResult","_","rest"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"sources":["../../src/context/SelectionProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n createContext,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nexport type GetIdFn<T, Id> = (item: T, index: number) => Id;\n\nexport interface SelectionState<T, Id = unknown> {\n selectionMap: Map<Id, T>;\n setSelection: (items: Array<{ id: Id; item: T }>) => void;\n toggleSelection: (item: T, id: Id) => void;\n removeFromSelection: (id: Id) => void;\n clearSelection: () => void;\n isSelected: (item: T, index: number) => boolean;\n}\n\nexport interface SelectionProviderProps {\n children: ReactNode;\n}\n\nexport interface UseSelectionOptions<T, Id = string | number> {\n getId?: GetIdFn<T, Id>;\n}\n\ninterface InternalState<T, Id> extends SelectionState<T, Id> {\n registerGetId: (fn: GetIdFn<T, Id>) => void;\n}\n\nconst SelectionContext = createContext<InternalState<unknown, unknown> | undefined>(undefined);\n\nconst defaultGetId = (_item: unknown, index: number): unknown => index;\n\n/**\n * Provides selection state to descendant components.\n */\nexport function SelectionProvider({ children }: SelectionProviderProps): ReactElement {\n const [selectionMap, setSelectionMap] = useState(new Map<unknown, unknown>());\n const getIdRef = useRef<GetIdFn<unknown, unknown>>(defaultGetId);\n\n // Allows consumers to register their own getId function. by default we use the index.\n const registerGetId = useCallback((fn: GetIdFn<unknown, unknown>) => {\n getIdRef.current = fn;\n }, []);\n\n const setSelection = useCallback((items: Array<{ id: unknown; item: unknown }>) => {\n const newMap = new Map<unknown, unknown>();\n items.forEach(({ item, id }) => newMap.set(id, item));\n setSelectionMap(newMap);\n }, []);\n\n const toggleSelection = useCallback((item: unknown, id: unknown) => {\n setSelectionMap((prev) => {\n const newMap = new Map(prev);\n if (newMap.has(id)) {\n newMap.delete(id);\n } else {\n newMap.set(id, item);\n }\n return newMap;\n });\n }, []);\n\n const removeFromSelection = useCallback((id: unknown) => {\n setSelectionMap((prev) => {\n if (!prev.has(id)) return prev;\n const newMap = new Map(prev);\n newMap.delete(id);\n return newMap;\n });\n }, []);\n\n const clearSelection = useCallback(() => setSelectionMap(new Map()), []);\n\n const isSelected = useCallback(\n (item: unknown, index: number) => selectionMap.has(getIdRef.current(item, index)),\n [selectionMap]\n );\n\n const ctx = useMemo<InternalState<unknown, unknown>>(\n () => ({\n selectionMap,\n setSelection,\n toggleSelection,\n removeFromSelection,\n clearSelection,\n isSelected,\n registerGetId,\n }),\n [selectionMap, setSelection, toggleSelection, removeFromSelection, clearSelection, isSelected, registerGetId]\n );\n\n return <SelectionContext.Provider value={ctx}>{children}</SelectionContext.Provider>;\n}\n\n/**\n * No-op functions and empty map for when there is no context available.\n * This allows components to use the hook without crashing given the optional nature of the provider.\n */\nconst noOp = (): void => {};\nconst noOpIsSelected = (): boolean => false;\nconst emptyMap = new Map<unknown, unknown>();\nconst defaultState: SelectionState<unknown, unknown> & { hasContext: false } = {\n selectionMap: emptyMap,\n setSelection: noOp,\n toggleSelection: noOp,\n removeFromSelection: noOp,\n clearSelection: noOp,\n isSelected: noOpIsSelected,\n hasContext: false,\n};\n\n/**\n * Hook to access selection state from context.\n * If used outside of a SelectionProvider, returns no-op functions and an empty selection map.\n *\n * @param options Optional configuration for the selection hook.\n * @param options.getId Function to get the unique identifier for an item, this allows the selection state to identify items.\n */\nexport function useSelection<T, Id = string | number>(\n options?: UseSelectionOptions<T, Id>\n): SelectionState<T, Id> & { hasContext: boolean } {\n const ctx = useContext(SelectionContext);\n\n useEffect(() => {\n if (ctx && options?.getId) {\n ctx.registerGetId(options.getId as GetIdFn<unknown, unknown>);\n }\n }, [ctx, options?.getId]);\n\n const memoizedResult = useMemo(() => {\n if (!ctx) return defaultState as SelectionState<T, Id> & { hasContext: false };\n\n const { registerGetId: _, ...rest } = ctx;\n return { ...rest, hasContext: true } as SelectionState<T, Id> & { hasContext: true };\n }, [ctx]);\n\n return memoizedResult;\n}\n"],"names":["createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","SelectionContext","undefined","defaultGetId","_item","index","SelectionProvider","children","selectionMap","setSelectionMap","Map","getIdRef","registerGetId","fn","current","setSelection","items","newMap","forEach","item","id","set","toggleSelection","prev","has","delete","removeFromSelection","clearSelection","isSelected","ctx","Provider","value","noOp","noOpIsSelected","emptyMap","defaultState","hasContext","useSelection","options","getId","memoizedResult","_","rest"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SACEA,aAAa,EAGbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,QAAQ;AAyBf,MAAMC,iCAAmBP,cAA2DQ;AAEpF,MAAMC,eAAe,CAACC,OAAgBC,QAA2BA;AAEjE;;CAEC,GACD,OAAO,SAASC,kBAAkB,EAAEC,QAAQ,EAA0B;IACpE,MAAM,CAACC,cAAcC,gBAAgB,GAAGT,SAAS,IAAIU;IACrD,MAAMC,WAAWZ,OAAkCI;IAEnD,sFAAsF;IACtF,MAAMS,gBAAgBjB,YAAY,CAACkB;QACjCF,SAASG,OAAO,GAAGD;IACrB,GAAG,EAAE;IAEL,MAAME,eAAepB,YAAY,CAACqB;QAChC,MAAMC,SAAS,IAAIP;QACnBM,MAAME,OAAO,CAAC,CAAC,EAAEC,IAAI,EAAEC,EAAE,EAAE,GAAKH,OAAOI,GAAG,CAACD,IAAID;QAC/CV,gBAAgBQ;IAClB,GAAG,EAAE;IAEL,MAAMK,kBAAkB3B,YAAY,CAACwB,MAAeC;QAClDX,gBAAgB,CAACc;YACf,MAAMN,SAAS,IAAIP,IAAIa;YACvB,IAAIN,OAAOO,GAAG,CAACJ,KAAK;gBAClBH,OAAOQ,MAAM,CAACL;YAChB,OAAO;gBACLH,OAAOI,GAAG,CAACD,IAAID;YACjB;YACA,OAAOF;QACT;IACF,GAAG,EAAE;IAEL,MAAMS,sBAAsB/B,YAAY,CAACyB;QACvCX,gBAAgB,CAACc;YACf,IAAI,CAACA,KAAKC,GAAG,CAACJ,KAAK,OAAOG;YAC1B,MAAMN,SAAS,IAAIP,IAAIa;YACvBN,OAAOQ,MAAM,CAACL;YACd,OAAOH;QACT;IACF,GAAG,EAAE;IAEL,MAAMU,iBAAiBhC,YAAY,IAAMc,gBAAgB,IAAIC,QAAQ,EAAE;IAEvE,MAAMkB,aAAajC,YACjB,CAACwB,MAAed,QAAkBG,aAAagB,GAAG,CAACb,SAASG,OAAO,CAACK,MAAMd,SAC1E;QAACG;KAAa;IAGhB,MAAMqB,MAAM/B,QACV,IAAO,CAAA;YACLU;YACAO;YACAO;YACAI;YACAC;YACAC;YACAhB;QACF,CAAA,GACA;QAACJ;QAAcO;QAAcO;QAAiBI;QAAqBC;QAAgBC;QAAYhB;KAAc;IAG/G,qBAAO,KAACX,iBAAiB6B,QAAQ;QAACC,OAAOF;kBAAMtB;;AACjD;AAEA;;;CAGC,GACD,MAAMyB,OAAO,KAAa;AAC1B,MAAMC,iBAAiB,IAAe;AACtC,MAAMC,WAAW,IAAIxB;AACrB,MAAMyB,eAAyE;IAC7E3B,cAAc0B;IACdnB,cAAciB;IACdV,iBAAiBU;IACjBN,qBAAqBM;IACrBL,gBAAgBK;IAChBJ,YAAYK;IACZG,YAAY;AACd;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,aACdC,OAAoC;IAEpC,MAAMT,MAAMjC,WAAWK;IAEvBJ,UAAU;QACR,IAAIgC,OAAOS,SAASC,OAAO;YACzBV,IAAIjB,aAAa,CAAC0B,QAAQC,KAAK;QACjC;IACF,GAAG;QAACV;QAAKS,SAASC;KAAM;IAExB,MAAMC,iBAAiB1C,QAAQ;QAC7B,IAAI,CAAC+B,KAAK,OAAOM;QAEjB,MAAM,EAAEvB,eAAe6B,CAAC,EAAE,GAAGC,MAAM,GAAGb;QACtC,OAAO;YAAE,GAAGa,IAAI;YAAEN,YAAY;QAAK;IACrC,GAAG;QAACP;KAAI;IAER,OAAOW;AACT"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import React, { useCallback } from 'react';
|
|
15
15
|
import { styled } from '@mui/material/styles';
|
|
16
16
|
import { SnackbarProvider as NotistackProvider, useSnackbar as useNotistack, MaterialDesignContent } from 'notistack';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/SnackbarProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useCallback } from 'react';\nimport { styled } from '@mui/material/styles';\nimport {\n SnackbarProvider as NotistackProvider,\n ProviderContext as NotistackContext,\n useSnackbar as useNotistack,\n SnackbarMessage,\n OptionsObject,\n SnackbarKey,\n MaterialDesignContent,\n} from 'notistack';\n\nexport interface SnackbarContext extends NotistackContext {\n errorSnackbar: EnqueueFunction;\n infoSnackbar: EnqueueFunction;\n warningSnackbar: EnqueueFunction;\n successSnackbar: EnqueueFunction;\n\n /**\n * Useful for catch blocks where the error will be of type `unknown`, tries\n * to show the `message` property if passed an instance of `Error`.\n */\n exceptionSnackbar: (error: unknown, options?: SnackbarOptions) => SnackbarKey;\n}\n\ntype EnqueueFunction = (message: SnackbarMessage, options?: SnackbarOptions) => SnackbarKey;\n\ntype SnackbarOptions = Omit<OptionsObject, 'variant'>;\n\n/**\n * Application-wide provider for showing snackbars/toasts.\n * Customized to preserve formatting in error messages.\n */\nexport function SnackbarProvider({\n children,\n ...props\n}: React.ComponentProps<typeof NotistackProvider>): React.ReactElement {\n return (\n <NotistackProvider\n {...props}\n Components={{\n error: styled(MaterialDesignContent)(() => ({\n '&.notistack-MuiContent-error': {\n whiteSpace: 'pre-wrap',\n },\n })),\n }}\n >\n {children}\n </NotistackProvider>\n );\n}\n\n/**\n * Gets the SnackbarContext with methods for displaying snackbars/toasts.\n */\nexport function useSnackbar(): SnackbarContext {\n const { enqueueSnackbar, closeSnackbar } = useNotistack();\n\n // Create variant-specific callbacks\n const errorSnackbar = useEnqueueFunction(enqueueSnackbar, 'error');\n const infoSnackbar = useEnqueueFunction(enqueueSnackbar, 'info');\n const warningSnackbar = useEnqueueFunction(enqueueSnackbar, 'warning');\n const successSnackbar = useEnqueueFunction(enqueueSnackbar, 'success');\n\n const exceptionSnackbar: SnackbarContext['exceptionSnackbar'] = useCallback(\n (error, options) => {\n // Try to use message prop, but fallback to a default message that\n // will just stringify the error provided\n const message = error instanceof Error ? error.message : `An unexpected error occurred: ${error}`;\n\n return errorSnackbar(message, options);\n },\n [errorSnackbar]\n );\n\n return {\n enqueueSnackbar,\n closeSnackbar,\n errorSnackbar,\n infoSnackbar,\n warningSnackbar,\n successSnackbar,\n exceptionSnackbar,\n };\n}\n\n// Helper to create a variant-specific enqueue function\nfunction useEnqueueFunction(\n enqueueSnackbar: NotistackContext['enqueueSnackbar'],\n variant: OptionsObject['variant']\n): EnqueueFunction {\n return useCallback(\n (message, options) => {\n const allOptions: OptionsObject = {\n ...options,\n variant,\n };\n return enqueueSnackbar(message, allOptions);\n },\n [enqueueSnackbar, variant]\n );\n}\n"],"names":["React","useCallback","styled","SnackbarProvider","NotistackProvider","useSnackbar","useNotistack","MaterialDesignContent","children","props","Components","error","whiteSpace","enqueueSnackbar","closeSnackbar","errorSnackbar","useEnqueueFunction","infoSnackbar","warningSnackbar","successSnackbar","exceptionSnackbar","options","message","Error","variant","allOptions"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"sources":["../../src/context/SnackbarProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useCallback } from 'react';\nimport { styled } from '@mui/material/styles';\nimport {\n SnackbarProvider as NotistackProvider,\n ProviderContext as NotistackContext,\n useSnackbar as useNotistack,\n SnackbarMessage,\n OptionsObject,\n SnackbarKey,\n MaterialDesignContent,\n} from 'notistack';\n\nexport interface SnackbarContext extends NotistackContext {\n errorSnackbar: EnqueueFunction;\n infoSnackbar: EnqueueFunction;\n warningSnackbar: EnqueueFunction;\n successSnackbar: EnqueueFunction;\n\n /**\n * Useful for catch blocks where the error will be of type `unknown`, tries\n * to show the `message` property if passed an instance of `Error`.\n */\n exceptionSnackbar: (error: unknown, options?: SnackbarOptions) => SnackbarKey;\n}\n\ntype EnqueueFunction = (message: SnackbarMessage, options?: SnackbarOptions) => SnackbarKey;\n\ntype SnackbarOptions = Omit<OptionsObject, 'variant'>;\n\n/**\n * Application-wide provider for showing snackbars/toasts.\n * Customized to preserve formatting in error messages.\n */\nexport function SnackbarProvider({\n children,\n ...props\n}: React.ComponentProps<typeof NotistackProvider>): React.ReactElement {\n return (\n <NotistackProvider\n {...props}\n Components={{\n error: styled(MaterialDesignContent)(() => ({\n '&.notistack-MuiContent-error': {\n whiteSpace: 'pre-wrap',\n },\n })),\n }}\n >\n {children}\n </NotistackProvider>\n );\n}\n\n/**\n * Gets the SnackbarContext with methods for displaying snackbars/toasts.\n */\nexport function useSnackbar(): SnackbarContext {\n const { enqueueSnackbar, closeSnackbar } = useNotistack();\n\n // Create variant-specific callbacks\n const errorSnackbar = useEnqueueFunction(enqueueSnackbar, 'error');\n const infoSnackbar = useEnqueueFunction(enqueueSnackbar, 'info');\n const warningSnackbar = useEnqueueFunction(enqueueSnackbar, 'warning');\n const successSnackbar = useEnqueueFunction(enqueueSnackbar, 'success');\n\n const exceptionSnackbar: SnackbarContext['exceptionSnackbar'] = useCallback(\n (error, options) => {\n // Try to use message prop, but fallback to a default message that\n // will just stringify the error provided\n const message = error instanceof Error ? error.message : `An unexpected error occurred: ${error}`;\n\n return errorSnackbar(message, options);\n },\n [errorSnackbar]\n );\n\n return {\n enqueueSnackbar,\n closeSnackbar,\n errorSnackbar,\n infoSnackbar,\n warningSnackbar,\n successSnackbar,\n exceptionSnackbar,\n };\n}\n\n// Helper to create a variant-specific enqueue function\nfunction useEnqueueFunction(\n enqueueSnackbar: NotistackContext['enqueueSnackbar'],\n variant: OptionsObject['variant']\n): EnqueueFunction {\n return useCallback(\n (message, options) => {\n const allOptions: OptionsObject = {\n ...options,\n variant,\n };\n return enqueueSnackbar(message, allOptions);\n },\n [enqueueSnackbar, variant]\n );\n}\n"],"names":["React","useCallback","styled","SnackbarProvider","NotistackProvider","useSnackbar","useNotistack","MaterialDesignContent","children","props","Components","error","whiteSpace","enqueueSnackbar","closeSnackbar","errorSnackbar","useEnqueueFunction","infoSnackbar","warningSnackbar","successSnackbar","exceptionSnackbar","options","message","Error","variant","allOptions"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,SAASC,WAAW,QAAQ,QAAQ;AAC3C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SACEC,oBAAoBC,iBAAiB,EAErCC,eAAeC,YAAY,EAI3BC,qBAAqB,QAChB,YAAY;AAmBnB;;;CAGC,GACD,OAAO,SAASJ,iBAAiB,EAC/BK,QAAQ,EACR,GAAGC,OAC4C;IAC/C,qBACE,KAACL;QACE,GAAGK,KAAK;QACTC,YAAY;YACVC,OAAOT,OAAOK,uBAAuB,IAAO,CAAA;oBAC1C,gCAAgC;wBAC9BK,YAAY;oBACd;gBACF,CAAA;QACF;kBAECJ;;AAGP;AAEA;;CAEC,GACD,OAAO,SAASH;IACd,MAAM,EAAEQ,eAAe,EAAEC,aAAa,EAAE,GAAGR;IAE3C,oCAAoC;IACpC,MAAMS,gBAAgBC,mBAAmBH,iBAAiB;IAC1D,MAAMI,eAAeD,mBAAmBH,iBAAiB;IACzD,MAAMK,kBAAkBF,mBAAmBH,iBAAiB;IAC5D,MAAMM,kBAAkBH,mBAAmBH,iBAAiB;IAE5D,MAAMO,oBAA0DnB,YAC9D,CAACU,OAAOU;QACN,kEAAkE;QAClE,yCAAyC;QACzC,MAAMC,UAAUX,iBAAiBY,QAAQZ,MAAMW,OAAO,GAAG,CAAC,8BAA8B,EAAEX,OAAO;QAEjG,OAAOI,cAAcO,SAASD;IAChC,GACA;QAACN;KAAc;IAGjB,OAAO;QACLF;QACAC;QACAC;QACAE;QACAC;QACAC;QACAC;IACF;AACF;AAEA,uDAAuD;AACvD,SAASJ,mBACPH,eAAoD,EACpDW,OAAiC;IAEjC,OAAOvB,YACL,CAACqB,SAASD;QACR,MAAMI,aAA4B;YAChC,GAAGJ,OAAO;YACVG;QACF;QACA,OAAOX,gBAAgBS,SAASG;IAClC,GACA;QAACZ;QAAiBW;KAAQ;AAE9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import React, { createContext, useContext } from 'react';
|
|
15
15
|
import { formatWithTimeZone, dateFormatOptionsWithTimeZone } from '../utils';
|
|
16
16
|
export const TimeZoneContext = /*#__PURE__*/ createContext(undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/TimeZoneProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, ReactElement, useContext } from 'react';\nimport { formatWithTimeZone, dateFormatOptionsWithTimeZone } from '../utils';\n\nexport const TimeZoneContext = createContext<string | undefined>(undefined);\n\nexport interface TimeZoneProviderProps {\n timeZone?: string;\n children?: React.ReactNode;\n}\n\nexport function TimeZoneProvider(props: TimeZoneProviderProps): ReactElement {\n const { children, timeZone } = props;\n return <TimeZoneContext.Provider value={timeZone}>{children}</TimeZoneContext.Provider>;\n}\n\nexport function useTimeZone(): {\n timeZone: string;\n formatWithUserTimeZone: (date: Date, formatString: string) => string;\n dateFormatOptionsWithUserTimeZone: (dateFormatOptions: Intl.DateTimeFormatOptions) => Intl.DateTimeFormatOptions;\n} {\n const timeZone = useContext(TimeZoneContext);\n return {\n // fallback to \"local\" timezone if TimeZoneProvider is not present in the React tree\n timeZone: timeZone ?? 'local',\n formatWithUserTimeZone(date: Date, formatString: string): string {\n return formatWithTimeZone(date, formatString, timeZone);\n },\n dateFormatOptionsWithUserTimeZone(dateFormatOptions: Intl.DateTimeFormatOptions): Intl.DateTimeFormatOptions {\n return dateFormatOptionsWithTimeZone(dateFormatOptions, timeZone);\n },\n };\n}\n"],"names":["React","createContext","useContext","formatWithTimeZone","dateFormatOptionsWithTimeZone","TimeZoneContext","undefined","TimeZoneProvider","props","children","timeZone","Provider","value","useTimeZone","formatWithUserTimeZone","date","formatString","dateFormatOptionsWithUserTimeZone","dateFormatOptions"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"sources":["../../src/context/TimeZoneProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, ReactElement, useContext } from 'react';\nimport { formatWithTimeZone, dateFormatOptionsWithTimeZone } from '../utils';\n\nexport const TimeZoneContext = createContext<string | undefined>(undefined);\n\nexport interface TimeZoneProviderProps {\n timeZone?: string;\n children?: React.ReactNode;\n}\n\nexport function TimeZoneProvider(props: TimeZoneProviderProps): ReactElement {\n const { children, timeZone } = props;\n return <TimeZoneContext.Provider value={timeZone}>{children}</TimeZoneContext.Provider>;\n}\n\nexport function useTimeZone(): {\n timeZone: string;\n formatWithUserTimeZone: (date: Date, formatString: string) => string;\n dateFormatOptionsWithUserTimeZone: (dateFormatOptions: Intl.DateTimeFormatOptions) => Intl.DateTimeFormatOptions;\n} {\n const timeZone = useContext(TimeZoneContext);\n return {\n // fallback to \"local\" timezone if TimeZoneProvider is not present in the React tree\n timeZone: timeZone ?? 'local',\n formatWithUserTimeZone(date: Date, formatString: string): string {\n return formatWithTimeZone(date, formatString, timeZone);\n },\n dateFormatOptionsWithUserTimeZone(dateFormatOptions: Intl.DateTimeFormatOptions): Intl.DateTimeFormatOptions {\n return dateFormatOptionsWithTimeZone(dateFormatOptions, timeZone);\n },\n };\n}\n"],"names":["React","createContext","useContext","formatWithTimeZone","dateFormatOptionsWithTimeZone","TimeZoneContext","undefined","TimeZoneProvider","props","children","timeZone","Provider","value","useTimeZone","formatWithUserTimeZone","date","formatString","dateFormatOptionsWithUserTimeZone","dateFormatOptions"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,SAASC,aAAa,EAAgBC,UAAU,QAAQ,QAAQ;AACvE,SAASC,kBAAkB,EAAEC,6BAA6B,QAAQ,WAAW;AAE7E,OAAO,MAAMC,gCAAkBJ,cAAkCK,WAAW;AAO5E,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGF;IAC/B,qBAAO,KAACH,gBAAgBM,QAAQ;QAACC,OAAOF;kBAAWD;;AACrD;AAEA,OAAO,SAASI;IAKd,MAAMH,WAAWR,WAAWG;IAC5B,OAAO;QACL,oFAAoF;QACpFK,UAAUA,YAAY;QACtBI,wBAAuBC,IAAU,EAAEC,YAAoB;YACrD,OAAOb,mBAAmBY,MAAMC,cAAcN;QAChD;QACAO,mCAAkCC,iBAA6C;YAC7E,OAAOd,8BAA8Bc,mBAAmBR;QAC1D;IACF;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { TextField as MuiTextField } from '@mui/material';
|
|
15
15
|
import { forwardRef, useCallback, useMemo, useState } from 'react';
|
|
16
16
|
import debounce from 'lodash/debounce';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/controls/TextField.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TextFieldProps as MuiTextFieldProps, TextField as MuiTextField } from '@mui/material';\nimport { ChangeEvent, ForwardedRef, forwardRef, useCallback, useMemo, useState } from 'react';\nimport debounce from 'lodash/debounce';\n\ntype TextFieldProps = Omit<MuiTextFieldProps, 'onChange'> & { debounceMs?: number; onChange?: (value: string) => void };\n\nexport const TextField = forwardRef(function (\n { debounceMs = 250, value, onChange, ...props }: TextFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n const [currentValue, setCurrentValue] = useState(value);\n\n function handleChange(event: ChangeEvent<HTMLInputElement>): void {\n setCurrentValue(event.target.value);\n debounceFn(event.target.value);\n }\n\n const handleDebounceFn = useCallback(\n (inputValue: string) => {\n onChange?.(inputValue);\n },\n [onChange]\n );\n\n const debounceFn = useMemo(() => debounce(handleDebounceFn, debounceMs), [debounceMs, handleDebounceFn]);\n\n return <MuiTextField ref={ref} value={currentValue} onChange={handleChange} {...props} />;\n});\nTextField.displayName = 'TextField';\n"],"names":["TextField","MuiTextField","forwardRef","useCallback","useMemo","useState","debounce","debounceMs","value","onChange","props","ref","currentValue","setCurrentValue","handleChange","event","target","debounceFn","handleDebounceFn","inputValue","displayName"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"sources":["../../src/controls/TextField.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TextFieldProps as MuiTextFieldProps, TextField as MuiTextField } from '@mui/material';\nimport { ChangeEvent, ForwardedRef, forwardRef, useCallback, useMemo, useState } from 'react';\nimport debounce from 'lodash/debounce';\n\ntype TextFieldProps = Omit<MuiTextFieldProps, 'onChange'> & { debounceMs?: number; onChange?: (value: string) => void };\n\nexport const TextField = forwardRef(function (\n { debounceMs = 250, value, onChange, ...props }: TextFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n const [currentValue, setCurrentValue] = useState(value);\n\n function handleChange(event: ChangeEvent<HTMLInputElement>): void {\n setCurrentValue(event.target.value);\n debounceFn(event.target.value);\n }\n\n const handleDebounceFn = useCallback(\n (inputValue: string) => {\n onChange?.(inputValue);\n },\n [onChange]\n );\n\n const debounceFn = useMemo(() => debounce(handleDebounceFn, debounceMs), [debounceMs, handleDebounceFn]);\n\n return <MuiTextField ref={ref} value={currentValue} onChange={handleChange} {...props} />;\n});\nTextField.displayName = 'TextField';\n"],"names":["TextField","MuiTextField","forwardRef","useCallback","useMemo","useState","debounce","debounceMs","value","onChange","props","ref","currentValue","setCurrentValue","handleChange","event","target","debounceFn","handleDebounceFn","inputValue","displayName"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA8CA,aAAaC,YAAY,QAAQ,gBAAgB;AAC/F,SAAoCC,UAAU,EAAEC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC9F,OAAOC,cAAc,kBAAkB;AAIvC,OAAO,MAAMN,0BAAYE,WAAW,SAClC,EAAEK,aAAa,GAAG,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGC,OAAuB,EAC/DC,GAAiC;IAEjC,MAAM,CAACC,cAAcC,gBAAgB,GAAGR,SAASG;IAEjD,SAASM,aAAaC,KAAoC;QACxDF,gBAAgBE,MAAMC,MAAM,CAACR,KAAK;QAClCS,WAAWF,MAAMC,MAAM,CAACR,KAAK;IAC/B;IAEA,MAAMU,mBAAmBf,YACvB,CAACgB;QACCV,WAAWU;IACb,GACA;QAACV;KAAS;IAGZ,MAAMQ,aAAab,QAAQ,IAAME,SAASY,kBAAkBX,aAAa;QAACA;QAAYW;KAAiB;IAEvG,qBAAO,KAACjB;QAAaU,KAAKA;QAAKH,OAAOI;QAAcH,UAAUK;QAAe,GAAGJ,KAAK;;AACvF,GAAG;AACHV,UAAUoB,WAAW,GAAG"}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
|
package/dist/model/index.js
CHANGED
package/dist/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './graph';\nexport * from './theme';\nexport * from './timeOption';\nexport * from './timeZoneOption';\nexport * from './action';\nexport * from './legend';\nexport * from './time';\nexport * from './bits';\nexport * from './bytes';\nexport * from './currency';\nexport * from './percent';\nexport * from './temperature';\nexport * from './decimal';\nexport * from './throughput';\nexport * from './formatterCache';\nexport * from './units';\nexport * from './utils';\nexport * from './types';\nexport * from './thresholds';\nexport * from './transforms';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,mBAAmB;AACjC,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,mBAAmB;AACjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './graph';\nexport * from './theme';\nexport * from './timeOption';\nexport * from './timeZoneOption';\nexport * from './action';\nexport * from './legend';\nexport * from './time';\nexport * from './bits';\nexport * from './bytes';\nexport * from './currency';\nexport * from './percent';\nexport * from './temperature';\nexport * from './decimal';\nexport * from './throughput';\nexport * from './formatterCache';\nexport * from './units';\nexport * from './utils';\nexport * from './types';\nexport * from './thresholds';\nexport * from './transforms';\nexport * from './value-mapping';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,mBAAmB;AACjC,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,mBAAmB;AACjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,kBAAkB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type ValueMapping = ValueMappingOptions | ValueMappingOptionsRange | ValueMappingOptionsRegex | ValueMappingOptionsMisc;
|
|
2
|
+
export interface ValueMappingOptions {
|
|
3
|
+
kind: 'Value';
|
|
4
|
+
spec: {
|
|
5
|
+
value: string | number;
|
|
6
|
+
result: MappedValue;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface ValueMappingOptionsRange {
|
|
10
|
+
kind: 'Range';
|
|
11
|
+
spec: {
|
|
12
|
+
from?: number;
|
|
13
|
+
to?: number;
|
|
14
|
+
result: MappedValue;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface ValueMappingOptionsRegex {
|
|
18
|
+
kind: 'Regex';
|
|
19
|
+
spec: {
|
|
20
|
+
pattern: string;
|
|
21
|
+
result: MappedValue;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface ValueMappingOptionsMisc {
|
|
25
|
+
kind: 'Misc';
|
|
26
|
+
spec: {
|
|
27
|
+
value: 'empty' | 'null' | 'NaN' | 'true' | 'false';
|
|
28
|
+
result: MappedValue;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface MappedValue {
|
|
32
|
+
value: number | string;
|
|
33
|
+
color?: string;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=value-mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-mapping.d.ts","sourceRoot":"","sources":["../../src/model/value-mapping.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,YAAY,GACpB,mBAAmB,GACnB,wBAAwB,GACxB,wBAAwB,GACxB,uBAAuB,CAAC;AAE5B,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;QACnD,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=value-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/value-mapping.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport type ValueMapping =\n | ValueMappingOptions\n | ValueMappingOptionsRange\n | ValueMappingOptionsRegex\n | ValueMappingOptionsMisc;\n\nexport interface ValueMappingOptions {\n kind: 'Value';\n spec: {\n value: string | number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRange {\n kind: 'Range';\n spec: {\n from?: number;\n to?: number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRegex {\n kind: 'Regex';\n spec: {\n pattern: string;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsMisc {\n kind: 'Misc';\n spec: {\n value: 'empty' | 'null' | 'NaN' | 'true' | 'false';\n result: MappedValue;\n };\n}\n\nexport interface MappedValue {\n value: number | string;\n color?: string;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAyCjC,WAGC"}
|
package/dist/test/render.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { render } from '@testing-library/react';
|
|
15
15
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
16
16
|
const queryClient = new QueryClient({
|
package/dist/test/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { render, RenderOptions, RenderResult } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ReactElement } from 'react';\n\nconst queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false } } });\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult {\n return render(<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>, options);\n}\n"],"names":["render","QueryClient","QueryClientProvider","queryClient","defaultOptions","queries","refetchOnWindowFocus","renderWithContext","ui","options","client"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { render, RenderOptions, RenderResult } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ReactElement } from 'react';\n\nconst queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false } } });\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult {\n return render(<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>, options);\n}\n"],"names":["render","QueryClient","QueryClientProvider","queryClient","defaultOptions","queries","refetchOnWindowFocus","renderWithContext","ui","options","client"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,QAAqC,yBAAyB;AAC7E,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,wBAAwB;AAGzE,MAAMC,cAAc,IAAIF,YAAY;IAAEG,gBAAgB;QAAEC,SAAS;YAAEC,sBAAsB;QAAM;IAAE;AAAE;AAEnG;;CAEC,GACD,OAAO,SAASC,kBAAkBC,EAAgB,EAAEC,OAAwC;IAC1F,OAAOT,qBAAO,KAACE;QAAoBQ,QAAQP;kBAAcK;QAA2BC;AACtF"}
|
package/dist/theme/typography.js
CHANGED
|
@@ -20,7 +20,7 @@ import '@fontsource/inter/900.css';
|
|
|
20
20
|
const fontWeightLight = 300;
|
|
21
21
|
const fontWeightRegular = 400;
|
|
22
22
|
const fontWeightMedium = 600;
|
|
23
|
-
const fontWeightBold =
|
|
23
|
+
const fontWeightBold = 700;
|
|
24
24
|
/**
|
|
25
25
|
* Theme typography options that are the same across both the dark and light themes.
|
|
26
26
|
*/ export const typography = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/theme/typography.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport '@fontsource/inter/300.css';\nimport '@fontsource/inter/400.css';\nimport '@fontsource/inter/500.css';\nimport '@fontsource/inter/600.css';\nimport '@fontsource/inter/700.css';\nimport '@fontsource/inter/900.css';\nimport { ThemeOptions } from '@mui/material';\n\n// Font weights need to correspond with the imports at the top of the file\nconst fontWeightLight = 300;\nconst fontWeightRegular = 400;\nconst fontWeightMedium = 600;\nconst fontWeightBold =
|
|
1
|
+
{"version":3,"sources":["../../src/theme/typography.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport '@fontsource/inter/300.css';\nimport '@fontsource/inter/400.css';\nimport '@fontsource/inter/500.css';\nimport '@fontsource/inter/600.css';\nimport '@fontsource/inter/700.css';\nimport '@fontsource/inter/900.css';\nimport { ThemeOptions } from '@mui/material';\n\n// Font weights need to correspond with the imports at the top of the file\nconst fontWeightLight = 300;\nconst fontWeightRegular = 400;\nconst fontWeightMedium = 600;\nconst fontWeightBold = 700;\n\n/**\n * Theme typography options that are the same across both the dark and light themes.\n */\nexport const typography: ThemeOptions['typography'] = {\n fontFamily:\n 'Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"',\n\n fontWeightLight,\n fontWeightRegular,\n fontWeightMedium,\n fontWeightBold,\n\n h1: {\n fontSize: '1.5rem', // 24px\n fontWeight: fontWeightMedium,\n lineHeight: '32px',\n },\n h2: {\n fontSize: '1.25rem', // 20px\n fontWeight: fontWeightMedium,\n lineHeight: '28px',\n },\n h3: {\n fontSize: '1rem', // 16px\n fontWeight: fontWeightMedium,\n lineHeight: '24px',\n },\n h4: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightMedium,\n lineHeight: '22px',\n },\n h5: undefined,\n h6: undefined,\n\n body1: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightRegular,\n lineHeight: '20px',\n },\n body2: {\n fontSize: '0.75rem', // 12px\n fontWeight: fontWeightRegular,\n lineHeight: '18px',\n },\n subtitle1: {\n fontSize: '1rem', // 16px\n fontWeight: fontWeightRegular,\n lineHeight: '24px',\n letterSpacing: '0.02rem',\n },\n subtitle2: {\n fontSize: '0.875rem', // 14px\n fontWeight: fontWeightMedium,\n lineHeight: '22px',\n letterSpacing: '0.03rem',\n textTransform: 'uppercase',\n },\n\n button: {\n // 14px\n fontSize: '0.875rem',\n fontWeight: fontWeightMedium,\n // 20 px\n lineHeight: '1.25rem',\n textTransform: 'none',\n letterSpacing: '0.03rem',\n },\n caption: {\n fontSize: '0.6875rem', // 11px\n fontWeight: fontWeightRegular,\n lineHeight: '16px',\n },\n};\n"],"names":["fontWeightLight","fontWeightRegular","fontWeightMedium","fontWeightBold","typography","fontFamily","h1","fontSize","fontWeight","lineHeight","h2","h3","h4","h5","undefined","h6","body1","body2","subtitle1","letterSpacing","subtitle2","textTransform","button","caption"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AACnC,OAAO,4BAA4B;AAGnC,0EAA0E;AAC1E,MAAMA,kBAAkB;AACxB,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AAEvB;;CAEC,GACD,OAAO,MAAMC,aAAyC;IACpDC,YACE;IAEFL;IACAC;IACAC;IACAC;IAEAG,IAAI;QACFC,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAC,IAAI;QACFH,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAE,IAAI;QACFJ,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAG,IAAI;QACFL,UAAU;QACVC,YAAYN;QACZO,YAAY;IACd;IACAI,IAAIC;IACJC,IAAID;IAEJE,OAAO;QACLT,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;IACAQ,OAAO;QACLV,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;IACAS,WAAW;QACTX,UAAU;QACVC,YAAYP;QACZQ,YAAY;QACZU,eAAe;IACjB;IACAC,WAAW;QACTb,UAAU;QACVC,YAAYN;QACZO,YAAY;QACZU,eAAe;QACfE,eAAe;IACjB;IAEAC,QAAQ;QACN,OAAO;QACPf,UAAU;QACVC,YAAYN;QACZ,QAAQ;QACRO,YAAY;QACZY,eAAe;QACfF,eAAe;IACjB;IACAI,SAAS;QACPhB,UAAU;QACVC,YAAYP;QACZQ,YAAY;IACd;AACF,EAAE"}
|
package/dist/utils/format.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function dateFormatOptionsWithTimeZone(dateFormatOptions: Intl.DateTimeFormatOptions, timeZone?: string): Intl.DateTimeFormatOptions;
|
|
2
2
|
export declare function formatWithTimeZone(date: Date, formatString: string, timeZone?: string): string;
|
|
3
|
+
export declare function getGMTOffset(timeZone?: string): string;
|
|
3
4
|
export declare function getFormattedAxisLabel(rangeMs: number): string | {
|
|
4
5
|
month: '{MMM}';
|
|
5
6
|
year: '{yearStyle|{yyyy}}\n{monthStyle|{MMM}}';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAgBA,wBAAgB,6BAA6B,CAC3C,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,EAC7C,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAAC,qBAAqB,CAgB5B;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAY9F;AAGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GACjD,MAAM,GACN;IACE,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,wCAAwC,CAAC;IAC/C,GAAG,EAAE,WAAW,CAAC;CAClB,CA8BJ;AAED,UAAU,iBAAiB;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,iBAWhD,CAAC"}
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAgBA,wBAAgB,6BAA6B,CAC3C,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,EAC7C,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAAC,qBAAqB,CAgB5B;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAY9F;AAED,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CA0BtD;AAGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GACjD,MAAM,GACN;IACE,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,wCAAwC,CAAC;IAC/C,GAAG,EAAE,WAAW,CAAC;CAClB,CA8BJ;AAED,UAAU,iBAAiB;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,iBAWhD,CAAC"}
|
package/dist/utils/format.js
CHANGED
|
@@ -42,6 +42,23 @@ export function formatWithTimeZone(date, formatString, timeZone) {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
export function getGMTOffset(timeZone) {
|
|
46
|
+
const lower = timeZone?.toLowerCase();
|
|
47
|
+
const resolvedTimeZone = !timeZone || lower === 'local' || lower === 'browser' ? Intl.DateTimeFormat().resolvedOptions().timeZone : lower === 'utc' ? 'UTC' : timeZone;
|
|
48
|
+
try {
|
|
49
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
|
50
|
+
timeZone: resolvedTimeZone,
|
|
51
|
+
timeZoneName: 'shortOffset'
|
|
52
|
+
});
|
|
53
|
+
const parts = formatter.formatToParts(new Date());
|
|
54
|
+
const tzPart = parts.find((p)=>p.type === 'timeZoneName');
|
|
55
|
+
const value = tzPart?.value ?? '';
|
|
56
|
+
if (value === 'GMT') return 'GMT+0';
|
|
57
|
+
return value;
|
|
58
|
+
} catch {
|
|
59
|
+
return 'GMT+0';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
45
62
|
// https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter
|
|
46
63
|
export function getFormattedAxisLabel(rangeMs) {
|
|
47
64
|
const dayMs = 86400000;
|
package/dist/utils/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/format.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { tz } from '@date-fns/tz';\nimport { format } from 'date-fns';\n\nexport function dateFormatOptionsWithTimeZone(\n dateFormatOptions: Intl.DateTimeFormatOptions,\n timeZone?: string\n): Intl.DateTimeFormatOptions {\n /*\n * if timeZone is provided, and is not local|browser,\n * then set timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, default to browser timeZone setting\n */\n if (timeZone) {\n const lowerTimeZone = timeZone.toLowerCase();\n if (lowerTimeZone !== 'local' && lowerTimeZone !== 'browser') {\n return {\n ...dateFormatOptions,\n timeZone: lowerTimeZone === 'utc' ? 'UTC' : timeZone,\n };\n }\n }\n return dateFormatOptions;\n}\n\nexport function formatWithTimeZone(date: Date, formatString: string, timeZone?: string): string {\n /*\n * if timeZone is provided, and is not local|browser,\n * then format using timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, format without timeZone option, defaulting to browser timeZone setting\n */\n const lowerTimeZone = timeZone?.toLowerCase();\n if (!timeZone || lowerTimeZone === 'local' || lowerTimeZone === 'browser') {\n return format(date, formatString);\n } else {\n return format(date, formatString, { in: tz(lowerTimeZone === 'utc' ? 'UTC' : timeZone) });\n }\n}\n\n// https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter\nexport function getFormattedAxisLabel(rangeMs: number):\n | string\n | {\n month: '{MMM}';\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}';\n day: '{MM}/{dd}';\n } {\n const dayMs = 86400000;\n const monthMs = 2629440000;\n const yearMs = 31536000000;\n\n // more than 5 years\n if (rangeMs > yearMs * 5) {\n return '{yyyy}';\n }\n\n // more than 2 years\n if (rangeMs > yearMs * 2) {\n return '{MMM} {yyyy}';\n }\n\n // between 5 days to 6 months\n if (rangeMs > dayMs * 5 && rangeMs < monthMs * 6) {\n return '{MM}/{dd}'; // 12/01\n }\n\n // between 2 and 5 days\n if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 5) {\n return '{MM}/{dd} {HH}:{mm}'; // 12/01 12:30\n }\n\n return {\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}',\n month: '{MMM}', // Jan, Feb, ...\n day: '{MM}/{dd}',\n };\n}\n\ninterface FormattedDateTime {\n formattedDate: string;\n formattedTime: string;\n}\n\nexport const getDateAndTime = (timeMs?: number): FormattedDateTime => {\n if (!timeMs) {\n return { formattedDate: '', formattedTime: '' };\n }\n const date = new Date(timeMs);\n const formattedDate = format(date, 'MMM dd, yyyy - ');\n const formattedTime = format(date, 'HH:mm:ss');\n return {\n formattedDate,\n formattedTime,\n };\n};\n"],"names":["tz","format","dateFormatOptionsWithTimeZone","dateFormatOptions","timeZone","lowerTimeZone","toLowerCase","formatWithTimeZone","date","formatString","in","getFormattedAxisLabel","rangeMs","dayMs","monthMs","yearMs","year","month","day","getDateAndTime","timeMs","formattedDate","formattedTime"
|
|
1
|
+
{"version":3,"sources":["../../src/utils/format.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { tz } from '@date-fns/tz';\nimport { format } from 'date-fns';\n\nexport function dateFormatOptionsWithTimeZone(\n dateFormatOptions: Intl.DateTimeFormatOptions,\n timeZone?: string\n): Intl.DateTimeFormatOptions {\n /*\n * if timeZone is provided, and is not local|browser,\n * then set timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, default to browser timeZone setting\n */\n if (timeZone) {\n const lowerTimeZone = timeZone.toLowerCase();\n if (lowerTimeZone !== 'local' && lowerTimeZone !== 'browser') {\n return {\n ...dateFormatOptions,\n timeZone: lowerTimeZone === 'utc' ? 'UTC' : timeZone,\n };\n }\n }\n return dateFormatOptions;\n}\n\nexport function formatWithTimeZone(date: Date, formatString: string, timeZone?: string): string {\n /*\n * if timeZone is provided, and is not local|browser,\n * then format using timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, format without timeZone option, defaulting to browser timeZone setting\n */\n const lowerTimeZone = timeZone?.toLowerCase();\n if (!timeZone || lowerTimeZone === 'local' || lowerTimeZone === 'browser') {\n return format(date, formatString);\n } else {\n return format(date, formatString, { in: tz(lowerTimeZone === 'utc' ? 'UTC' : timeZone) });\n }\n}\n\nexport function getGMTOffset(timeZone?: string): string {\n const lower = timeZone?.toLowerCase();\n\n const resolvedTimeZone =\n !timeZone || lower === 'local' || lower === 'browser'\n ? Intl.DateTimeFormat().resolvedOptions().timeZone\n : lower === 'utc'\n ? 'UTC'\n : timeZone;\n\n try {\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: resolvedTimeZone,\n timeZoneName: 'shortOffset',\n });\n\n const parts = formatter.formatToParts(new Date());\n const tzPart = parts.find((p) => p.type === 'timeZoneName');\n\n const value = tzPart?.value ?? '';\n\n if (value === 'GMT') return 'GMT+0';\n return value;\n } catch {\n return 'GMT+0';\n }\n}\n\n// https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter\nexport function getFormattedAxisLabel(rangeMs: number):\n | string\n | {\n month: '{MMM}';\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}';\n day: '{MM}/{dd}';\n } {\n const dayMs = 86400000;\n const monthMs = 2629440000;\n const yearMs = 31536000000;\n\n // more than 5 years\n if (rangeMs > yearMs * 5) {\n return '{yyyy}';\n }\n\n // more than 2 years\n if (rangeMs > yearMs * 2) {\n return '{MMM} {yyyy}';\n }\n\n // between 5 days to 6 months\n if (rangeMs > dayMs * 5 && rangeMs < monthMs * 6) {\n return '{MM}/{dd}'; // 12/01\n }\n\n // between 2 and 5 days\n if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 5) {\n return '{MM}/{dd} {HH}:{mm}'; // 12/01 12:30\n }\n\n return {\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}',\n month: '{MMM}', // Jan, Feb, ...\n day: '{MM}/{dd}',\n };\n}\n\ninterface FormattedDateTime {\n formattedDate: string;\n formattedTime: string;\n}\n\nexport const getDateAndTime = (timeMs?: number): FormattedDateTime => {\n if (!timeMs) {\n return { formattedDate: '', formattedTime: '' };\n }\n const date = new Date(timeMs);\n const formattedDate = format(date, 'MMM dd, yyyy - ');\n const formattedTime = format(date, 'HH:mm:ss');\n return {\n formattedDate,\n formattedTime,\n };\n};\n"],"names":["tz","format","dateFormatOptionsWithTimeZone","dateFormatOptions","timeZone","lowerTimeZone","toLowerCase","formatWithTimeZone","date","formatString","in","getGMTOffset","lower","resolvedTimeZone","Intl","DateTimeFormat","resolvedOptions","formatter","timeZoneName","parts","formatToParts","Date","tzPart","find","p","type","value","getFormattedAxisLabel","rangeMs","dayMs","monthMs","yearMs","year","month","day","getDateAndTime","timeMs","formattedDate","formattedTime"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,EAAE,QAAQ,eAAe;AAClC,SAASC,MAAM,QAAQ,WAAW;AAElC,OAAO,SAASC,8BACdC,iBAA6C,EAC7CC,QAAiB;IAEjB;;;;GAIC,GACD,IAAIA,UAAU;QACZ,MAAMC,gBAAgBD,SAASE,WAAW;QAC1C,IAAID,kBAAkB,WAAWA,kBAAkB,WAAW;YAC5D,OAAO;gBACL,GAAGF,iBAAiB;gBACpBC,UAAUC,kBAAkB,QAAQ,QAAQD;YAC9C;QACF;IACF;IACA,OAAOD;AACT;AAEA,OAAO,SAASI,mBAAmBC,IAAU,EAAEC,YAAoB,EAAEL,QAAiB;IACpF;;;;GAIC,GACD,MAAMC,gBAAgBD,UAAUE;IAChC,IAAI,CAACF,YAAYC,kBAAkB,WAAWA,kBAAkB,WAAW;QACzE,OAAOJ,OAAOO,MAAMC;IACtB,OAAO;QACL,OAAOR,OAAOO,MAAMC,cAAc;YAAEC,IAAIV,GAAGK,kBAAkB,QAAQ,QAAQD;QAAU;IACzF;AACF;AAEA,OAAO,SAASO,aAAaP,QAAiB;IAC5C,MAAMQ,QAAQR,UAAUE;IAExB,MAAMO,mBACJ,CAACT,YAAYQ,UAAU,WAAWA,UAAU,YACxCE,KAAKC,cAAc,GAAGC,eAAe,GAAGZ,QAAQ,GAChDQ,UAAU,QACR,QACAR;IAER,IAAI;QACF,MAAMa,YAAY,IAAIH,KAAKC,cAAc,CAAC,SAAS;YACjDX,UAAUS;YACVK,cAAc;QAChB;QAEA,MAAMC,QAAQF,UAAUG,aAAa,CAAC,IAAIC;QAC1C,MAAMC,SAASH,MAAMI,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK;QAE5C,MAAMC,QAAQJ,QAAQI,SAAS;QAE/B,IAAIA,UAAU,OAAO,OAAO;QAC5B,OAAOA;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,sEAAsE;AACtE,OAAO,SAASC,sBAAsBC,OAAe;IAOnD,MAAMC,QAAQ;IACd,MAAMC,UAAU;IAChB,MAAMC,SAAS;IAEf,oBAAoB;IACpB,IAAIH,UAAUG,SAAS,GAAG;QACxB,OAAO;IACT;IAEA,oBAAoB;IACpB,IAAIH,UAAUG,SAAS,GAAG;QACxB,OAAO;IACT;IAEA,6BAA6B;IAC7B,IAAIH,UAAUC,QAAQ,KAAKD,UAAUE,UAAU,GAAG;QAChD,OAAO,aAAa,QAAQ;IAC9B;IAEA,uBAAuB;IACvB,IAAIF,UAAUC,QAAQ,KAAKD,WAAWC,QAAQ,GAAG;QAC/C,OAAO,uBAAuB,cAAc;IAC9C;IAEA,OAAO;QACLG,MAAM;QACNC,OAAO;QACPC,KAAK;IACP;AACF;AAOA,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,IAAI,CAACA,QAAQ;QACX,OAAO;YAAEC,eAAe;YAAIC,eAAe;QAAG;IAChD;IACA,MAAM9B,OAAO,IAAIa,KAAKe;IACtB,MAAMC,gBAAgBpC,OAAOO,MAAM;IACnC,MAAM8B,gBAAgBrC,OAAOO,MAAM;IACnC,OAAO;QACL6B;QACAC;IACF;AACF,EAAE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestHeaders } from '@perses-dev/
|
|
1
|
+
import { RequestHeaders } from '@perses-dev/client';
|
|
2
2
|
import { VariableStateMap } from './variable-interpolation';
|
|
3
3
|
export type QueryParamValues = Record<string, string | string[]>;
|
|
4
4
|
export declare function interpolateHeaders(headers: Record<string, string>, variableState: VariableStateMap): RequestHeaders;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-interpolation.d.ts","sourceRoot":"","sources":["../../src/utils/request-interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"request-interpolation.d.ts","sourceRoot":"","sources":["../../src/utils/request-interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAoB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEjE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,gBAAgB,GAAG,cAAc,CAMnH;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,gBAAgB,EAC7B,aAAa,EAAE,gBAAgB,GAC9B,gBAAgB,CAUlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/request-interpolation.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { RequestHeaders } from '@perses-dev/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/request-interpolation.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { RequestHeaders } from '@perses-dev/client';\nimport { replaceVariables, VariableStateMap } from './variable-interpolation';\n\nexport type QueryParamValues = Record<string, string | string[]>;\n\nexport function interpolateHeaders(headers: Record<string, string>, variableState: VariableStateMap): RequestHeaders {\n const result: RequestHeaders = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key] = replaceVariables(value, variableState);\n }\n return result;\n}\n\nexport function interpolateQueryParams(\n queryParams: QueryParamValues,\n variableState: VariableStateMap\n): QueryParamValues {\n const result: QueryParamValues = {};\n for (const [key, value] of Object.entries(queryParams)) {\n if (Array.isArray(value)) {\n result[key] = value.map((v) => replaceVariables(v, variableState));\n } else {\n result[key] = replaceVariables(value, variableState);\n }\n }\n return result;\n}\n"],"names":["replaceVariables","interpolateHeaders","headers","variableState","result","key","value","Object","entries","interpolateQueryParams","queryParams","Array","isArray","map","v"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,gBAAgB,QAA0B,2BAA2B;AAI9E,OAAO,SAASC,mBAAmBC,OAA+B,EAAEC,aAA+B;IACjG,MAAMC,SAAyB,CAAC;IAChC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACN,SAAU;QAClDE,MAAM,CAACC,IAAI,GAAGL,iBAAiBM,OAAOH;IACxC;IACA,OAAOC;AACT;AAEA,OAAO,SAASK,uBACdC,WAA6B,EAC7BP,aAA+B;IAE/B,MAAMC,SAA2B,CAAC;IAClC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACE,aAAc;QACtD,IAAIC,MAAMC,OAAO,CAACN,QAAQ;YACxBF,MAAM,CAACC,IAAI,GAAGC,MAAMO,GAAG,CAAC,CAACC,IAAMd,iBAAiBc,GAAGX;QACrD,OAAO;YACLC,MAAM,CAACC,IAAI,GAAGL,iBAAiBM,OAAOH;QACxC;IACF;IACA,OAAOC;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/components",
|
|
3
|
-
"version": "0.54.0-beta.
|
|
3
|
+
"version": "0.54.0-beta.2",
|
|
4
4
|
"description": "Common UI components used across Perses features",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"@date-fns/tz": "^1.4.1",
|
|
35
35
|
"@fontsource/inter": "^5.0.0",
|
|
36
36
|
"@mui/x-date-pickers": "^7.23.1",
|
|
37
|
-
"@perses-dev/core": "0.53.0",
|
|
38
37
|
"@perses-dev/spec": "0.2.0-beta.0",
|
|
38
|
+
"@perses-dev/client": "0.54.0-beta.2",
|
|
39
|
+
"numbro": "^2.3.6",
|
|
39
40
|
"@tanstack/match-sorter-utils": "^8.19.4",
|
|
40
41
|
"@tanstack/react-table": "^8.20.5",
|
|
41
42
|
"@uiw/react-codemirror": "^4.19.1",
|