@nocode-factory/sanity-kit 2.0.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.
Files changed (95) hide show
  1. package/bin/ncf-kit.mjs +201 -0
  2. package/dist/index.d.ts +1643 -0
  3. package/dist/index.js +6632 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/web-server.d.ts +46 -0
  6. package/dist/web-server.js +51 -0
  7. package/dist/web-server.js.map +1 -0
  8. package/dist/web.d.ts +27 -0
  9. package/dist/web.js +117 -0
  10. package/dist/web.js.map +1 -0
  11. package/package.json +90 -0
  12. package/scripts/use-client.mjs +20 -0
  13. package/src/config/defaults.ts +74 -0
  14. package/src/config/resolve.ts +153 -0
  15. package/src/config/types.ts +290 -0
  16. package/src/config/validate.ts +193 -0
  17. package/src/context/BoardLayoutContext.tsx +24 -0
  18. package/src/context/KitContext.tsx +30 -0
  19. package/src/context/PreviewTargetContext.tsx +27 -0
  20. package/src/hooks/useAnnotations.ts +60 -0
  21. package/src/hooks/useBoardLayout.ts +398 -0
  22. package/src/hooks/useColumnOptions.ts +47 -0
  23. package/src/hooks/useDocumentColumns.ts +61 -0
  24. package/src/hooks/useHistory.ts +89 -0
  25. package/src/hooks/useInternalColumns.ts +19 -0
  26. package/src/hooks/useKitClient.ts +15 -0
  27. package/src/hooks/useOccurrences.ts +62 -0
  28. package/src/hooks/usePageContents.ts +65 -0
  29. package/src/hooks/usePages.ts +41 -0
  30. package/src/hooks/usePreviewTarget.ts +162 -0
  31. package/src/hooks/useQueryData.ts +103 -0
  32. package/src/hooks/useRegistration.ts +50 -0
  33. package/src/index.ts +280 -0
  34. package/src/lib/blocks.ts +38 -0
  35. package/src/lib/colors.ts +103 -0
  36. package/src/lib/columns.ts +137 -0
  37. package/src/lib/diff.ts +200 -0
  38. package/src/lib/elkLayout.ts +124 -0
  39. package/src/lib/graph.ts +238 -0
  40. package/src/lib/grouping.ts +116 -0
  41. package/src/lib/links.ts +70 -0
  42. package/src/lib/occurrences.ts +93 -0
  43. package/src/lib/pageThumbnail.ts +43 -0
  44. package/src/lib/pages.ts +199 -0
  45. package/src/lib/paths.ts +68 -0
  46. package/src/lib/query.ts +113 -0
  47. package/src/lib/schemaColumns.ts +162 -0
  48. package/src/lib/schemaTypes.ts +75 -0
  49. package/src/lib/sectionsMap.ts +83 -0
  50. package/src/lib/service.ts +88 -0
  51. package/src/lib/siteRoutes.ts +43 -0
  52. package/src/lib/status.ts +122 -0
  53. package/src/lib/studioLinks.ts +137 -0
  54. package/src/schema/boardLayout.ts +190 -0
  55. package/src/tools/components/BlockCard.tsx +79 -0
  56. package/src/tools/components/ComponentsTool.tsx +171 -0
  57. package/src/tools/components/map/SectionNode.tsx +109 -0
  58. package/src/tools/components/map/SectionsMap.tsx +339 -0
  59. package/src/tools/createToolComponent.tsx +67 -0
  60. package/src/tools/history/ChangeRow.tsx +87 -0
  61. package/src/tools/history/DiffPanel.tsx +227 -0
  62. package/src/tools/history/HistoryTool.tsx +230 -0
  63. package/src/tools/more/MoreTool.tsx +82 -0
  64. package/src/tools/pages/ColumnHeader.tsx +216 -0
  65. package/src/tools/pages/ColumnVisibility.tsx +173 -0
  66. package/src/tools/pages/FieldValue.tsx +327 -0
  67. package/src/tools/pages/PagesTable.tsx +394 -0
  68. package/src/tools/pages/PagesTool.tsx +333 -0
  69. package/src/tools/pages/PagesToolbar.tsx +53 -0
  70. package/src/tools/pages/PathCell.tsx +71 -0
  71. package/src/tools/pages/PreviewTarget.tsx +226 -0
  72. package/src/tools/pages/TagCell.tsx +124 -0
  73. package/src/tools/pages/ViewTabs.tsx +57 -0
  74. package/src/tools/pages/board/BoardView.tsx +661 -0
  75. package/src/tools/pages/board/PageNode.tsx +306 -0
  76. package/src/tools/pages/board/PagePanel.tsx +228 -0
  77. package/src/tools/presentation/PreviewHeader.tsx +75 -0
  78. package/src/tools/shared/AnnotationNode.tsx +126 -0
  79. package/src/ui/ActorName.tsx +20 -0
  80. package/src/ui/ConfigIssues.tsx +41 -0
  81. package/src/ui/InlineCode.tsx +22 -0
  82. package/src/ui/Popover.tsx +85 -0
  83. package/src/ui/ProjectStatusNotice.tsx +58 -0
  84. package/src/ui/QueryError.tsx +16 -0
  85. package/src/ui/QuietInput.tsx +64 -0
  86. package/src/ui/StatusBadge.tsx +11 -0
  87. package/src/ui/ToolPlaceholder.tsx +23 -0
  88. package/src/ui/formatDate.ts +14 -0
  89. package/src/ui/tokens.ts +54 -0
  90. package/src/version.ts +5 -0
  91. package/src/web/PreviewBanner.tsx +115 -0
  92. package/src/web/draftModeToggle.ts +56 -0
  93. package/src/web/environment.ts +21 -0
  94. package/src/web/index.ts +15 -0
  95. package/src/web/server.ts +11 -0
