ooxml-ui 1.16.0 → 1.17.0

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/xlsx.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { statusLayout, watchStatusWidth } from './chunk-UBBC5FH7.js';
2
2
  import { trackPointerGesture } from './chunk-GSXOZCAN.js';
3
- import './chunk-QUG6IRQQ.js';
4
- import { syncRibbonAddIns } from './chunk-UIVYZERK.js';
5
- export { RIBBON_ADD_IN_EVENT } from './chunk-UIVYZERK.js';
3
+ import './chunk-CQ5BMX2Z.js';
4
+ import { syncRibbonAddIns } from './chunk-VUSDTDZS.js';
5
+ export { RIBBON_ADD_IN_EVENT } from './chunk-VUSDTDZS.js';
6
6
  import { defineSmartArt } from './chunk-ANPFMQ6E.js';
7
- import { withExtension, saveExtension, downloadBytes, emit, emitEvent, blobFor, announceFileCommand, pickFile } from './chunk-JVNIZBG7.js';
8
- export { XLSX_EDITOR_EVENTS } from './chunk-JVNIZBG7.js';
7
+ import { withExtension, saveExtension, downloadBytes, emit, emitEvent, blobFor, announceFileCommand, pickFile } from './chunk-VCXKKGQZ.js';
8
+ export { XLSX_EDITOR_EVENTS } from './chunk-VCXKKGQZ.js';
9
9
  import './chunk-GSWCAZQ3.js';
10
10
  import { shadcnBridge } from './chunk-7E3HU7RL.js';
11
- import { range_control_default, createRibbonOverflow, defineBackstage, defineRibbon, defineRibbonActions, defineTitleBar, defineStatusBar, defineZoomSlider, defineOptionsDialog, rangeControl, defineDialog, optionsLabels, runKeyTips, assignKeyTips, userInterfaceSection, personalizeSection, optionText, unavailableControl, unavailableCategory, defineGallery, defineColorGrid, defineContextMenu, defineCommentsPane, parseSvgPreview } from './chunk-CHFMXUPK.js';
11
+ import { range_control_default, createRibbonOverflow, defineBackstage, defineRibbon, defineRibbonActions, defineTitleBar, defineStatusBar, defineZoomSlider, defineOptionsDialog, rangeControl, defineDialog, optionsLabels, runKeyTips, assignKeyTips, userInterfaceSection, personalizeSection, optionText, unavailableControl, unavailableCategory, defineGallery, defineColorGrid, defineContextMenu, defineCommentsPane, defineChartPicker } from './chunk-KRQ5T2GX.js';
12
12
  import { getIcon, registerIcon } from './chunk-M6GF5ED2.js';
13
13
  import { definePresence } from './chunk-KNC2UEUR.js';
14
14
  import { withTokens } from './chunk-CWBSXK7P.js';
15
15
  import './chunk-LD3K2RDN.js';
