hazo_ui 2.4.5 → 2.5.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/index.cjs +101 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -15
- package/dist/index.d.ts +33 -15
- package/dist/index.js +101 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4338,8 +4338,21 @@ var get_variant_classes = (variant = "default") => {
|
|
|
4338
4338
|
return "bg-primary/10 text-primary border-primary/20";
|
|
4339
4339
|
}
|
|
4340
4340
|
};
|
|
4341
|
+
var get_custom_color_styles = (color_bg, color_fg, color_border) => {
|
|
4342
|
+
if (!color_bg && !color_fg && !color_border) {
|
|
4343
|
+
return {};
|
|
4344
|
+
}
|
|
4345
|
+
return {
|
|
4346
|
+
...color_bg && { backgroundColor: color_bg },
|
|
4347
|
+
...color_fg && { color: color_fg },
|
|
4348
|
+
...color_border && { borderColor: color_border }
|
|
4349
|
+
};
|
|
4350
|
+
};
|
|
4351
|
+
var has_custom_colors = (color_bg, color_fg, color_border) => {
|
|
4352
|
+
return Boolean(color_bg || color_fg || color_border);
|
|
4353
|
+
};
|
|
4341
4354
|
var CommandPillView = ({ node, selected, editor }) => {
|
|
4342
|
-
const { prefix, action, action_label, id, variant } = node.attrs;
|
|
4355
|
+
const { prefix, action, action_label, id, variant, color_bg, color_fg, color_border } = node.attrs;
|
|
4343
4356
|
const handle_click = () => {
|
|
4344
4357
|
const event = new CustomEvent("command-pill-click", {
|
|
4345
4358
|
detail: {
|
|
@@ -4353,6 +4366,8 @@ var CommandPillView = ({ node, selected, editor }) => {
|
|
|
4353
4366
|
});
|
|
4354
4367
|
document.dispatchEvent(event);
|
|
4355
4368
|
};
|
|
4369
|
+
const use_custom_colors = has_custom_colors(color_bg, color_fg, color_border);
|
|
4370
|
+
const custom_styles = get_custom_color_styles(color_bg, color_fg, color_border);
|
|
4356
4371
|
return /* @__PURE__ */ jsxRuntime.jsx(react.NodeViewWrapper, { as: "span", className: "inline", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4357
4372
|
"span",
|
|
4358
4373
|
{
|
|
@@ -4365,17 +4380,19 @@ var CommandPillView = ({ node, selected, editor }) => {
|
|
|
4365
4380
|
"border",
|
|
4366
4381
|
"cursor-pointer select-none",
|
|
4367
4382
|
"transition-all duration-150",
|
|
4368
|
-
|
|
4383
|
+
// Only apply variant classes if no custom colors
|
|
4384
|
+
!use_custom_colors && get_variant_classes(variant),
|
|
4369
4385
|
selected && "ring-2 ring-ring ring-offset-1",
|
|
4370
4386
|
"hover:opacity-80"
|
|
4371
4387
|
),
|
|
4388
|
+
style: custom_styles,
|
|
4372
4389
|
contentEditable: false,
|
|
4373
4390
|
"data-command-id": id,
|
|
4374
4391
|
"data-command-prefix": prefix,
|
|
4375
4392
|
"data-command-action": action,
|
|
4376
4393
|
onClick: handle_click,
|
|
4377
4394
|
children: [
|
|
4378
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground opacity-70", children: prefix }),
|
|
4395
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(!use_custom_colors && "text-muted-foreground opacity-70"), style: use_custom_colors ? { opacity: 0.7 } : void 0, children: prefix }),
|
|
4379
4396
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: action_label })
|
|
4380
4397
|
]
|
|
4381
4398
|
}
|
|
@@ -4427,6 +4444,27 @@ var CommandNodeExtension = core.Node.create({
|
|
|
4427
4444
|
renderHTML: (attributes) => ({
|
|
4428
4445
|
"data-command-variant": attributes.variant
|
|
4429
4446
|
})
|
|
4447
|
+
},
|
|
4448
|
+
color_bg: {
|
|
4449
|
+
default: null,
|
|
4450
|
+
parseHTML: (element) => element.getAttribute("data-command-color-bg"),
|
|
4451
|
+
renderHTML: (attributes) => ({
|
|
4452
|
+
"data-command-color-bg": attributes.color_bg
|
|
4453
|
+
})
|
|
4454
|
+
},
|
|
4455
|
+
color_fg: {
|
|
4456
|
+
default: null,
|
|
4457
|
+
parseHTML: (element) => element.getAttribute("data-command-color-fg"),
|
|
4458
|
+
renderHTML: (attributes) => ({
|
|
4459
|
+
"data-command-color-fg": attributes.color_fg
|
|
4460
|
+
})
|
|
4461
|
+
},
|
|
4462
|
+
color_border: {
|
|
4463
|
+
default: null,
|
|
4464
|
+
parseHTML: (element) => element.getAttribute("data-command-color-border"),
|
|
4465
|
+
renderHTML: (attributes) => ({
|
|
4466
|
+
"data-command-color-border": attributes.color_border
|
|
4467
|
+
})
|
|
4430
4468
|
}
|
|
4431
4469
|
};
|
|
4432
4470
|
},
|
|
@@ -4457,11 +4495,15 @@ var CommandNodeExtension = core.Node.create({
|
|
|
4457
4495
|
addCommands() {
|
|
4458
4496
|
return {
|
|
4459
4497
|
insertCommand: (attrs) => ({ commands }) => {
|
|
4498
|
+
const { color: color2, ...rest_attrs } = attrs;
|
|
4460
4499
|
return commands.insertContent({
|
|
4461
4500
|
type: this.name,
|
|
4462
4501
|
attrs: {
|
|
4463
|
-
...
|
|
4464
|
-
id: generate_command_id()
|
|
4502
|
+
...rest_attrs,
|
|
4503
|
+
id: generate_command_id(),
|
|
4504
|
+
...color2?.bg && { color_bg: color2.bg },
|
|
4505
|
+
...color2?.fg && { color_fg: color2.fg },
|
|
4506
|
+
...color2?.border && { color_border: color2.border }
|
|
4465
4507
|
}
|
|
4466
4508
|
});
|
|
4467
4509
|
},
|
|
@@ -4586,12 +4628,13 @@ var create_command_suggestion_extension = (config) => {
|
|
|
4586
4628
|
});
|
|
4587
4629
|
});
|
|
4588
4630
|
};
|
|
4589
|
-
var insert_command_at_position = (editor, command, prefix, range, variant = "default") => {
|
|
4631
|
+
var insert_command_at_position = (editor, command, prefix, range, variant = "default", color2) => {
|
|
4590
4632
|
editor.chain().focus().deleteRange(range).insertCommand({
|
|
4591
4633
|
prefix,
|
|
4592
4634
|
action: command.action,
|
|
4593
4635
|
action_label: command.action_label,
|
|
4594
|
-
variant
|
|
4636
|
+
variant,
|
|
4637
|
+
color: color2
|
|
4595
4638
|
}).run();
|
|
4596
4639
|
};
|
|
4597
4640
|
var get_variant_classes2 = (variant = "default") => {
|
|
@@ -4605,6 +4648,16 @@ var get_variant_classes2 = (variant = "default") => {
|
|
|
4605
4648
|
return "bg-primary/10 text-primary border-primary/20 hover:bg-primary/15";
|
|
4606
4649
|
}
|
|
4607
4650
|
};
|
|
4651
|
+
var get_custom_color_styles2 = (color2) => {
|
|
4652
|
+
if (!color2) {
|
|
4653
|
+
return {};
|
|
4654
|
+
}
|
|
4655
|
+
return {
|
|
4656
|
+
...color2.bg && { backgroundColor: color2.bg },
|
|
4657
|
+
...color2.fg && { color: color2.fg },
|
|
4658
|
+
...color2.border && { borderColor: color2.border }
|
|
4659
|
+
};
|
|
4660
|
+
};
|
|
4608
4661
|
var CommandPill = ({
|
|
4609
4662
|
prefix,
|
|
4610
4663
|
action,
|
|
@@ -4612,8 +4665,11 @@ var CommandPill = ({
|
|
|
4612
4665
|
id,
|
|
4613
4666
|
selected = false,
|
|
4614
4667
|
variant = "default",
|
|
4668
|
+
color: color2,
|
|
4615
4669
|
on_click
|
|
4616
4670
|
}) => {
|
|
4671
|
+
const use_custom_colors = Boolean(color2?.bg || color2?.fg || color2?.border);
|
|
4672
|
+
const custom_styles = get_custom_color_styles2(color2);
|
|
4617
4673
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4618
4674
|
"span",
|
|
4619
4675
|
{
|
|
@@ -4625,10 +4681,12 @@ var CommandPill = ({
|
|
|
4625
4681
|
"text-sm font-medium",
|
|
4626
4682
|
"border",
|
|
4627
4683
|
"transition-all duration-150",
|
|
4628
|
-
|
|
4684
|
+
// Only apply variant classes if no custom colors
|
|
4685
|
+
!use_custom_colors && get_variant_classes2(variant),
|
|
4629
4686
|
selected && "ring-2 ring-ring ring-offset-1",
|
|
4630
4687
|
on_click && "cursor-pointer"
|
|
4631
4688
|
),
|
|
4689
|
+
style: custom_styles,
|
|
4632
4690
|
"data-command-id": id,
|
|
4633
4691
|
"data-command-prefix": prefix,
|
|
4634
4692
|
"data-command-action": action,
|
|
@@ -4642,7 +4700,7 @@ var CommandPill = ({
|
|
|
4642
4700
|
}
|
|
4643
4701
|
},
|
|
4644
4702
|
children: [
|
|
4645
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground opacity-70", children: prefix }),
|
|
4703
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(!use_custom_colors && "text-muted-foreground opacity-70"), style: use_custom_colors ? { opacity: 0.7 } : void 0, children: prefix }),
|
|
4646
4704
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: action_label })
|
|
4647
4705
|
]
|
|
4648
4706
|
}
|
|
@@ -4669,7 +4727,8 @@ var CommandPopover = ({
|
|
|
4669
4727
|
position,
|
|
4670
4728
|
on_select,
|
|
4671
4729
|
on_close,
|
|
4672
|
-
on_selection_change: _on_selection_change
|
|
4730
|
+
on_selection_change: _on_selection_change,
|
|
4731
|
+
prefix_color
|
|
4673
4732
|
}) => {
|
|
4674
4733
|
const container_ref = React27__namespace.useRef(null);
|
|
4675
4734
|
const grouped_commands = React27__namespace.useMemo(
|
|
@@ -4745,6 +4804,16 @@ var CommandPopover = ({
|
|
|
4745
4804
|
onSelect: () => on_select(cmd),
|
|
4746
4805
|
selected: flat_idx === selected_index,
|
|
4747
4806
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 w-full", children: [
|
|
4807
|
+
prefix_color && (prefix_color.bg || prefix_color.fg) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4808
|
+
"span",
|
|
4809
|
+
{
|
|
4810
|
+
className: "flex-shrink-0 w-2 h-2 rounded-full",
|
|
4811
|
+
style: {
|
|
4812
|
+
backgroundColor: prefix_color.bg || prefix_color.fg,
|
|
4813
|
+
border: prefix_color.border ? `1px solid ${prefix_color.border}` : void 0
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
),
|
|
4748
4817
|
cmd.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0 text-muted-foreground", children: cmd.icon }),
|
|
4749
4818
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
4750
4819
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "font-medium truncate", children: [
|
|
@@ -4777,7 +4846,8 @@ var parse_commands_from_text = (text, prefixes) => {
|
|
|
4777
4846
|
for (const cmd of prefix_config.commands) {
|
|
4778
4847
|
action_to_label.set(`${prefix_config.char}${cmd.action}`, {
|
|
4779
4848
|
label: cmd.action_label,
|
|
4780
|
-
prefix: prefix_config.char
|
|
4849
|
+
prefix: prefix_config.char,
|
|
4850
|
+
color: prefix_config.color
|
|
4781
4851
|
});
|
|
4782
4852
|
}
|
|
4783
4853
|
}
|
|
@@ -4796,7 +4866,8 @@ var parse_commands_from_text = (text, prefixes) => {
|
|
|
4796
4866
|
action_label: info.label,
|
|
4797
4867
|
prefix,
|
|
4798
4868
|
position: match.index,
|
|
4799
|
-
length: full_match.length
|
|
4869
|
+
length: full_match.length,
|
|
4870
|
+
color: info.color
|
|
4800
4871
|
});
|
|
4801
4872
|
}
|
|
4802
4873
|
}
|
|
@@ -4835,7 +4906,10 @@ var text_to_tiptap_content = (text, prefixes, variant = "default") => {
|
|
|
4835
4906
|
prefix: cmd.prefix,
|
|
4836
4907
|
action: cmd.action,
|
|
4837
4908
|
action_label: cmd.action_label,
|
|
4838
|
-
variant
|
|
4909
|
+
variant,
|
|
4910
|
+
...cmd.color?.bg && { color_bg: cmd.color.bg },
|
|
4911
|
+
...cmd.color?.fg && { color_fg: cmd.color.fg },
|
|
4912
|
+
...cmd.color?.border && { color_border: cmd.color.border }
|
|
4839
4913
|
}
|
|
4840
4914
|
});
|
|
4841
4915
|
last_end = cmd.position + cmd.length;
|
|
@@ -5078,19 +5152,22 @@ var HazoUiTextbox = ({
|
|
|
5078
5152
|
const handle_command_select = React27__namespace.useCallback(
|
|
5079
5153
|
(command) => {
|
|
5080
5154
|
if (!editor || !suggestion_state) return;
|
|
5155
|
+
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
5156
|
+
const prefix_color = prefix_config?.color;
|
|
5081
5157
|
insert_command_at_position(
|
|
5082
5158
|
editor,
|
|
5083
5159
|
command,
|
|
5084
5160
|
suggestion_state.prefix,
|
|
5085
5161
|
suggestion_state.range,
|
|
5086
|
-
pill_variant
|
|
5162
|
+
pill_variant,
|
|
5163
|
+
prefix_color
|
|
5087
5164
|
);
|
|
5088
5165
|
if (on_command_insert) {
|
|
5089
5166
|
on_command_insert(command, suggestion_state.prefix);
|
|
5090
5167
|
}
|
|
5091
5168
|
set_suggestion_state(null);
|
|
5092
5169
|
},
|
|
5093
|
-
[editor, suggestion_state, pill_variant, on_command_insert]
|
|
5170
|
+
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
5094
5171
|
);
|
|
5095
5172
|
const handle_popover_close = React27__namespace.useCallback(() => {
|
|
5096
5173
|
set_suggestion_state(null);
|
|
@@ -5312,7 +5389,8 @@ var HazoUiTextbox = ({
|
|
|
5312
5389
|
},
|
|
5313
5390
|
on_select: handle_command_select,
|
|
5314
5391
|
on_close: handle_popover_close,
|
|
5315
|
-
on_selection_change: set_selected_index
|
|
5392
|
+
on_selection_change: set_selected_index,
|
|
5393
|
+
prefix_color: prefixes.find((p) => p.char === suggestion_state.prefix)?.color
|
|
5316
5394
|
}
|
|
5317
5395
|
),
|
|
5318
5396
|
edit_context && mounted && reactDom.createPortal(
|
|
@@ -5618,19 +5696,22 @@ var HazoUiTextarea = ({
|
|
|
5618
5696
|
const handle_command_select = React27__namespace.useCallback(
|
|
5619
5697
|
(command) => {
|
|
5620
5698
|
if (!editor || !suggestion_state) return;
|
|
5699
|
+
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
5700
|
+
const prefix_color = prefix_config?.color;
|
|
5621
5701
|
insert_command_at_position(
|
|
5622
5702
|
editor,
|
|
5623
5703
|
command,
|
|
5624
5704
|
suggestion_state.prefix,
|
|
5625
5705
|
suggestion_state.range,
|
|
5626
|
-
pill_variant
|
|
5706
|
+
pill_variant,
|
|
5707
|
+
prefix_color
|
|
5627
5708
|
);
|
|
5628
5709
|
if (on_command_insert) {
|
|
5629
5710
|
on_command_insert(command, suggestion_state.prefix);
|
|
5630
5711
|
}
|
|
5631
5712
|
set_suggestion_state(null);
|
|
5632
5713
|
},
|
|
5633
|
-
[editor, suggestion_state, pill_variant, on_command_insert]
|
|
5714
|
+
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
5634
5715
|
);
|
|
5635
5716
|
const handle_popover_close = React27__namespace.useCallback(() => {
|
|
5636
5717
|
set_suggestion_state(null);
|
|
@@ -5856,7 +5937,8 @@ var HazoUiTextarea = ({
|
|
|
5856
5937
|
},
|
|
5857
5938
|
on_select: handle_command_select,
|
|
5858
5939
|
on_close: handle_popover_close,
|
|
5859
|
-
on_selection_change: set_selected_index
|
|
5940
|
+
on_selection_change: set_selected_index,
|
|
5941
|
+
prefix_color: prefixes.find((p) => p.char === suggestion_state.prefix)?.color
|
|
5860
5942
|
}
|
|
5861
5943
|
),
|
|
5862
5944
|
edit_context && mounted && reactDom.createPortal(
|