@juspay/svelte-ui-components 4.5.0 → 4.6.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.
@@ -1,7 +1,14 @@
1
1
  <script lang="ts">
2
2
  import type { KeyboardInputProperties } from './properties';
3
3
 
4
- let { keys, separator = '+', testId, onclick, classes }: KeyboardInputProperties = $props();
4
+ let {
5
+ keys,
6
+ separator = '+',
7
+ testId,
8
+ onclick,
9
+ classes,
10
+ literal = false
11
+ }: KeyboardInputProperties = $props();
5
12
 
6
13
  const KEY_SYMBOLS: Record<string, string> = {
7
14
  cmd: '\u2318',
@@ -28,6 +35,9 @@
28
35
  let interactive = $derived(typeof onclick === 'function');
29
36
 
30
37
  function getSymbol(key: string): string {
38
+ if (literal) {
39
+ return key;
40
+ }
31
41
  return KEY_SYMBOLS[key.toLowerCase()] ?? key;
32
42
  }
33
43
 
@@ -6,6 +6,15 @@ export type OptionalKeyboardInputProperties = {
6
6
  separator?: string;
7
7
  testId?: string;
8
8
  classes?: string;
9
+ /**
10
+ * When true, every key renders exactly as given — the built-in KEY_SYMBOLS
11
+ * table (`space` → ␣, `tab` → ⇥, `cmd` → ⌘, …) is bypassed entirely.
12
+ * Defaults to false, so existing consumers keep today's glyph substitution
13
+ * unchanged. Use this when the word itself is the label that must appear
14
+ * (e.g. a "Hold SPACE" caption or a physical-key caption reading "Tab"),
15
+ * not the typographic symbol.
16
+ */
17
+ literal?: boolean;
9
18
  };
10
19
  export type KeyboardInputEventProperties = {
11
20
  onclick?: (event: MouseEvent) => void;
package/dist-wc/index.js CHANGED
@@ -9834,7 +9834,7 @@ var root$64 = /* @__PURE__ */ from_html("<span class=\"separator svelte-14lwsom\
9834
9834
  };
9835
9835
  function KeyboardInput(e, t) {
9836
9836
  push(t, !0), append_styles$1(e, $$css$63);
9837
- let n = prop(t, "keys", 7), i = prop(t, "separator", 7, "+"), a = prop(t, "testId", 7), o = prop(t, "onclick", 7), s = prop(t, "classes", 7), c = {
9837
+ let n = prop(t, "keys", 7), i = prop(t, "separator", 7, "+"), a = prop(t, "testId", 7), o = prop(t, "onclick", 7), s = prop(t, "classes", 7), c = prop(t, "literal", 7, !1), l = {
9838
9838
  cmd: "⌘",
9839
9839
  command: "⌘",
9840
9840
  ctrl: "⌃",
@@ -9853,14 +9853,14 @@ function KeyboardInput(e, t) {
9853
9853
  left: "←",
9854
9854
  right: "→",
9855
9855
  space: "␣"
9856
- }, l = /* @__PURE__ */ user_derived(() => Array.isArray(n()) ? n() : n().split(i()).map((e) => e.trim())), u = /* @__PURE__ */ user_derived(() => typeof o() == "function");
9857
- function f(e) {
9858
- return c[e.toLowerCase()] ?? e;
9859
- }
9856
+ }, u = /* @__PURE__ */ user_derived(() => Array.isArray(n()) ? n() : n().split(i()).map((e) => e.trim())), f = /* @__PURE__ */ user_derived(() => typeof o() == "function");
9860
9857
  function p(e) {
9858
+ return c() ? e : l[e.toLowerCase()] ?? e;
9859
+ }
9860
+ function h(e) {
9861
9861
  (e.key === "Enter" || e.key === " ") && (e.preventDefault(), o()?.(new MouseEvent("click")));
9862
9862
  }
9863
- var h = {
9863
+ var S = {
9864
9864
  get keys() {
9865
9865
  return n();
9866
9866
  },
@@ -9890,9 +9890,15 @@ function KeyboardInput(e, t) {
9890
9890
  },
9891
9891
  set classes(e) {
9892
9892
  s(e), flushSync();
9893
+ },
9894
+ get literal() {
9895
+ return c();
9896
+ },
9897
+ set literal(e = !1) {
9898
+ c(e), flushSync();
9893
9899
  }
9894
- }, S = root_2$41();
9895
- return each(S, 21, () => get(l), index, (e, t, n) => {
9900
+ }, C = root_2$41();
9901
+ return each(C, 21, () => get(u), index, (e, t, n) => {
9896
9902
  var a = root_1$53(), o = first_child(a), s = (e) => {
9897
9903
  var t = root$64(), n = child(t, !0);
9898
9904
  reset(t), template_effect(() => set_text(n, i())), append(e, t);
@@ -9901,21 +9907,22 @@ function KeyboardInput(e, t) {
9901
9907
  n > 0 && e(s);
9902
9908
  });
9903
9909
  var c = sibling(o, 2), l = child(c, !0);
9904
- reset(c), template_effect((e) => set_text(l, e), [() => f(get(t))]), append(e, a);
9905
- }), reset(S), template_effect(() => {
9906
- set_class(S, 1, `keyboard-input ${s() ?? "" ?? ""}`, "svelte-14lwsom"), set_attribute(S, "data-pw", typeof a() == "string" ? a() : null), set_attribute(S, "testid", typeof a() == "string" ? a() : null), set_attribute(S, "role", get(u) ? "button" : null), set_attribute(S, "tabindex", get(u) ? 0 : null);
9907
- }), delegated("click", S, function(...e) {
9908
- (get(u) ? o() : null)?.apply(this, e);
9909
- }), delegated("keydown", S, function(...e) {
9910
- (get(u) ? p : null)?.apply(this, e);
9911
- }), append(e, S), pop(h);
9910
+ reset(c), template_effect((e) => set_text(l, e), [() => p(get(t))]), append(e, a);
9911
+ }), reset(C), template_effect(() => {
9912
+ set_class(C, 1, `keyboard-input ${s() ?? "" ?? ""}`, "svelte-14lwsom"), set_attribute(C, "data-pw", typeof a() == "string" ? a() : null), set_attribute(C, "testid", typeof a() == "string" ? a() : null), set_attribute(C, "role", get(f) ? "button" : null), set_attribute(C, "tabindex", get(f) ? 0 : null);
9913
+ }), delegated("click", C, function(...e) {
9914
+ (get(f) ? o() : null)?.apply(this, e);
9915
+ }), delegated("keydown", C, function(...e) {
9916
+ (get(f) ? h : null)?.apply(this, e);
9917
+ }), append(e, C), pop(S);
9912
9918
  }
9913
9919
  delegate(["click", "keydown"]), create_custom_element(KeyboardInput, {
9914
9920
  keys: {},
9915
9921
  separator: {},
9916
9922
  testId: {},
9917
9923
  onclick: {},
9918
- classes: {}
9924
+ classes: {},
9925
+ literal: {}
9919
9926
  }, [], [], { mode: "open" });
9920
9927
  //#endregion
9921
9928
  //#region src/wc/components/KeyboardInput.wc.svelte
@@ -9943,6 +9950,10 @@ customElements.define("sui-keyboard-input", create_custom_element(KeyboardInput_
9943
9950
  type: "String"
9944
9951
  },
9945
9952
  classes: { type: "String" },
9953
+ literal: {
9954
+ reflect: !0,
9955
+ type: "Boolean"
9956
+ },
9946
9957
  onclick: { type: "Object" }
9947
9958
  }, [], [], { mode: "open" }));
9948
9959
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",