16
- import { SPECIAL_CODES, FRACTION_CODES, translate, AUTOSUM_FUNCTIONS, themeToCssVars, lightTheme, darkTheme, ICON_ACCENTS, ICON_PATHS, normalizeEditorLocale, normalizeThemeMode, applyThemeColors, parseSelectionRef, selectionRef, DirtyState, createCommandRegistry, createDialogRegistry, activeRef, createSelectionModel, SheetSelections, translator, initialSelection, sheetBaseName, historyOf, onRibbonTabsChange, activeChart, editChart, ribbonTabs, isTabHidden, selectTab, setTabHidden, tabButton, searchCommands, formatNumber, TEMPLATES, createTemplateWorkbook, isMenuSeparator, registerRibbonTabs, installFormatPainter, SHEET_ICONS, clipboardCommands, fontCommands, alignmentCommands, numberCommands, cellCommands, editingCommands, pageLayoutCommands, pageBreakCommands, formulaCommands, dataCommands, whatIfCommands, contextualCommands, reviewTab, viewTab, helpTab, editBridge, CellViewCache, QUADRANTS, columnHeaderHeight, rowHeaderWidth, GridGeometry, cellRange, scrollToReveal, buildItems, fitNumber, cssFont, clampAddress, selectCell, movingEnd, extendSelection, moveWithinSelection, rowsRange, colsRange, ALL_RANGE, tabMenu, editing, icon, DATA_BAR_COLORS, dataBarRule, COLOR_SCALES, colorScaleRule, iconSetRule, target, tableAt, timelineSourceAt, slicerSourceAt, viewing, activeTable, numberFormatOptions, FONT_NAMES, FONT_SIZES, BORDER_PRESETS, ORIENTATIONS, ACCOUNTING_FORMATS, themePaletteItems, MARGIN_PRESETS, PAPER_SIZES, FUNCTION_MENUS, MORE_FUNCTION_CATEGORIES, functionsIn, activeSlicer, activeTimeline, isSingleCell, spanRange, selectionCellCount, addRange, activeStyle, selectSpecial, insertFunctionCall, guessHeader, regionOf, HIGHLIGHT_STYLES, ICON_SETS, TABLE_STYLES, tableStylePreview, resolveNameBox, absoluteReference, nameForRange, fillPaint, iconSvg, colSelected, rowSelected, rowHeaderMenu, columnHeaderMenu, cellMenu, recentFunctions, evaluateRef, buildChart, detectCategory, CATEGORIES, TIME_CODES, DATE_CODES, DEFAULT_OPTIONS, cellStyleItems, textDecoration, justify, alignItems, textAlign, hasBorders, edgeCss, diagonalSvg, SYMBOLS, buildCode, UNSET, dxfCss, negativeCodes, iconCount, iconThresholds, rowsOf, colsOf } from 'ooxml-core/xlsx/ui';
16
+ import { SPECIAL_CODES, FRACTION_CODES, translate, INSERT_CHART_TYPES, AUTOSUM_FUNCTIONS, themeToCssVars, lightTheme, darkTheme, ICON_ACCENTS, ICON_PATHS, normalizeEditorLocale, normalizeThemeMode, applyThemeColors, parseSelectionRef, selectionRef, DirtyState, createCommandRegistry, createDialogRegistry, activeRef, createSelectionModel, SheetSelections, translator, initialSelection, sheetBaseName, historyOf, onRibbonTabsChange, activeChart, editChart, ribbonTabs, isTabHidden, selectTab, setTabHidden, tabButton, searchCommands, formatNumber, TEMPLATES, createTemplateWorkbook, isMenuSeparator, registerRibbonTabs, installFormatPainter, SHEET_ICONS, clipboardCommands, fontCommands, alignmentCommands, numberCommands, cellCommands, editingCommands, pageLayoutCommands, pageBreakCommands, formulaCommands, dataCommands, whatIfCommands, contextualCommands, reviewTab, viewTab, helpTab, editBridge, CellViewCache, QUADRANTS, columnHeaderHeight, rowHeaderWidth, GridGeometry, cellRange, scrollToReveal, buildItems, fitNumber, cssFont, clampAddress, selectCell, movingEnd, extendSelection, moveWithinSelection, rowsRange, colsRange, ALL_RANGE, tabMenu, editing, icon, DATA_BAR_COLORS, dataBarRule, COLOR_SCALES, colorScaleRule, iconSetRule, target, tableAt, timelineSourceAt, slicerSourceAt, viewing, activeTable, numberFormatOptions, FONT_NAMES, FONT_SIZES, BORDER_PRESETS, ORIENTATIONS, ACCOUNTING_FORMATS, themePaletteItems, MARGIN_PRESETS, PAPER_SIZES, FUNCTION_MENUS, MORE_FUNCTION_CATEGORIES, functionsIn, activeSlicer, activeTimeline, isSingleCell, spanRange, selectionCellCount, addRange, activeStyle, selectSpecial, insertFunctionCall, guessHeader, regionOf, evaluateRef, HIGHLIGHT_STYLES, ICON_SETS, TABLE_STYLES, tableStylePreview, resolveNameBox, absoluteReference, nameForRange, fillPaint, iconSvg, colSelected, rowSelected, rowHeaderMenu, columnHeaderMenu, cellMenu, recentFunctions, buildChart, detectCategory, CATEGORIES, TIME_CODES, DATE_CODES, DEFAULT_OPTIONS, cellStyleItems, textDecoration, justify, alignItems, textAlign, hasBorders, edgeCss, diagonalSvg, SYMBOLS, buildCode, UNSET, dxfCss, negativeCodes, iconCount, iconThresholds, rowsOf, colsOf } from 'ooxml-core/xlsx/ui';
17
17
  export { EDITOR_LOCALES, THEME_KEYS, normalizeEditorLocale, registerRibbonTabs, themeToCssVars, darkTheme as xlsxDarkTheme, lightTheme as xlsxLightTheme } from 'ooxml-core/xlsx/ui';
