@crisp-ui-kit/crisp 0.51.0 → 0.52.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 (43) hide show
  1. package/dist/cjs/components/datatable/datatable.js +98 -24
  2. package/dist/cjs/core/caret-rect.js +73 -0
  3. package/dist/cjs/core/index.js +7 -1
  4. package/dist/cjs/core/mention.js +32 -0
  5. package/dist/cjs/core/use-mention-trigger.js +124 -0
  6. package/dist/cjs/product/recordpanel/recordpanel.js +13 -81
  7. package/dist/cjs/product/recordpanel/recordpanel.recipe.js +53 -44
  8. package/dist/cjs/product/recordstable/editable-field.js +11 -8
  9. package/dist/cjs/product/recordstable/recordstable.tag.js +8 -3
  10. package/dist/cjs/product/richtext/index.js +2 -1
  11. package/dist/cjs/product/richtext/richtext.js +440 -23
  12. package/dist/cjs/product/richtext/richtext.recipe.js +59 -9
  13. package/dist/esm/components/datatable/datatable.js +98 -24
  14. package/dist/esm/core/caret-rect.js +70 -0
  15. package/dist/esm/core/index.js +3 -0
  16. package/dist/esm/core/mention.js +29 -0
  17. package/dist/esm/core/use-mention-trigger.js +88 -0
  18. package/dist/esm/product/recordpanel/index.js +1 -1
  19. package/dist/esm/product/recordpanel/recordpanel.js +15 -83
  20. package/dist/esm/product/recordpanel/recordpanel.recipe.js +54 -45
  21. package/dist/esm/product/recordstable/editable-field.js +11 -8
  22. package/dist/esm/product/recordstable/recordstable.tag.js +8 -3
  23. package/dist/esm/product/richtext/index.js +1 -1
  24. package/dist/esm/product/richtext/richtext.js +439 -22
  25. package/dist/esm/product/richtext/richtext.recipe.js +60 -10
  26. package/dist/recordpanel.css +47 -41
  27. package/dist/recordpanel.layered.css +47 -41
  28. package/dist/richtext.css +31 -5
  29. package/dist/richtext.layered.css +31 -5
  30. package/dist/styles.css +79 -47
  31. package/dist/styles.layered.css +79 -47
  32. package/dist/types/components/datatable/datatable.d.ts +11 -10
  33. package/dist/types/core/caret-rect.d.ts +16 -0
  34. package/dist/types/core/index.d.ts +3 -0
  35. package/dist/types/core/mention.d.ts +27 -0
  36. package/dist/types/core/use-mention-trigger.d.ts +41 -0
  37. package/dist/types/product/recordpanel/index.d.ts +1 -1
  38. package/dist/types/product/recordpanel/recordpanel.d.ts +81 -27
  39. package/dist/types/product/recordstable/editable-field.d.ts +11 -8
  40. package/dist/types/product/recordstable/recordstable.tag.d.ts +8 -3
  41. package/dist/types/product/richtext/index.d.ts +1 -1
  42. package/dist/types/product/richtext/richtext.d.ts +168 -7
  43. package/package.json +1 -1
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.recordpanelRecipe = void 0;
4
4
  const core_1 = require("../../core");
5
5
  const tokens_1 = require("../../tokens");
6
- const recordstable_tag_1 = require("../recordstable/recordstable.tag");
7
6
  // A right-side record peek panel — slides in over the main content to show one
