@abraca/nuxt 2.34.0 → 2.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/ANodeSettingsPanel.d.vue.ts +11 -4
  3. package/dist/runtime/components/ANodeSettingsPanel.vue +63 -9
  4. package/dist/runtime/components/ANodeSettingsPanel.vue.d.ts +11 -4
  5. package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
  6. package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
  7. package/dist/runtime/components/chat/ANodeChatPanel.vue +4 -0
  8. package/dist/runtime/components/renderers/ASheetsRenderer.client.vue +160 -1
  9. package/dist/runtime/components/renderers/sheets/ASheetsCell.d.vue.ts +3 -0
  10. package/dist/runtime/components/renderers/sheets/ASheetsCell.vue +30 -34
  11. package/dist/runtime/components/renderers/sheets/ASheetsCell.vue.d.ts +3 -0
  12. package/dist/runtime/components/renderers/sheets/ASheetsConditionalModal.d.vue.ts +15 -0
  13. package/dist/runtime/components/renderers/sheets/ASheetsConditionalModal.vue +226 -0
  14. package/dist/runtime/components/renderers/sheets/ASheetsConditionalModal.vue.d.ts +15 -0
  15. package/dist/runtime/components/renderers/sheets/ASheetsFindPanel.d.vue.ts +31 -0
  16. package/dist/runtime/components/renderers/sheets/ASheetsFindPanel.vue +130 -0
  17. package/dist/runtime/components/renderers/sheets/ASheetsFindPanel.vue.d.ts +31 -0
  18. package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue +25 -6
  19. package/dist/runtime/components/renderers/sheets/ASheetsToolbar.d.vue.ts +6 -0
  20. package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue +39 -3
  21. package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue.d.ts +6 -0
  22. package/dist/runtime/components/renderers/sheets/ASheetsValidationModal.d.vue.ts +15 -0
  23. package/dist/runtime/components/renderers/sheets/ASheetsValidationModal.vue +185 -0
  24. package/dist/runtime/components/renderers/sheets/ASheetsValidationModal.vue.d.ts +15 -0
  25. package/dist/runtime/components/settings/ASettingsAdminPanel.vue +168 -1
  26. package/dist/runtime/components/settings/ASettingsInvitesPanel.vue +73 -11
  27. package/dist/runtime/components/shell/ADocPanelSettings.d.vue.ts +25 -3
  28. package/dist/runtime/components/shell/ADocPanelSettings.vue +28 -10
  29. package/dist/runtime/components/shell/ADocPanelSettings.vue.d.ts +25 -3
  30. package/dist/runtime/composables/useChatUsers.d.ts +50 -4
  31. package/dist/runtime/composables/useChatUsers.js +57 -17
  32. package/dist/runtime/composables/useDocPermissions.d.ts +137 -0
  33. package/dist/runtime/composables/useDocPermissions.js +258 -0
  34. package/dist/runtime/composables/useIdentityDoc.d.ts +1 -1
  35. package/dist/runtime/composables/useOrphans.d.ts +58 -0
  36. package/dist/runtime/composables/useOrphans.js +87 -0
  37. package/dist/runtime/composables/useSheetsFind.d.ts +35 -0
  38. package/dist/runtime/composables/useSheetsFind.js +44 -0
  39. package/dist/runtime/composables/useSheetsFormat.d.ts +40 -0
  40. package/dist/runtime/composables/useSheetsFormat.js +132 -0
  41. package/dist/runtime/composables/useSheetsValidation.d.ts +22 -0
  42. package/dist/runtime/composables/useSheetsValidation.js +38 -0
  43. package/dist/runtime/types.d.ts +52 -10
  44. package/package.json +1 -1
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "2.34.0",
7
+ "version": "2.35.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -8,13 +8,19 @@ type __VLS_Props = {
8
8
  docLabel?: string;
9
9
  /** Document meta to read/write. */
10
10
  docMeta?: DocPageMeta | null;
11
- /** Permission entries — left to the consumer (varies per backend). */
11
+ /**
12
+ * Auto-wire server-backed permissions + public-access via useDocPermissions.
13
+ * When true, the `permissions` / `loadingPermissions` / `onlineNotGranted` /
14
+ * `isOwner` props below are ignored (the composable supplies them).
15
+ */
16
+ managePermissions?: boolean;
17
+ /** Permission entries — left to the consumer (ignored when `manage-permissions`). */
12
18
  permissions?: PermissionEntry[];