18
18
  import { createWorksheet, createEditSession, approximateMeasure, createWorkbook, MAX_ROW, MAX_COL, chartView, createRefEvaluator, chartBarSpacing, CHART_FILL_PARTS, selectionStats, formatSelectionStat, printRange, formatRange, chartSeriesTransparencyPatch, chartSeriesTransparency, chartSeriesGradientPatch, chartSeriesSolidFillPatch, chartSeriesFillPatch, chartWithElementFills, chartElementTransparencyPatch, chartElementTransparency, chartElementGradientPatch, chartElementSolidFillPatch, chartElementFillPatch, chartElementFill, chartGradientStopTransparency, paginateWorksheet, resolveColor, DEFAULT_THEME, pageHeaderFooter, createGridMetrics, createPrintMergeIndex, formatAddress, cellView, renderHeaderFooterRuns, nextSheetName, FUNCTION_CATALOG, mergeAt, visibleCells, getCell, cellInputText, closeParens, isFormulaText, parseCellInput, referenceTarget, navigate, anchorToPixelBox, renderChartSvg, selectionOfPeriods, pixelBoxToAnchor, listValidationOptions, validationAt, getValue, resolvePasteOptions, pivotGroupableFields, pivotGroupableDateFields, pivotSubtotalFields, DEFAULT_COL_WIDTH, nameAtCaret, functionMatches, callAtCaret, splice, acceptsReference, translateFormula, slicerStyleColors, slicerGeometry, timelineGeometry, TIMELINE_PERIOD_WIDTH, TIMELINE_METRICS, timelineView, slicerItems, selectionAfterClick, isCellError, layoutRemoteSelections, parseHtmlTable, toggleAbsolute, rangeContains, pageViewLayout, formatValue, isDateFormat, pictureAnchorAt, selectedSparklineGroups, pivotTableAt, validateDefinedName, usedRange, pivotAxisChoices, parseAddress, PIVOT_DATE_UNITS, PIVOT_SUBTOTAL_ORDER, parseRange, parseInputCell, displayText, styleAt, rangesIntersect, chartColorScheme, SLICER_STYLE_NAMES, slicerStyleLabel, slicerStylePreview, coloredReferences, syntaxParams, activeParam, columnLabel, THEME_SLOTS, pageBreakPreview, normalizeRange, currentRegion, autoFitColumnWidth, pageViewCellRect, pageOfCell, validateSheetName, dateToSerial, IMAGE_EXTENSIONS, verifySheetPassword, verifyWorkbookPassword, sheetByName, quoteSheetName, pivotRowFields, pivotValuesIndex, pivotSourceData, defaultFieldGroup, defaultDateGroup, dateGroupDays, pivotIsoToSerial, fieldSubtotalFunctions, printTitles, formatPrintTitleSpan, parsePrintTitleSpan, scenariosOf, PAGE_VIEW_GAP, pivotPageItems, pivotPageItemLabel, pivotSerialToIso, previewScenario, serialToDate, BUILTIN_NUMBER_FORMATS, pixelsToColumnWidth, planBreakDrag, resizePrintArea, validateTableName, pixelsToEmu, pageViewHit, resizedFrameAnchor, headerFooterKey, splitHeaderFooter, composeHeaderFooter } from 'ooxml-core/xlsx';
19
19
  import { hyperlinkPolicy } from 'ooxml-core/opc';
