@ctrliq/quantic-components 1.67.2 → 1.67.4

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,4 +1,5 @@
1
1
  import { unsafeCSS, } from 'lit';
2
+ import { escapeCssString, whenSlotPresent } from './slot-utils';
2
3
  /**
3
4
  * Mixin that automatically hides empty named slots using CSS only.
4
5
  *
@@ -31,11 +32,13 @@ export const AutoHideEmptySlotsMixin = (superClass, namedSlots = []) => {
31
32
  ? style.cssText
32
33
  : Array.from(style.cssRules, (rule) => rule.cssText).join('\n');
33
34
  const slotRulesCSS = namedSlots
34
- .map((name) => [
35
- `slot[name="${name}"] { display: none; }`,
36
- `:host(:has([slot="${name}"])) slot[name="${name}"] { display: revert-layer; }`,
37
- `@scope { :scope:has([slot="${name}"]) slot[name="${name}"] { display: revert-layer; } }`,
38
- ].join(' '))
35
+ .map((name) => {
36
+ const escaped = escapeCssString(name);
37
+ return [
38
+ `slot[name="${escaped}"] { display: none; }`,
39
+ whenSlotPresent(name, unsafeCSS(`slot[name="${escaped}"] { display: revert-layer; }`)).cssText,
40
+ ].join(' ');
41
+ })
39
42
  .join(' ');
40
43
  class AutoHideEmptySlotsClass extends superClass {
41
44
  static finalizeStyles(styles) {
@@ -22,3 +22,22 @@ export declare function onSlotChange(setter: (has: boolean) => void): (e: Event)
22
22
  * html`<slot @slotchange=${onSlotTextChange((t) => (this._labelText = t))}></slot>`
23
23
  */
24
24
  export declare function onSlotTextChange(setter: (text: string) => void): (e: Event) => void;