@@ -0,0 +1,124 @@
1
+ import {Box, Flex, Stack, Text} from '@sanity/ui'
2
+ import {CheckmarkIcon} from '@sanity/icons/Checkmark'
3
+ import {InlinePopover} from '../../ui/Popover'
4
+ import {CELL} from '../../ui/tokens'
5
+ import type {NcfBoardTag} from '../../config/types'
6
+
7
+ export interface TagCellProps {
8
+ tag: string | null
9
+ tags: readonly NcfBoardTag[]
10
+ onChange: (tag: string | null) => void
11
+ }
12
+
13
+ /**
14
+ * Étiquette d'une page, modifiable sur place.
15
+ *
16
+ * Pas de menu déroulant permanent : une centaine de lignes en porteraient
17
+ * autant, et le tableau ne se lirait plus. La cellule affiche la valeur, et
18
+ * ouvre un choix au clic.
19
+ */
20
+ export function TagCell(props: TagCellProps) {
21
+ const {tag, tags, onChange} = props
22
+ const current = tags.find((option) => option.id === tag)
23
+
24
+ return (
25
+ <InlinePopover
26
+ width={180}
27
+ trigger={({toggle}) => (
28
+ <Flex
29
+ align="center"
30
+ gap={2}
31
+ onClick={toggle}
32
+ style={{...CELL, cursor: 'pointer'}}
33
+ title="Changer l’étiquette"
34
+ >
35
+ {current ? (
36
+ <>
37
+ <Box
38
+ style={{
39
+ width: 6,
40
+ height: 6,
41
+ borderRadius: '50%',
42
+ background: current.color,
43
+ flex: 'none',
44
+ }}
45
+ />
46
+ <Text size={0} textOverflow="ellipsis">
47
+ {current.label}
48
+ </Text>
49
+ </>
50
+ ) : (
51
+ <Text size={0} muted>
52
+ —
53
+ </Text>
54
+ )}
55
+ </Flex>
56
+ )}
57
+ >
58
+ {({close}) => (
59
+ <Stack gap={0}>
60
+ <TagOption
61
+ label="Sans étiquette"
62
+ selected={!current}
63
+ onClick={() => {
64
+ onChange(null)
65
+ close()
66
+ }}
67
+ />
68
+ {tags.map((option) => (
69
+ <TagOption
70
+ key={option.id}
71
+ label={option.label}
72
+ color={option.color}
73
+ selected={option.id === tag}
74
+ onClick={() => {
75
+ onChange(option.id)
76
+ close()
77
+ }}
78
+ />
79
+ ))}
80
+ </Stack>
81
+ )}
82
+ </InlinePopover>
83
+ )
84
+ }
85
+
86
+ function TagOption(props: {
87
+ label: string
88
+ color?: string
89
+ selected: boolean
90
+ onClick: () => void
91
+ }) {
92
+ return (
93
+ <Flex
94
+ align="center"
95
+ gap={2}
96
+ padding={2}
97
+ onClick={props.onClick}
98
+ style={{cursor: 'pointer', borderRadius: 3}}
99
+ onMouseEnter={(event) => {
100
+ event.currentTarget.style.background = 'var(--card-muted-bg-color, rgba(127,127,127,0.12))'
101
+ }}
102
+ onMouseLeave={(event) => {
103
+ event.currentTarget.style.background = 'transparent'
104
+ }}
105
+ >
106
+ <Box
107
+ style={{
108
+ width: 8,
109
+ height: 8,
110
+ borderRadius: '50%',
111
+ background: props.color ?? 'transparent',
112
+ border: props.color ? 'none' : '1px solid var(--card-border-color, rgba(127,127,127,0.4))',
113
+ flex: 'none',
114
+ }}
115
+ />
116
+ <Box flex={1} style={{minWidth: 0}}>
117
+ <Text size={1} textOverflow="ellipsis">
118
+ {props.label}
119
+ </Text>
120
+ </Box>
121
+ {props.selected && <CheckmarkIcon style={{fontSize: 14, opacity: 0.7}} />}
122
+ </Flex>
123
+ )
124
+ }
@@ -0,0 +1,57 @@
1
+ import {Box, Button, Flex, Text} from '@sanity/ui'
2
+ import {DocumentsIcon} from '@sanity/icons/Documents'
3
+ import {ProjectsIcon} from '@sanity/icons/Projects'
4
+ import {CircleIcon} from '@sanity/icons/Circle'
5
+
6
+ export type PagesView = 'list' | 'tree' | 'brain'
7
+
8
+ const TABS: {value: PagesView; label: string; icon: typeof DocumentsIcon}[] = [
9
+ {value: 'list', label: 'Liste', icon: DocumentsIcon},
10
+ {value: 'tree', label: 'Arbo', icon: ProjectsIcon},
11
+ {value: 'brain', label: 'Cerveau', icon: CircleIcon},
12
+ ]
13
+
14
+ export interface ViewTabsProps {
15
+ view: PagesView
16
+ onChange: (view: PagesView) => void
17
+ }
18
+
19
+ /**
20
+ * Trois façons de regarder le même ensemble de pages, au même niveau.
21
+ * L'arborescence et le cerveau étaient auparavant imbriqués dans « Board » :
22
+ * un niveau de navigation pour rien.
23
+ */
24
+ export function ViewTabs(props: ViewTabsProps) {
25
+ return (
26
+ <Flex gap={1} role="tablist" aria-label="Vue des pages">
27
+ {TABS.map((tab) => {
28
+ const active = props.view === tab.value
29
+ return (
30
+ <Button
31
+ key={tab.value}
32
+ role="tab"
33
+ aria-selected={active}
34
+ mode={active ? 'default' : 'bleed'}
35
+ tone={active ? 'primary' : 'default'}
36
+ fontSize={1}
37
+ padding={2}
38
+ icon={tab.icon}
39
+ text={tab.label}
40
+ onClick={() => props.onChange(tab.value)}
41
+ />
42
+ )
43
+ })}
44
+ </Flex>
45
+ )
46
+ }
47
+
48
+ /** Libellé discret d'un sélecteur, pour qu'il ne s'annonce pas lui-même. */
49
+ export function FieldLabel(props: {children: string}) {
50
+ return (
51
+ <Box paddingBottom={1}>
52
+ <Text size={0} muted weight="medium">
53
+ {props.children}
54
+ </Text>
55
+ </Box>
56
+ )
57
+ }