13
- /** Loading flag for permissions. */
19
+ /** Loading flag for permissions (ignored when `manage-permissions`). */
14
20
  loadingPermissions?: boolean;
15
- /** Online users not yet in permission list. */
21
+ /** Online users not yet in permission list (ignored when `manage-permissions`). */
16
22
  onlineNotGranted?: OnlineUser[];
17
- /** Whether the current user is owner. */
23
+ /** Whether the current user is owner (ignored when `manage-permissions`). */
18
24
  isOwner?: boolean;
19
25
  };
20
26
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -46,6 +52,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
46
52
  permissions: PermissionEntry[];
47
53
  loadingPermissions: boolean;
48
54
  onlineNotGranted: OnlineUser[];
55
+ managePermissions: boolean;
49
56
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
50
57
  declare const _default: typeof __VLS_export;
51
58
  export default _default;
@@ -1,6 +1,9 @@
1
1
  <script setup>
2
2
  import { computed, ref, toRef, watch } from "vue";
3
+ import { useToast } from "#imports";
3
4
  import { useDocSnapshots } from "../composables/useDocSnapshots";
5
+ import { useDocPermissions } from "../composables/useDocPermissions";
6
+ import { useChatUsers } from "../composables/useChatUsers";
4
7
  import { useAbracadabra } from "../composables/useAbracadabra";
5
8
  import ADocPanelSettings from "./shell/ADocPanelSettings.vue";
6
9
  import ASnapshotPreviewModal from "./ASnapshotPreviewModal.vue";