25
+ import { type CSSResult } from 'lit';
26
+ /**
27
+ * Generates a CSSResult that applies `rules` when the host has a light DOM
28
+ * child with the given slot name. Two forms are emitted for cross-browser
29
+ * Declarative Shadow DOM compatibility:
30
+ *
31
+ * - `:host(:has([slot="name"])) { rules }` — standard shadow DOM (Safari, Firefox)
32
+ * - `@scope { :scope:has([slot="name"]) { rules } }` — Chrome DSD
33
+ *
34
+ * @example
35
+ * whenSlotPresent('action-icon', css`
36
+ * .main { padding-right: calc(var(--quantic-component-card-padding) * 2); }
37
+ * `)
38
+ */
39
+ export declare function whenSlotPresent(slotName: string, rules: CSSResult): CSSResult;
40
+ /**
41
+ * Escapes a value for safe interpolation inside a double-quoted CSS string.
42
+ */
43
+ export declare function escapeCssString(value: string): string;
@@ -36,3 +36,29 @@ export function onSlotChange(setter) {
36
36
  export function onSlotTextChange(setter) {
37
37
  return (e) => setter(slotTextContent(e.target));
38
38
  }
39
+ import { unsafeCSS } from 'lit';
40
+ /**
41
+ * Generates a CSSResult that applies `rules` when the host has a light DOM
42
+ * child with the given slot name. Two forms are emitted for cross-browser
43
+ * Declarative Shadow DOM compatibility:
44
+ *
45
+ * - `:host(:has([slot="name"])) { rules }` — standard shadow DOM (Safari, Firefox)
46
+ * - `@scope { :scope:has([slot="name"]) { rules } }` — Chrome DSD
47
+ *
48
+ * @example
49
+ * whenSlotPresent('action-icon', css`
50
+ * .main { padding-right: calc(var(--quantic-component-card-padding) * 2); }
51
+ * `)
52
+ */
53
+ export function whenSlotPresent(slotName, rules) {
54
+ const r = rules.cssText;
55
+ const name = escapeCssString(slotName);
56
+ return unsafeCSS(`:host(:has([slot="${name}"])) { ${r} } ` +
57
+ `@scope { :scope:has([slot="${name}"]) { ${r} } }`);
58
+ }
59
+ /**
60
+ * Escapes a value for safe interpolation inside a double-quoted CSS string.
61
+ */
62
+ export function escapeCssString(value) {
63
+ return value.replace(/["\\]/g, '\\$&');
64
+ }
@@ -13,8 +13,7 @@ export declare class Card extends Card_base {
13
13
  target: string | undefined;
14
14
  rel: string | undefined;
15
15
  download: string | undefined;
16
- private hasActionIconSlot;
17
- static styles: import("lit").CSSResult;
16
+ static styles: import("lit").CSSResult[];
18
17
  render(): import("lit").TemplateResult;
19
18
  }
20
19
  export {};
@@ -4,8 +4,7 @@ declare const DropdownMenuGroup_base: typeof QuanticElement;
4
4
  export declare class DropdownMenuGroup extends DropdownMenuGroup_base {
5
5
  static meta: ComponentMeta;
6
6
  label: string;
7
- private hasLabelSlot;
8
- static styles: import("lit").CSSResult;
7
+ static styles: import("lit").CSSResult[];
9
8
  render(): import("lit").TemplateResult<1>;
10
9
  }
11
10
  export {};
@@ -11,9 +11,6 @@ export declare class Field extends QuanticElement {
11
11
  status: FieldValidationStatus | undefined;
12
12
  size: FieldSize;
13
13
  hintPosition: FieldHintPosition;
14
- private hasLabelSlot;
15
- private hasHintSlot;
16
- private hasMessageSlot;
17
14
  static styles: import("lit").CSSResult[];
18
15
  render(): import("lit").TemplateResult<1>;
19
16
  }
@@ -5,10 +5,9 @@ export declare class InlineEdit extends QuanticElement {
5
5
  label: string;
6
6
  active: boolean;
7
7
  invalid: boolean;
8
- private hasLabelSlot;
9
8
  connectedCallback(): void;
10
9
  disconnectedCallback(): void;
11
- static styles: import("lit").CSSResult;
10
+ static styles: import("lit").CSSResult[];
12
11
  private activate;
13
12
  private deactivate;
14
13
  private handleActivateClick;
@@ -1,4 +1,4 @@
1
- import { type PropertyValues } from 'lit';
1
+ import { type CSSResultGroup, type PropertyValues } from 'lit';
2
2
  import { LayoutVariant } from './index.constants';
3
3
  import { QuanticElement } from '../shared/quantic-element';
4
4
  import type { ComponentMeta } from '../shared/meta.types';
@@ -10,8 +10,6 @@ export declare class Layout extends Layout_base {
10
10
  private previousIsSmallViewport?;
11
11
  private hasSidebarSlot;
12
12
  private hasTitlebarSlot;
13
- private hasNavbarSlot;
14
- private hasLogoSlot;
15
13
  private asideElement?;
16
14
  private toggleButtonElement?;
17
15
  private focusTrap?;
@@ -28,10 +26,10 @@ export declare class Layout extends Layout_base {
28
26
  protected willUpdate(_props: PropertyValues): void;
29
27
  protected updated(props: PropertyValues): void;
30
28
  static styles: import("lit").CSSResult;
29
+ static finalizeStyles(styles?: CSSResultGroup): import("lit").CSSResultOrNative[];
31
30
  private get isAsideCollapsible();
32
31
  private get hasSidebar();
33
32
  private get hasTitlebar();
34
- private get hasHeader();
35
33
  render(): import("lit").TemplateResult;
36
34
  }
37
35
  export {};
@@ -22,3 +22,22 @@ export declare function onSlotChange(setter: (has: boolean) => void): (e: Event)
22
22
  * html`<slot @slotchange=${onSlotTextChange((t) => (this._labelText = t))}></slot>`
23
23
  */
24
24
  export declare function onSlotTextChange(setter: (text: string) => void): (e: Event) => void;
25
+ import { type CSSResult } from 'lit';
26
+ /**
27
+ * Generates a CSSResult that applies `rules` when the host has a light DOM
28
+ * child with the given slot name. Two forms are emitted for cross-browser
29
+ * Declarative Shadow DOM compatibility:
30
+ *
31
+ * - `:host(:has([slot="name"])) { rules }` — standard shadow DOM (Safari, Firefox)
32
+ * - `@scope { :scope:has([slot="name"]) { rules } }` — Chrome DSD
33
+ *
34
+ * @example
35
+ * whenSlotPresent('action-icon', css`
36
+ * .main { padding-right: calc(var(--quantic-component-card-padding) * 2); }
37
+ * `)
38
+ */
39
+ export declare function whenSlotPresent(slotName: string, rules: CSSResult): CSSResult;
40
+ /**
41
+ * Escapes a value for safe interpolation inside a double-quoted CSS string.
42
+ */
43
+ export declare function escapeCssString(value: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrliq/quantic-components",
3
- "version": "1.67.2",
3
+ "version": "1.67.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/types/index.d.ts",
6
6
  "exports": {