@@ -6748,16 +6748,17 @@ function openFillSeries(ctx) {
6748
6748
  var PICTURE_TYPES = ["image/png", "image/jpeg", "image/gif", "image/bmp", "image/webp"].filter(
6749
6749
  (type) => type in IMAGE_EXTENSIONS
6750
6750
  );
6751
- var CHART_TYPES = [
6752
- ["column", "Column", "chartColumn"],
6753
- ["line", "Line", "chartLine"],
6754
- ["pie", "Pie", "chartPie"],
6755
- ["bar", "Bar", "chartBar"],
6756
- ["area", "Area", "chartArea"],
6757
- ["scatter", "Scatter", "chartScatter"],
6758
- ["doughnut", "Doughnut", "chartPie"],
6759
- ["radar", "Radar", "chartLine"]
6760
- ];
6751
+ var CHART_GLYPHS = {
6752
+ column: "chartColumn",
6753
+ line: "chartLine",
6754
+ pie: "chartPie",
6755
+ bar: "chartBar",
6756
+ area: "chartArea",
6757
+ scatter: "chartScatter",
6758
+ doughnut: "chartPie",
6759
+ radar: "chartLine"
6760
+ };
6761
+ var CHART_TYPES = INSERT_CHART_TYPES.map(([type, label]) => [type, label, CHART_GLYPHS[type] ?? "chartColumn"]);
6761
6762
  function pickImage(ctx) {
6762
6763
  return new Promise((resolve) => {
6763
6764
  const input = ctx.host.ownerDocument.createElement("input");
@@ -6876,92 +6877,58 @@ function openInsertChart(ctx, props2 = {}) {
6876
6877
  const t = target(ctx);
6877
6878
  if (!t) return Promise.resolve(void 0);
6878
6879
  const change = props2.change === true ? activeChart(ctx) : void 0;
6879
- let type = props2.type ?? change?.chart.chartType ?? "column";
6880
6880
  const range2 = regionOf(t);
6881
- defineGallery(ctx.host.ownerDocument.defaultView?.customElements);
6882
- const tiles = ctx.host.ownerDocument.createElement("office-ui-gallery");
6883
- tiles.setAttribute("mode", "panel");
6884
- const grouping = select(ctx, GROUPINGS, change?.chart.grouping ?? "clustered");
6885
- const groupingField = field(ctx, "Grouping", grouping);
6886
- const title = textInput(ctx, change?.chart.title ?? "");
6887
- const preview = el(ctx, "div", "xve-preview");
6888
- preview.setAttribute("aria-label", ctx.t("Preview"));
6889
- preview.setAttribute("role", "img");
6890
- const current = () => {
6881
+ const doc = ctx.host.ownerDocument;
6882
+ defineChartPicker(doc.defaultView?.customElements);
6883
+ const picker = doc.createElement("office-ui-chart-picker");
6884
+ picker.types = CHART_TYPES.map(([id, label]) => ({ id, label: ctx.t(label) }));
6885
+ picker.groupings = GROUPINGS.map(([id, label]) => ({ id, label: ctx.t(label) }));
6886
+ picker.groupedTypes = ["column", "bar"];
6887
+ picker.labels = {
6888
+ chartType: ctx.t("Chart type"),
6889
+ grouping: ctx.t("Grouping"),
6890
+ title: ctx.t("Chart title"),
6891
+ preview: ctx.t("Preview")
6892
+ };
6893
+ picker.changeOnly = change !== void 0;
6894
+ picker.value = {
6895
+ type: props2.type ?? change?.chart.chartType ?? "column",
6896
+ grouping: change?.chart.grouping ?? "clustered",
6897
+ title: change?.chart.title ?? ""
6898
+ };
6899
+ const current = (value) => {
6900
+ const grouping = value.grouping;
6891
6901
  if (change)
6892
- return {
6893
- ...structuredClone(change.chart),
6894
- chartType: type,
6895
- grouping: grouping.value
6896
- };
6897
- return buildChart(t.workbook, t.sheet, range2, type, {
6898
- grouping: grouping.value,
6899
- ...title.value.trim() ? { title: title.value.trim() } : {}
6902
+ return { ...structuredClone(change.chart), chartType: value.type, grouping };
6903
+ return buildChart(t.workbook, t.sheet, range2, value.type, {
6904
+ grouping,
6905
+ ...value.title.trim() ? { title: value.title.trim() } : {}
6900
6906
  });
6901
6907
  };
6902
- const refresh = () => {
6903
- tiles.state = {
6904
- id: "chart-type",
6905
- label: ctx.t("Chart type"),
6906
- sections: [
6907
- {
6908
- columns: 4,
6909
- tileWidth: 96,
6910
- tileHeight: 60,
6911
- items: CHART_TYPES.map(([key, label]) => ({
6912
- id: key,
6913
- label: ctx.t(label),
6914
- applied: key === type,
6915
- preview: renderChartSvg(
6916
- chartView(
6917
- t.workbook,
6918
- t.sheet,
6919
- { ...current(), chartType: key, title: "", showLegend: false },
6920
- (ref) => evaluateRef(t.workbook, t.sheet, ref)
6921
- ),
6922
- 360,
6923
- 220
6924
- )
6925
- }))
6926
- }
6927
- ]
6928
- };
6929
- groupingField.hidden = !(type === "column" || type === "bar");
6930
- const model = chartView(
6931
- t.workbook,
6932
- t.sheet,
6933
- current(),
6934
- (ref) => evaluateRef(t.workbook, t.sheet, ref)
6908
+ picker.drawPreview = (value, size, tile2) => {
6909
+ const chart = { ...current(value), ...tile2 ? { title: "", showLegend: false } : {} };
6910
+ return renderChartSvg(
6911
+ chartView(t.workbook, t.sheet, chart, (ref) => evaluateRef(t.workbook, t.sheet, ref)),
6912
+ size.width,
6913
+ size.height
6935
6914
  );
6936
- const node = parseSvgPreview(ctx.host.ownerDocument, renderChartSvg(model, 360, 220));
6937
- preview.replaceChildren(...node ? [node] : []);
6938
6915
  };
6939
- tiles.addEventListener("office-gallery-pick", (event) => {
6940
- const key = event.detail.itemId;
6941
- if (!CHART_TYPES.some(([id]) => id === key)) return;
6942
- type = key;
6943
- refresh();
6944
- });
6945
- grouping.addEventListener("change", refresh);
6946
- title.addEventListener("input", refresh);
6947
- const body = [tiles, groupingField];
6948
- if (!change) body.push(field(ctx, "Chart title", title));
6949
- body.push(preview);
6916
+ const body = [picker];
6950
6917
  if (!change && t.ws.rows.size === 0)
6951
6918
  body.push(text(ctx, "Select the data for the chart first, then insert it."));
6952
- refresh();
6953
6919
  return showDialog(ctx, {
6954
6920
  name: "insert-chart",
6955
6921
  heading: change ? "Change Chart Type" : "Insert Chart",
6956
6922
  wide: true,
6957
6923
  body,
6958
- opened: () => tiles.querySelector(`[data-gallery-item="${type}"]`)?.focus(),
6924
+ opened: () => picker.shadowRoot?.querySelector(`[data-gallery-item="${picker.value.type}"]`)?.focus(),
6959
6925
  submit: () => {
6960
- const chart = current();
6926
+ const value = picker.value;
6927
+ const chart = current(value);
6961
6928
  if (change)
6962
6929
  editChart(ctx, () => ({
6963
- chartType: type,
6964
- ...type === "column" || type === "bar" ? { grouping: grouping.value } : {}
6930
+ chartType: value.type,
6931
+ ...value.type === "column" || value.type === "bar" ? { grouping: value.grouping } : {}
6965
6932
  }));
6966
6933
  else {
6967
6934
  const { kind: _kind, ...model } = chart;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml-ui",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "Shared, format-neutral web components and styles for the Office viewers (Word, PowerPoint, Excel)",
5
5
  "keywords": [
6
6
  "custom-elements",
@@ -146,7 +146,7 @@
146
146
  "dompurify": "^3.4.16",
147
147
  "emf-converter": "4.18.1",
148
148
  "lit": "^3.3.3",
149
- "ooxml-core": "^1.16.0",
149
+ "ooxml-core": "^1.17.0",
150
150
  "opentype.js": "^2.0.0",
151
151
  "prosemirror-collab": "^1.3.1",
152
152
  "prosemirror-commands": "^1.7.2",