8
- // record's fields, the way a row peek panel opens. Positioned absolutely inside a
9
- // relative container (the app main area); slides in via @starting-style.
7
+ // record's Highlights and Activity, the way Attio's own peek does. Positioned
8
+ // absolutely inside a relative container (the app main area); slides in via
9
+ // @starting-style.
10
10
  const config = (0, core_1.defineRecipe)({
11
11
  name: "recordpanel",
12
12
  base: `
@@ -21,53 +21,60 @@ const config = (0, core_1.defineRecipe)({
21
21
  @starting-style { transform: translateX(calc(100% + ${tokens_1.contract.space["2"]})); }
22
22
  & * { box-sizing: border-box; }
23
23
 
24
- & .crisp-recordpanel-header { display: flex; align-items: center; gap: ${tokens_1.contract.space["2"]}; height: 52px; flex-shrink: 0; padding: 0 ${tokens_1.contract.space["3"]}; border-bottom: 1px solid ${tokens_1.contract.borderSubtle}; }
24
+ /* #448: measured live on app.attio.com's peek -- a toolbar row above
25
+ the identity header: Close, then Previous/Next, on the left; "Open
26
+ record" on the right. 49px tall, 8px/10px padding, a hairline border
27
+ beneath (the same borderSubtle every other panel/row edge here
28
+ already uses). Close keeps the existing transparent ghost button;
29
+ Previous/Next/Open record are a distinct field-elevation style
30
+ (white fill, e.field's own ring+shadow, solid icon) -- measured as
31
+ genuinely different chrome from Close, not a reuse. */
32
+ & .crisp-recordpanel-toolbar { display: flex; align-items: center; height: 49px; flex-shrink: 0; padding: ${tokens_1.contract.space["2"]} ${tokens_1.contract.space["2.5"]}; border-bottom: 1px solid ${tokens_1.contract.borderSubtle}; }
33
+ & .crisp-recordpanel-toolbar-spacer { flex: 1; }
34
+ & .crisp-recordpanel-pager { display: flex; align-items: center; gap: ${tokens_1.contract.space["1.5"]}; margin-inline-start: ${tokens_1.contract.space["3"]}; }
35
+ & .crisp-recordpanel-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0; padding: 0; border: none; border-radius: ${tokens_1.contract.radius.md}; background: transparent; color: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 55%, transparent); font-family: inherit; cursor: pointer; transition: background-color .12s; }
36
+ & .crisp-recordpanel-iconbtn:hover { background: ${tokens_1.contract.bgRaised}; color: ${tokens_1.contract.fgPrimary}; }
37
+ & .crisp-recordpanel-navbtn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0; padding: 0; border: none; border-radius: ${tokens_1.contract.radius.md}; background: ${tokens_1.contract.bgSurface}; box-shadow: ${tokens_1.elevation.field}; color: ${tokens_1.contract.fgPrimary}; font-family: inherit; cursor: pointer; }
38
+ & .crisp-recordpanel-navbtn:hover:not(:disabled) { background: ${tokens_1.contract.bgRaised}; }
39
+ & .crisp-recordpanel-navbtn:disabled { opacity: 0.4; cursor: not-allowed; }
40
+
41
+ & .crisp-recordpanel-header { display: flex; align-items: center; gap: ${tokens_1.contract.space["2"]}; height: 52px; flex-shrink: 0; padding: 0 ${tokens_1.contract.space["3"]}; }
25
42
  & .crisp-recordpanel-fav { width: 22px; height: ${tokens_1.contract.size.chip}; border-radius: ${tokens_1.contract.radius.sm}; flex-shrink: 0; object-fit: cover; background: ${tokens_1.contract.bgRaised}; }
26
43
  & .crisp-recordpanel-title { flex: 1; min-width: 0; font-size: ${tokens_1.contract.text.xl}; font-weight: ${tokens_1.contract.weight.semibold}; letter-spacing: -0.2px; color: ${tokens_1.contract.fgPrimary}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
27
- & .crisp-recordpanel-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0; padding: 0; border: none; border-radius: ${tokens_1.contract.radius.md}; background: transparent; color: ${tokens_1.contract.fgMuted}; font-family: inherit; cursor: pointer; transition: background-color .12s; }
28
- & .crisp-recordpanel-iconbtn:hover { background: ${tokens_1.contract.bgRaised}; color: ${tokens_1.contract.fgPrimary}; }
29
44
 
30
45
  & .crisp-recordpanel-body { flex: 1; min-height: 0; overflow-y: auto; padding: ${tokens_1.contract.space["2"]} ${tokens_1.contract.space["3"]}; }
31
- & .crisp-recordpanel-sectionlabel { font-size: ${tokens_1.contract.text.sm}; font-weight: ${tokens_1.contract.weight.medium}; color: ${tokens_1.contract.fgMuted}; padding: ${tokens_1.contract.space["2"]} ${tokens_1.contract.space["1"]} ${tokens_1.contract.space["1"]}; }
32
- & .crisp-recordpanel-field { display: flex; align-items: flex-start; gap: ${tokens_1.contract.space["2"]}; min-height: 32px; padding: ${tokens_1.contract.space["1"]} ${tokens_1.contract.space["1"]}; border-radius: ${tokens_1.contract.radius.md}; }
33
- & .crisp-recordpanel-field:hover { background: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 3%, transparent); }
34
- & .crisp-recordpanel-field-label { display: flex; align-items: center; gap: ${tokens_1.contract.space["1.5"]}; width: 132px; flex-shrink: 0; padding-top: 3px; color: ${tokens_1.contract.fgMuted}; font-size: ${tokens_1.contract.text.md}; }
35
- & .crisp-recordpanel-field-label svg { flex-shrink: 0; }
36
- & .crisp-recordpanel-field-value { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: ${tokens_1.contract.space["1"]}; padding-top: 3px; font-size: ${tokens_1.contract.text.lg}; color: ${tokens_1.contract.fgPrimary}; }
37
- & .crisp-recordpanel-field-value[data-editable] { cursor: pointer; }
38
- /* the click-to-edit trigger is a real <button> (keyboard-operable),
39
- reset back to plain inline text and made a flex-wrap container of its
40
- own -- FieldValue can render several chips (tags), which still need
41
- to wrap the way they did before this had a button around them at
42
- all. It wraps only FieldValue, never the error slot beside it (see
43
- the component's own comment) -- NOT \`display: contents\`, which
44
- drops a button's accessible semantics in some engines. */
45
- & .crisp-recordpanel-edit-trigger { display: inline-flex; flex-wrap: wrap; align-items: center; gap: ${tokens_1.contract.space["1"]}; margin: 0; padding: 0; border: none; background: none; text-align: start; font: inherit; color: inherit; cursor: pointer; }
46
- & .crisp-recordpanel-empty { color: ${tokens_1.contract.fgMuted}; }
47
46
 
48
- /* #431: measured live on app.attio.com's record side panel -- clicking a
49
- field's value opens a plain, borderless field exactly filling the
50
- value's own box (no border, no background, no box-shadow), same font
51
- as the value it replaces (hence \`font: inherit\`, not a restated
52
- size/weight). A field row's own hover tint above already carries the
53
- "this is interactive" affordance; the pending/error treatment isn't
54
- Attio-measured -- it reuses the same tokens DataTable's identical
55
- states already use (opacity 0.5, \`bgDanger\`), per #385/#430. */
56
- & .crisp-recordpanel-edit { display: block; width: 100%; margin: 0; padding: 0; border: none; border-radius: ${tokens_1.contract.radius.sm}; background: none; box-shadow: none; outline: none; font: inherit; color: inherit; }
57
- /* not Attio-measured (its own field shows no focus ring either, caret
58
- only) -- kept for real keyboard users, the same brand ring every
59
- other crisp field already shows on focus (DataTable's identical
60
- .crisp-datatable-edit:focus, e.g.). */
61
- & .crisp-recordpanel-edit:focus { box-shadow: inset 0 0 0 1px ${tokens_1.contract.bgBrandSolid}; }
62
- & .crisp-recordpanel-edit:disabled { opacity: 0.5; cursor: not-allowed; }
63
- & .crisp-recordpanel-edit-pending { flex-shrink: 0; color: ${tokens_1.contract.fgMuted}; }
64
- & .crisp-recordpanel-edit-error { flex-basis: 100%; margin-top: ${tokens_1.contract.space["0.5"]}; font-size: ${tokens_1.contract.text.sm}; color: ${tokens_1.contract.bgDanger}; }
65
- & .crisp-recordpanel-edit-picker { display: flex; align-items: center; gap: ${tokens_1.contract.space["1"]}; width: 100%; }
66
- & .crisp-recordpanel-edit-picker .crisp-select-trigger { flex: 1; min-width: 0; }
47
+ /* #448: measured live on app.attio.com's peek (hover a Companies row,
48
+ click "Open preview"). Section label reads identically for both
49
+ Highlights and Activity: 14px/500, the same 63%-of-fgPrimary mix
50
+ RecordPage's own field-label already uses (product/recordpage's
51
+ .crisp-recordpage-field-label) -- one more surface landing on the
52
+ same measured "muted section heading" colour. */
53
+ & .crisp-recordpanel-section { padding: ${tokens_1.contract.space["2"]} ${tokens_1.contract.space["1"]} 0; }
54
+ & .crisp-recordpanel-section-head { display: flex; align-items: center; justify-content: space-between; gap: ${tokens_1.contract.space["2"]}; height: 20px; margin-bottom: ${tokens_1.contract.space["2"]}; }
55
+ & .crisp-recordpanel-section-label { font-size: ${tokens_1.contract.text.lg}; font-weight: ${tokens_1.contract.weight.medium}; color: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 63%, transparent); }
56
+ /* "View all" -- measured 10px/400, a lighter mix than the section label
57
+ (55%, not 63%) -- its own distinct, honestly-measured value, not a
58
+ reuse of a nearby one that happened to be close. */
59
+ & .crisp-recordpanel-section-action { border: none; background: none; padding: 0; font-family: inherit; font-size: 10px; font-weight: ${tokens_1.contract.weight.regular}; color: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 55%, transparent); cursor: pointer; }
60
+ & .crisp-recordpanel-section-action:hover { color: ${tokens_1.contract.fgPrimary}; }
67
61
 
68
- ${recordstable_tag_1.recordTagCss}
69
- & .crisp-recordpanel-link { color: ${tokens_1.contract.bgBrandSolid}; text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
70
- & .crisp-recordpanel-link:hover { text-decoration: underline; }
62
+ /* Highlights: a 2-column grid of label+icon+value cards, no card
63
+ chrome at all (no border/background/radius/shadow -- confirmed on
64
+ the live DOM: every highlight's computed style is fully transparent).
65
+ 8px row/column gap; two rows measured "233x86" inside 473px content
66
+ width is exactly (473 - 8) / 2. */
67
+ & .crisp-recordpanel-highlights { display: grid; grid-template-columns: 1fr 1fr; gap: ${tokens_1.contract.space["2"]}; }
68
+ & .crisp-recordpanel-highlight { display: flex; flex-direction: column; gap: ${tokens_1.contract.space["1.5"]}; min-width: 0; }
69
+ & .crisp-recordpanel-highlight-label { display: flex; align-items: center; gap: ${tokens_1.contract.space["1"]}; font-size: ${tokens_1.contract.text.sm}; font-weight: ${tokens_1.contract.weight.medium}; color: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 63%, transparent); }
70
+ & .crisp-recordpanel-highlight-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
71
+ & .crisp-recordpanel-highlight-label svg { flex-shrink: 0; color: ${tokens_1.contract.fgMuted}; }
72
+ & .crisp-recordpanel-highlight-value { font-size: ${tokens_1.contract.text.lg}; font-weight: ${tokens_1.contract.weight.medium}; color: ${tokens_1.contract.fgPrimary}; overflow: hidden; text-overflow: ellipsis; }
73
+
74
+ /* Activity is a consumer-supplied slot (crisp has no activity-feed
75
+ model of its own to render) -- this only wraps it with the measured
76
+ section heading above. */
77
+ & .crisp-recordpanel-activity { font-size: ${tokens_1.contract.text.lg}; }
71
78
 
72
79
  /* #329: an optional slot for record actions (e.g. Edit). Reuses the
73
80
  header's own measured values rather than inventing new ones -- the
@@ -76,6 +83,8 @@ const config = (0, core_1.defineRecipe)({
76
83
  edge), and the header/body gap (space.2) for its own vertical padding
77
84
  and for spacing between whatever it's given. */
78
85
  & .crisp-recordpanel-footer { flex-shrink: 0; display: flex; align-items: center; gap: ${tokens_1.contract.space["2"]}; padding: ${tokens_1.contract.space["2"]} ${tokens_1.contract.space["3"]}; border-top: 1px solid ${tokens_1.contract.borderSubtle}; }
86
+
87
+ ${core_1.rtlFlipCss}
79
88
  `,
80
89
  variants: {},
81
90
  defaultVariants: {},
@@ -37,18 +37,21 @@ exports.useEditableField = useEditableField;
37
37
  exports.editableInputType = editableInputType;
38
38
  const React = __importStar(require("react"));
39
39
  /**
40
- * The async-commit state machine behind `RecordPanel`/`RecordPage`'s
41
- * editable fields (#431) — the same shape `DataTable`'s own `commitEdit`
42
- * uses (#385/#430): a sync `onEdit` (returns `undefined`) commits and closes
40
+ * The async-commit state machine behind `RecordPage`'s editable Details
41
+ * column (#431) — the same shape `DataTable`'s own `commitEdit` uses
42
+ * (#385/#430): a sync `onEdit` (returns `undefined`) commits and closes
43
43
  * immediately; a Promise-returning `onEdit` keeps the field open and pending
44
44
  * while it settles, then either closes it (resolve) or closes it AND
45
45
  * reverts while showing the rejection's message (reject). The revert needs
46
- * no extra code here either: neither `RecordPanel` nor `RecordPage` mutates
47
- * `record` itself, so once `editingKey` clears, the field simply renders
48
- * `record[key]` again — whatever it still says.
46
+ * no extra code here either: `RecordPage` never mutates `record` itself, so
47
+ * once `editingKey` clears, the field simply renders `record[key]` again —
48
+ * whatever it still says.
49
49
  *
50
- * One hook shared by both consumers rather than two copies of the same
51
- * three `useState`s and the same `.then` branching.
50
+ * `RecordPanel` (the peek panel) used to share this hook too, before #448
51
+ * found that Attio's own peek has no editable field at all to attach it to
52
+ * — only `RecordPage`'s Details column does. Kept as its own module rather
53
+ * than folded back into `recordpage.tsx`: a second consumer turning up
54
+ * again is a smaller change than re-extracting it would be.
52
55
  */
53
56
  function useEditableField(onEdit) {
54
57
  const [editingKey, setEditingKey] = React.useState(null);
@@ -7,9 +7,14 @@ const tokens_1 = require("../../tokens");
7
7
  * `border-radius: ${c.radius.chip}`, 14px/20px at weight 500, and a 1px inset ring in the
8
8
  * tone's colour.
9
9
  *
10
- * Shared because RecordsTable and RecordPanel render the *same* chip. It used
11
- * to be pasted into both recipes, and the two copies had already started to
12
- * drift — adding the measured inset ring meant patching the same rules twice.
10
+ * Its own module (not pasted into `recordstable.recipe.ts`) because it used
11
+ * to be shared with `RecordPanel`'s own Details field list too, and the two
12
+ * copies had already started to drift before that sharing existed — adding
13
+ * the measured inset ring meant patching the same rules twice. `RecordPanel`
14
+ * no longer renders a Details list (#448, Attio's own peek doesn't have
15
+ * one), so `RecordsTable` is this module's only consumer now; kept as its
16
+ * own file rather than folded back in, since a second consumer showing up
17
+ * again is exactly how the drift happened the first time.
13
18
  */
14
19
  exports.recordTagCss = `& .crisp-recordstable-tag { display: inline-flex; align-items: center; height: ${tokens_1.contract.size.chip}; padding: 0 ${tokens_1.contract.space["1"]}; border-radius: ${tokens_1.contract.radius.chip}; font-size: ${tokens_1.contract.text.lg}; line-height: 20px; font-weight: ${tokens_1.contract.weight.medium}; white-space: nowrap; background: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 6%, transparent); color: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 82%, transparent); box-shadow: inset 0 0 0 1px ${tokens_1.contract.borderSubtle}; }
15
20
  & .crisp-recordstable-tag[data-tone="brand"] { background: color-mix(in srgb, ${tokens_1.contract.bgBrandSolid} 14%, transparent); color: color-mix(in srgb, ${tokens_1.contract.bgBrandSolid} 82%, ${tokens_1.contract.fgPrimary}); box-shadow: inset 0 0 0 1px color-mix(in srgb, ${tokens_1.contract.bgBrandSolid} 30%, transparent); }
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.richtextRecipe = exports.RichTextEditor = void 0;
3
+ exports.richtextRecipe = exports.RichTextEditor = exports.RICHTEXT_COLOR_TONES = void 0;
4
4
  var richtext_1 = require("./richtext");
5
+ Object.defineProperty(exports, "RICHTEXT_COLOR_TONES", { enumerable: true, get: function () { return richtext_1.RICHTEXT_COLOR_TONES; } });
5
6
  Object.defineProperty(exports, "RichTextEditor", { enumerable: true, get: function () { return richtext_1.RichTextEditor; } });
6
7
  var richtext_recipe_1 = require("./richtext.recipe");
7
8
  Object.defineProperty(exports, "richtextRecipe", { enumerable: true, get: function () { return richtext_recipe_1.richtextRecipe; } });