@@ -9,6 +12,7 @@ const props = defineProps({
9
12
  docTypeKey: { type: String, required: false },
10
13
  docLabel: { type: String, required: false },
11
14
  docMeta: { type: [Object, null], required: false },
15
+ managePermissions: { type: Boolean, required: false, default: false },
12
16
  permissions: { type: Array, required: false, default: () => [] },
13
17
  loadingPermissions: { type: Boolean, required: false, default: false },
14
18
  onlineNotGranted: { type: Array, required: false, default: () => [] },
@@ -16,17 +20,60 @@ const props = defineProps({
16
20
  });
17
21
  const emit = defineEmits(["grant-permission", "change-role", "revoke-permission", "create-invite", "sync-doc", "open-encryption", "update-meta"]);
18
22
  const abra = useAbracadabra();
23
+ const toast = useToast();
19
24
  const docIdRef = toRef(props, "docId");
20
25
  const snaps = useDocSnapshots(docIdRef);
21
26
  watch(docIdRef, (id) => {
22
27
  if (id) snaps.fetchList();
23
28
  }, { immediate: true });
24
29
  const previewVersion = ref(null);
25
- const effectiveRole = computed(() => abra.provider.value?.effectiveRole ?? null);
30
+ const chatUsers = useChatUsers();
31
+ const onlineUsers = computed(
32
+ () => chatUsers.onlineUsers.value.map((u) => ({ publicKey: u.publicKey, name: u.name, color: u.color }))
33
+ );
34
+ const perms = useDocPermissions(() => props.docId, { users: () => onlineUsers.value });
35
+ watch(
36
+ [docIdRef, () => props.managePermissions, () => abra.client.value],
37
+ ([id]) => {
38
+ if (props.managePermissions && id && abra.client.value) perms.refresh();
39
+ },
40
+ { immediate: true }
41
+ );
42
+ watch(perms.error, (msg) => {
43
+ if (props.managePermissions && msg) toast.add({ title: "Permission update failed", description: msg, color: "error" });
44
+ });
45
+ watch(perms.warning, (msg) => {
46
+ if (props.managePermissions && msg) toast.add({ title: "Granted, but E2E key provisioning failed", description: msg, color: "warning" });
47
+ });
48
+ const managing = computed(() => props.managePermissions);
49
+ const boundPermissions = computed(() => managing.value ? perms.permissions.value : props.permissions);
50
+ const boundLoadingPermissions = computed(() => managing.value ? perms.loadingPermissions.value : props.loadingPermissions);
51
+ const boundOnlineNotGranted = computed(() => managing.value ? perms.onlineNotGranted.value : props.onlineNotGranted);
52
+ const boundIsOwner = computed(() => managing.value ? perms.isOwner.value : props.isOwner);
53
+ const boundDefaultRole = computed(() => managing.value ? perms.serverDefaultRole.value ?? "viewer" : "viewer");
54
+ const boundInheritedFromLabel = computed(() => managing.value ? perms.inheritedFromLabel.value : null);
55
+ const effectiveRole = computed(
56
+ () => managing.value ? perms.effectiveRole.value : abra.provider.value?.effectiveRole ?? null
57
+ );
26
58
  const userName = computed(() => abra.userName?.value ?? "");
27
59
  const syncStatusIcon = computed(() => abra.provider.value ? "i-lucide-cloud" : "i-lucide-cloud-off");
28
60
  const syncStatusColor = computed(() => abra.provider.value ? "text-success" : "text-muted");
29
61
  const syncStatusLabel = computed(() => abra.provider.value ? "Connected" : "Disconnected");
62
+ function onGrant(u, r) {
63
+ if (managing.value) perms.grantPermission(u, r);
64
+ else emit("grant-permission", u, r);
65
+ }
66
+ function onChangeRole(u, r) {
67
+ if (managing.value) perms.changeRole(u, r);
68
+ else emit("change-role", u, r);
69
+ }
70
+ function onRevoke(u) {
71
+ if (managing.value) perms.revokePermission(u);
72
+ else emit("revoke-permission", u);
73
+ }
74
+ function onSetPublicAccess(v) {
75
+ if (managing.value) perms.setPublicAccess(v);
76
+ }
30
77
  </script>
31
78
 
32
79
  <template>
@@ -34,10 +81,16 @@ const syncStatusLabel = computed(() => abra.provider.value ? "Connected" : "Disc
34
81
  :doc-id="docId"
35
82
  :effective-role="effectiveRole"
36
83
  :user-name="userName"
37
- :is-owner="isOwner"
38
- :permissions="permissions"
39
- :loading-permissions="loadingPermissions"
40
- :online-not-granted="onlineNotGranted"
84
+ :is-owner="boundIsOwner"
85
+ :permissions="boundPermissions"
86
+ :loading-permissions="boundLoadingPermissions"
87
+ :default-role="boundDefaultRole"
88
+ :inherited-from-label="boundInheritedFromLabel"
89
+ :online-not-granted="boundOnlineNotGranted"
90
+ :public-access-value="perms.currentPublicAccessValue.value"
91
+ :public-access-options="perms.publicAccessOptions.value"
92
+ :can-edit-public-access="managing && boundIsOwner"
93
+ :saving-public-access="perms.savingAccess.value"
41
94
  :sync-status-icon="syncStatusIcon"
42
95
  :sync-status-color="syncStatusColor"
43
96
  :sync-status-label="syncStatusLabel"
@@ -49,9 +102,10 @@ const syncStatusLabel = computed(() => abra.provider.value ? "Connected" : "Disc
49
102
  :has-more-snapshots="snaps.hasMore.value"
50
103
  :pending-snapshot-version="null"
51
104
  :is-creating-snapshot="snaps.creating.value"
52
- @grant-permission="(u, r) => emit('grant-permission', u, r)"
53
- @change-role="(u, r) => emit('change-role', u, r)"
54
- @revoke-permission="(u) => emit('revoke-permission', u)"
105
+ @grant-permission="onGrant"
106
+ @change-role="onChangeRole"
107
+ @revoke-permission="onRevoke"
108
+ @set-public-access="onSetPublicAccess"
55
109
  @create-invite="(o) => emit('create-invite', o)"
56
110
  @sync-doc="emit('sync-doc')"
57
111
  @open-encryption="emit('open-encryption')"
@@ -71,7 +125,7 @@ const syncStatusLabel = computed(() => abra.provider.value ? "Connected" : "Disc
71
125
  :doc-label="docLabel"
72
126
  :doc-type="docTypeKey"
73
127
  :doc-meta="docMeta"
74
- :is-owner="isOwner"
128
+ :is-owner="boundIsOwner"
75
129
  @restore="(v) => snaps.restore(v)"
76
130
  @fork="(v) => snaps.fork(v)"
77
131
  @delete="(v) => snaps.remove(v)"
@@ -8,13 +8,19 @@ type __VLS_Props = {
8
8
  docLabel?: string;
9
9
  /** Document meta to read/write. */
10
10
  docMeta?: DocPageMeta | null;
11
- /** Permission entries — left to the consumer (varies per backend). */
11
+ /**
12
+ * Auto-wire server-backed permissions + public-access via useDocPermissions.
13
+ * When true, the `permissions` / `loadingPermissions` / `onlineNotGranted` /
14
+ * `isOwner` props below are ignored (the composable supplies them).
15
+ */
16
+ managePermissions?: boolean;
17
+ /** Permission entries — left to the consumer (ignored when `manage-permissions`). */
12
18
  permissions?: PermissionEntry[];
13
- /** Loading flag for permissions. */
19
+ /** Loading flag for permissions (ignored when `manage-permissions`). */
14
20
  loadingPermissions?: boolean;
15
- /** Online users not yet in permission list. */
21
+ /** Online users not yet in permission list (ignored when `manage-permissions`). */
16
22
  onlineNotGranted?: OnlineUser[];
17
- /** Whether the current user is owner. */
23
+ /** Whether the current user is owner (ignored when `manage-permissions`). */
18
24
  isOwner?: boolean;
19
25
  };
20
26
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -46,6 +52,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
46
52
  permissions: PermissionEntry[];
47
53
  loadingPermissions: boolean;
48
54
  onlineNotGranted: OnlineUser[];
55
+ managePermissions: boolean;
49
56
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
50
57
  declare const _default: typeof __VLS_export;
51
58
  export default _default;
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
12
12
  awareness: boolean;
13
13
  tag: "video" | "audio";
14
14
  live: boolean;
15
- total: boolean;
16
15
  controls: boolean;
16
+ total: boolean;
17
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
18
  declare const _default: typeof __VLS_export;
19
19
  export default _default;
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
12
12
  awareness: boolean;
13
13
  tag: "video" | "audio";
14
14
  live: boolean;
15
- total: boolean;
16
15
  controls: boolean;
16
+ total: boolean;
17
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
18
  declare const _default: typeof __VLS_export;
19
19
  export default _default;
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import { useChatChannel } from "../../composables/useChat";
4
+ import { useChatUsers } from "../../composables/useChatUsers";
4
5
  import { useAbracadabra } from "../../composables/useAbracadabra";
5
6
  import AChatPanel from "./AChatPanel.vue";
6
7
  const props = defineProps({
@@ -15,6 +16,8 @@ const props = defineProps({
15
16
  const emit = defineEmits(["open-doc", "jump-to-quote", "close"]);
16
17
  const { publicKeyB64 } = useAbracadabra();
17
18
  const { messages, channel, typingUsers, send, typing } = useChatChannel(props.docId);
19
+ const { agentsForChannel } = useChatUsers();
20
+ const channelAgents = computed(() => agentsForChannel(props.docId));
18
21
  const resolvedLabel = computed(() => props.label ?? channel.value?.label ?? "Chat");
19
22
  const typingUsersAdapted = computed(
20
23
  () => (typingUsers.value || []).map((id) => ({
@@ -32,6 +35,7 @@ const typingUsersAdapted = computed(
32
35
  :messages="messages"
33
36
  :current-user-id="publicKeyB64 ?? ''"
34
37
  :typing-users="typingUsersAdapted"
38
+ :active-agents="channelAgents"
35
39
  :placeholder="placeholder"
36
40
  :autofocus="autofocus"
37
41
  :empty-icon="emptyIcon"
@@ -18,10 +18,14 @@ import {
18
18
  } from "../../composables/useSheetsFormulas";
19
19
  import { useDocumentPermissions } from "../../composables/useDocumentPermissions";
20
20
  import { useAbracadabra } from "../../composables/useAbracadabra";
21
+ import { findMatches, replaceInCell } from "../../composables/useSheetsFind";
21
22
  import { DEFAULT_LOCALE } from "../../locale";
22
23
  import ASheetsToolbar from "./sheets/ASheetsToolbar.vue";
23
24
  import ASheetsGrid from "./sheets/ASheetsGrid.vue";
24
25
  import ASheetsMobileActionBar from "./sheets/ASheetsMobileActionBar.vue";
26
+ import ASheetsFindPanel from "./sheets/ASheetsFindPanel.vue";
27
+ import ASheetsConditionalModal from "./sheets/ASheetsConditionalModal.vue";
28
+ import ASheetsValidationModal from "./sheets/ASheetsValidationModal.vue";
25
29
  const props = defineProps({
26
30
  docId: { type: String, required: true },
27
31
  childProvider: { type: null, required: true },
@@ -676,6 +680,10 @@ function colHeaderContextItems(colIdx) {
676
680
  { label: locale.value.insertColumnLeft, icon: "i-lucide-arrow-left", onSelect: () => insertColAt(colIdx) },
677
681
  { label: locale.value.insertColumnRight, icon: "i-lucide-arrow-right", onSelect: () => insertColAt(colIdx + 1) }
678
682
  ],
683
+ [
684
+ { label: "Conditional formatting\u2026", icon: "i-lucide-palette", onSelect: () => openColumnConditional(colIdx) },
685
+ { label: "Data validation\u2026", icon: "i-lucide-list-checks", onSelect: () => openColumnValidation(colIdx) }
686
+ ],
679
687
  [
680
688
  { label: locale.value.deleteColumn, icon: "i-lucide-trash-2", color: "error", onSelect: () => deleteColumnAt(colIdx) }
681
689
  ]
@@ -721,7 +729,119 @@ function onCommitFormulaBar() {
721
729
  function onCancelFormulaBar() {
722
730
  selection.cancelEdit();
723
731
  }
732
+ const findVisible = ref(false);
733
+ const findQuery = ref("");
734
+ const findReplacement = ref("");
735
+ const findOptions = ref({});
736
+ const findIndex = ref(-1);
737
+ function findCellText(colIdx, rowIdx) {
738
+ const entry = getCellEntry(colIdx, rowIdx);
739
+ return { label: getCellValue(colIdx, rowIdx), formula: entry?.meta?.formula };
740
+ }
741
+ const findMatchList = computed(() => {
742
+ if (!findVisible.value || !findQuery.value) return [];
743
+ return findMatches(findQuery.value, findCellText, columns.value.length, dataRowCount.value, findOptions.value);
744
+ });
745
+ watch(findMatchList, (list) => {
746
+ if (!list.length) {
747
+ findIndex.value = -1;
748
+ } else if (findIndex.value < 0 || findIndex.value >= list.length) findIndex.value = 0;
749
+ });
750
+ function gotoMatch(i) {
751
+ const list = findMatchList.value;
752
+ if (!list.length) return;
753
+ const n = (i % list.length + list.length) % list.length;
754
+ findIndex.value = n;
755
+ const m = list[n];
756
+ selection.selectCell(m.colIdx, m.rowIdx, false);
757
+ }
758
+ function findNext() {
759
+ gotoMatch(findIndex.value + 1);
760
+ }
761
+ function findPrev() {
762
+ gotoMatch(findIndex.value - 1);
763
+ }
764
+ function openFind() {
765
+ findVisible.value = true;
766
+ nextTick(() => {
767
+ if (findMatchList.value.length) gotoMatch(0);
768
+ });
769
+ }
770
+ function closeFind() {
771
+ findVisible.value = false;
772
+ }
773
+ function replaceCurrent() {
774
+ const m = findMatchList.value[findIndex.value];
775
+ if (!m || !canWrite.value) return;
776
+ const next = replaceInCell(findCellText(m.colIdx, m.rowIdx), findQuery.value, findReplacement.value, findOptions.value);
777
+ if (next != null) commitCellValue(m.colIdx, m.rowIdx, next);
778
+ nextTick(() => findNext());
779
+ }
780
+ function replaceAll() {
781
+ if (!canWrite.value) return;
782
+ for (const m of [...findMatchList.value]) {
783
+ const next = replaceInCell(findCellText(m.colIdx, m.rowIdx), findQuery.value, findReplacement.value, findOptions.value);
784
+ if (next != null) writeCellValue(m.colIdx, m.rowIdx, next);
785
+ }
786
+ recalcFormulas();
787
+ stopUndoCapturing();
788
+ }
789
+ const conditionalOpen = ref(false);
790
+ const validationOpen = ref(false);
791
+ const ruleTargetColId = ref(null);
792
+ function ruleTargetMeta() {
793
+ if (ruleTargetColId.value) {
794
+ return columns.value.find((c) => c.id === ruleTargetColId.value)?.meta;
795
+ }
796
+ const ac = selection.activeCell.value;
797
+ if (!ac) return void 0;
798
+ return getCellEntry(ac.colIdx, ac.rowIdx)?.meta ?? columns.value[ac.colIdx]?.meta;
799
+ }
800
+ const activeColumnLabel = computed(() => {
801
+ if (ruleTargetColId.value) {
802
+ return columns.value.find((c) => c.id === ruleTargetColId.value)?.label ?? "";
803
+ }
804
+ const ac = selection.activeCell.value;
805
+ if (!ac) return "";
806
+ return columns.value[ac.colIdx]?.label ?? sheetsView.indexToColLetter(ac.colIdx);
807
+ });
808
+ const activeCellRules = computed(
809
+ () => ruleTargetMeta()?.cfRules ?? []
810
+ );
811
+ const activeValidation = computed(
812
+ () => ruleTargetMeta()?.validation
813
+ );
814
+ function openConditional() {
815
+ ruleTargetColId.value = null;
816
+ if (selection.activeCell.value) conditionalOpen.value = true;
817
+ }
818
+ function openValidation() {
819
+ ruleTargetColId.value = null;
820
+ if (selection.activeCell.value) validationOpen.value = true;
821
+ }
822
+ function openColumnConditional(colIdx) {
823
+ ruleTargetColId.value = columns.value[colIdx]?.id ?? null;
824
+ if (ruleTargetColId.value) conditionalOpen.value = true;
825
+ }
826
+ function openColumnValidation(colIdx) {
827
+ ruleTargetColId.value = columns.value[colIdx]?.id ?? null;
828
+ if (ruleTargetColId.value) validationOpen.value = true;
829
+ }
830
+ function saveConditional(rules) {
831
+ const val = rules.length ? rules : void 0;
832
+ if (ruleTargetColId.value) tree.updateMeta(ruleTargetColId.value, { cfRules: val });
833
+ else applyFormatting("cfRules", val);
834
+ }
835
+ function saveValidation(spec) {
836
+ if (ruleTargetColId.value) tree.updateMeta(ruleTargetColId.value, { validation: spec });
837
+ else applyFormatting("validation", spec);
838
+ }
724
839
  function onGridKeydown(e) {
840
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "f") {
841
+ e.preventDefault();
842
+ openFind();
843
+ return;
844
+ }
725
845
  selection.onKeydown(e);
726
846
  }
727
847
  void nextTick;
@@ -758,6 +878,28 @@ defineExpose({ connectedUsers });
758
878
  @set-bg-color="(c) => applyFormatting('bgColor', c)"
759
879
  @set-align="(a) => applyFormatting('align', a)"
760
880
  @set-number-format="(f) => applyFormatting('numberFormat', f)"
881
+ @open-find="openFind"
882
+ @open-conditional="openConditional"
883
+ @open-validation="openValidation"
884
+ />
885
+
886
+ <!-- Find & replace overlay -->
887
+ <ASheetsFindPanel
888
+ :visible="findVisible"
889
+ :editable="canWrite"
890
+ :match-count="findMatchList.length"
891
+ :current-index="findIndex"
892
+ :query="findQuery"
893
+ :replacement="findReplacement"
894
+ :options="findOptions"
895
+ @update:query="findQuery = $event"
896
+ @update:replacement="findReplacement = $event"
897
+ @update:options="findOptions = $event"
898
+ @next="findNext"
899
+ @prev="findPrev"
900
+ @replace="replaceCurrent"
901
+ @replace-all="replaceAll"
902
+ @close="closeFind"
761
903
  />
762
904
 
763
905
  <!-- Empty state -->
@@ -765,7 +907,10 @@ defineExpose({ connectedUsers });
765
907
  v-if="columns.length === 0"
766
908
  class="flex-1 flex flex-col items-center justify-center text-(--ui-text-dimmed)"
767
909
  >
768
- <UIcon name="i-lucide-grid-3x3" class="size-12 mb-3 opacity-20" />
910
+ <UIcon
911
+ name="i-lucide-grid-3x3"
912
+ class="size-12 mb-3 opacity-20"
913
+ />
769
914
  <p class="text-sm font-medium">
770
915
  {{ locale.emptyTitle }}
771
916
  </p>
@@ -861,5 +1006,19 @@ defineExpose({ connectedUsers });
861
1006
  :following-user="followingUser"
862
1007
  @close="closePanel"
863
1008
  />
1009
+
1010
+ <ASheetsConditionalModal
1011
+ v-model:open="conditionalOpen"
1012
+ :column-label="activeColumnLabel"
1013
+ :rules="activeCellRules"
1014
+ @save="saveConditional"
1015
+ />
1016
+
1017
+ <ASheetsValidationModal
1018
+ v-model:open="validationOpen"
1019
+ :column-label="activeColumnLabel"
1020
+ :spec="activeValidation"
1021
+ @save="saveValidation"
1022
+ />
864
1023
  </div>
865
1024
  </template>
@@ -1,4 +1,5 @@
1
1
  import type { TreeEntry } from '../../../composables/useChildTree.js';
2
+ import type { DocPageMeta } from '../../../types.js';
2
3
  type __VLS_Props = {
3
4
  colIdx: number;
4
5
  rowIdx: number;
@@ -8,6 +9,8 @@ type __VLS_Props = {
8
9
  height: number;
9
10
  value: string;
10
11
  entry: TreeEntry | undefined;
12
+ /** Owning column document's meta — supplies format/validation/cf defaults. */
13
+ columnMeta?: DocPageMeta;
11
14
  isActive: boolean | undefined;
12
15
  isSelected: boolean;
13
16
  isCut: boolean;
@@ -1,5 +1,7 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
+ import { formatCellDisplay, isNegativeRed, conditionalStyle } from "../../../composables/useSheetsFormat";
4
+ import { isCellValid } from "../../../composables/useSheetsValidation";
3
5
  const props = defineProps({
4
6
  colIdx: { type: Number, required: true },
5
7
  rowIdx: { type: Number, required: true },
@@ -9,6 +11,7 @@ const props = defineProps({
9
11
  height: { type: Number, required: true },
10
12
  value: { type: String, required: true },
11
13
  entry: { type: null, required: true },
14
+ columnMeta: { type: Object, required: false },
12
15
  isActive: { type: Boolean, required: true, skipCheck: true },
13
16
  isSelected: { type: Boolean, required: true },
14
17
  isCut: { type: Boolean, required: true },
@@ -20,33 +23,15 @@ const props = defineProps({
20
23
  editable: { type: Boolean, required: true }
21
24
  });
22
25
  defineEmits(["pointerdown", "pointermove", "pointerup", "pointercancel", "pointerenter", "contextmenu", "dblclick"]);
23
- const _currencyFmt = new Intl.NumberFormat(void 0, { style: "currency", currency: "USD" });
24
- const _percentFmtCache = /* @__PURE__ */ new Map();
25
- function _getPercentFmt(decimals) {
26
- let fmt = _percentFmtCache.get(decimals);
27
- if (!fmt) {
28
- fmt = new Intl.NumberFormat(void 0, { style: "percent", minimumFractionDigits: decimals });
29
- _percentFmtCache.set(decimals, fmt);
30
- }
31
- return fmt;
32
- }
33
- function formatCellDisplay(value, meta) {
34
- if (!meta?.numberFormat || meta.numberFormat === "general") return value;
35
- const num = Number(value);
36
- if (value === "" || isNaN(num)) return value;
37
- switch (meta.numberFormat) {
38
- case "number":
39
- return num.toFixed(meta.numberDecimals ?? 2);
40
- case "currency":
41
- return _currencyFmt.format(num);
42
- case "percent":
43
- return _getPercentFmt(meta.numberDecimals ?? 0).format(num);
44
- case "date":
45
- return new Date(num).toLocaleDateString();
46
- default:
47
- return value;
48
- }
49
- }
26
+ const displayValue = computed(
27
+ () => formatCellDisplay(props.value, props.entry?.meta, props.columnMeta)
28
+ );
29
+ const conditional = computed(
30
+ () => conditionalStyle(props.value, props.entry?.meta, props.columnMeta)
31
+ );
32
+ const isInvalid = computed(
33
+ () => !isCellValid(props.value, props.entry?.meta, props.columnMeta)
34
+ );
50
35
  const cellStyle = computed(() => {
51
36
  const base = {
52
37
  top: `${props.top}px`,
@@ -71,13 +56,17 @@ const cellStyle = computed(() => {
71
56
  });
72
57
  const contentStyle = computed(() => {
73
58
  const meta = props.entry?.meta;
74
- if (!meta) return void 0;
75
59
  const s = {};
76
- if (meta.bold) s.fontWeight = "bold";
77
- if (meta.italic) s.fontStyle = "italic";
78
- if (meta.textColor) s.color = meta.textColor;
79
- if (meta.bgColor) s.backgroundColor = meta.bgColor;
80
- if (meta.align) s.textAlign = meta.align;
60
+ if (meta?.bold) s.fontWeight = "bold";
61
+ if (meta?.italic) s.fontStyle = "italic";
62
+ if (meta?.textColor) s.color = meta.textColor;
63
+ if (meta?.bgColor) s.backgroundColor = meta.bgColor;
64
+ if (meta?.align) s.textAlign = meta.align;
65
+ const cf = conditional.value;
66
+ if (cf?.bg) s.backgroundColor = cf.bg;
67
+ if (cf?.fg) s.color = cf.fg;
68
+ if (cf?.bold) s.fontWeight = "bold";
69
+ if (isNegativeRed(props.value, meta, props.columnMeta)) s.color = "var(--ui-error, #ef4444)";
81
70
  return Object.keys(s).length ? s : void 0;
82
71
  });
83
72
  </script>
@@ -111,13 +100,20 @@ const contentStyle = computed(() => {
111
100
  {{ remote.name }}
112
101
  </span>
113
102
 
103
+ <!-- Invalid-value indicator (red corner triangle) -->
104
+ <span
105
+ v-if="isInvalid"
106
+ class="absolute top-0 right-0 size-0 border-t-[6px] border-l-[6px] border-t-(--ui-error) border-l-transparent pointer-events-none z-20"
107
+ title="Value fails validation"
108
+ />
109
+
114
110
  <!-- Display value -->
115
111
  <div
116
112
  v-if="!isEditing"
117
113
  class="w-full h-full flex items-center px-1.5 text-sm text-(--ui-text) truncate"
118
114
  :style="contentStyle"
119
115
  >
120
- {{ formatCellDisplay(value, entry?.meta) }}
116
+ {{ displayValue }}
121
117
  </div>
122
118
  </div>
123
119
  </template>
@@ -1,4 +1,5 @@
1
1
  import type { TreeEntry } from '../../../composables/useChildTree.js';
2
+ import type { DocPageMeta } from '../../../types.js';
2
3
  type __VLS_Props = {
3
4
  colIdx: number;
4
5
  rowIdx: number;
@@ -8,6 +9,8 @@ type __VLS_Props = {
8
9
  height: number;
9
10
  value: string;
10
11
  entry: TreeEntry | undefined;
12
+ /** Owning column document's meta — supplies format/validation/cf defaults. */
13
+ columnMeta?: DocPageMeta;
11
14
  isActive: boolean | undefined;
12
15
  isSelected: boolean;
13
16
  isCut: boolean;
@@ -0,0 +1,15 @@
1
+ import type { SheetsConditionalRule } from '../../../types.js';
2
+ type __VLS_Props = {
3
+ open: boolean;
4
+ columnLabel: string;
5
+ rules: SheetsConditionalRule[];
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ "update:open": (value: boolean) => any;
9
+ save: (rules: SheetsConditionalRule[]) => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
12
+ onSave?: ((rules: SheetsConditionalRule[]) => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;