@progressive-development/pd-content 0.9.2 → 1.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 (119) hide show
  1. package/LICENSE +21 -2
  2. package/README.md +42 -57
  3. package/dist/_virtual/_commonjsHelpers.js +7 -0
  4. package/dist/_virtual/prism-java.js +3 -0
  5. package/dist/_virtual/prism-java2.js +3 -0
  6. package/dist/_virtual/prism-python.js +3 -0
  7. package/dist/_virtual/prism-python2.js +3 -0
  8. package/dist/_virtual/prism-typescript.js +3 -0
  9. package/dist/_virtual/prism-typescript2.js +3 -0
  10. package/dist/_virtual/prism.js +7 -0
  11. package/dist/_virtual/prism2.js +3 -0
  12. package/dist/generated/locales/be.d.ts +10 -0
  13. package/dist/generated/locales/be.d.ts.map +1 -1
  14. package/dist/generated/locales/de.d.ts +10 -0
  15. package/dist/generated/locales/de.d.ts.map +1 -1
  16. package/dist/generated/locales/en.d.ts +10 -0
  17. package/dist/generated/locales/en.d.ts.map +1 -1
  18. package/dist/index.d.ts +8 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +9 -0
  21. package/dist/locales/be.js +11 -1
  22. package/dist/locales/de.js +11 -1
  23. package/dist/locales/en.js +11 -1
  24. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-bash.js +235 -0
  25. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-java.js +135 -0
  26. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-json.js +27 -0
  27. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-markdown.js +415 -0
  28. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-python.js +76 -0
  29. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-sql.js +32 -0
  30. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-typescript.js +71 -0
  31. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-yaml.js +83 -0
  32. package/dist/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/prism.js +1959 -0
  33. package/dist/pd-box-view/PdBoxView.d.ts +9 -0
  34. package/dist/pd-box-view/PdBoxView.d.ts.map +1 -1
  35. package/dist/pd-box-view/pd-box-view.stories.d.ts +41 -8
  36. package/dist/pd-box-view/pd-box-view.stories.d.ts.map +1 -1
  37. package/dist/pd-code-snippet/PdCodeSnippet.d.ts +105 -0
  38. package/dist/pd-code-snippet/PdCodeSnippet.d.ts.map +1 -0
  39. package/dist/pd-code-snippet/PdCodeSnippet.js +504 -0
  40. package/dist/pd-code-snippet/pd-code-snippet.d.ts +4 -0
  41. package/dist/pd-code-snippet/pd-code-snippet.d.ts.map +1 -0
  42. package/dist/pd-code-snippet/pd-code-snippet.js +5 -0
  43. package/dist/pd-code-snippet/pd-code-snippet.stories.d.ts +55 -0
  44. package/dist/pd-code-snippet/pd-code-snippet.stories.d.ts.map +1 -0
  45. package/dist/pd-collapse/PdCollapse.d.ts +31 -7
  46. package/dist/pd-collapse/PdCollapse.d.ts.map +1 -1
  47. package/dist/pd-collapse/PdCollapse.js +73 -15
  48. package/dist/pd-collapse/pd-collapse.stories.d.ts +49 -21
  49. package/dist/pd-collapse/pd-collapse.stories.d.ts.map +1 -1
  50. package/dist/pd-collapse-group/PdCollapseGroup.d.ts +8 -7
  51. package/dist/pd-collapse-group/PdCollapseGroup.d.ts.map +1 -1
  52. package/dist/pd-collapse-group/PdCollapseGroup.js +7 -6
  53. package/dist/pd-collapse-group/pd-collapse-group.stories.d.ts +39 -4
  54. package/dist/pd-collapse-group/pd-collapse-group.stories.d.ts.map +1 -1
  55. package/dist/pd-edit-content/PdEditContent.d.ts +13 -0
  56. package/dist/pd-edit-content/PdEditContent.d.ts.map +1 -1
  57. package/dist/pd-edit-content/PdEditContent.js +33 -7
  58. package/dist/pd-edit-content/pd-edit-content.stories.d.ts +54 -10
  59. package/dist/pd-edit-content/pd-edit-content.stories.d.ts.map +1 -1
  60. package/dist/pd-loading-state/PdLoadingState.d.ts +64 -0
  61. package/dist/pd-loading-state/PdLoadingState.d.ts.map +1 -0
  62. package/dist/pd-loading-state/PdLoadingState.js +219 -0
  63. package/dist/pd-loading-state/pd-loading-state.d.ts +6 -0
  64. package/dist/pd-loading-state/pd-loading-state.d.ts.map +1 -0
  65. package/dist/pd-loading-state/pd-loading-state.stories.d.ts +48 -0
  66. package/dist/pd-loading-state/pd-loading-state.stories.d.ts.map +1 -0
  67. package/dist/pd-loading-state.d.ts +2 -0
  68. package/dist/pd-loading-state.js +1 -0
  69. package/dist/pd-more-info/PdMoreInfo.d.ts +6 -2
  70. package/dist/pd-more-info/PdMoreInfo.d.ts.map +1 -1
  71. package/dist/pd-more-info/PdMoreInfo.js +30 -2
  72. package/dist/pd-more-info/pd-more-info.stories.d.ts +41 -5
  73. package/dist/pd-more-info/pd-more-info.stories.d.ts.map +1 -1
  74. package/dist/pd-notice-box/PdNoticeBox.d.ts +88 -0
  75. package/dist/pd-notice-box/PdNoticeBox.d.ts.map +1 -0
  76. package/dist/pd-notice-box/PdNoticeBox.js +224 -0
  77. package/dist/pd-notice-box/pd-notice-box.d.ts +3 -0
  78. package/dist/pd-notice-box/pd-notice-box.d.ts.map +1 -0
  79. package/dist/pd-notice-box/pd-notice-box.js +8 -0
  80. package/dist/pd-notice-box/pd-notice-box.stories.d.ts +58 -0
  81. package/dist/pd-notice-box/pd-notice-box.stories.d.ts.map +1 -0
  82. package/dist/pd-panel-viewer/PdPanel.d.ts +5 -0
  83. package/dist/pd-panel-viewer/PdPanel.d.ts.map +1 -1
  84. package/dist/pd-panel-viewer/PdPanelViewer.d.ts +53 -2
  85. package/dist/pd-panel-viewer/PdPanelViewer.d.ts.map +1 -1
  86. package/dist/pd-panel-viewer/PdPanelViewer.js +188 -33
  87. package/dist/pd-panel-viewer/pd-panel-viewer.stories.d.ts +46 -0
  88. package/dist/pd-panel-viewer/pd-panel-viewer.stories.d.ts.map +1 -0
  89. package/dist/pd-resize-content/PdResizeContent.d.ts +12 -10
  90. package/dist/pd-resize-content/PdResizeContent.d.ts.map +1 -1
  91. package/dist/pd-resize-content/PdResizeContent.js +19 -9
  92. package/dist/pd-resize-content/pd-resize-content.stories.d.ts +36 -4
  93. package/dist/pd-resize-content/pd-resize-content.stories.d.ts.map +1 -1
  94. package/dist/pd-tab/PdTab.d.ts +35 -2
  95. package/dist/pd-tab/PdTab.d.ts.map +1 -1
  96. package/dist/pd-tab/PdTab.js +181 -68
  97. package/dist/pd-tab/pd-tab.stories.d.ts +51 -21
  98. package/dist/pd-tab/pd-tab.stories.d.ts.map +1 -1
  99. package/dist/pd-timeline/PdTimeline.d.ts +50 -0
  100. package/dist/pd-timeline/PdTimeline.d.ts.map +1 -0
  101. package/dist/pd-timeline/PdTimeline.js +315 -0
  102. package/dist/pd-timeline/pd-timeline.d.ts +3 -0
  103. package/dist/pd-timeline/pd-timeline.d.ts.map +1 -0
  104. package/dist/pd-timeline/pd-timeline.stories.d.ts +56 -0
  105. package/dist/pd-timeline/pd-timeline.stories.d.ts.map +1 -0
  106. package/dist/pd-timeline-wizard/PdTimelineWizard.d.ts +39 -0
  107. package/dist/pd-timeline-wizard/PdTimelineWizard.d.ts.map +1 -0
  108. package/dist/pd-timeline-wizard/PdTimelineWizard.js +150 -0
  109. package/dist/pd-timeline-wizard/pd-timeline-wizard.d.ts +3 -0
  110. package/dist/pd-timeline-wizard/pd-timeline-wizard.d.ts.map +1 -0
  111. package/dist/pd-timeline-wizard/pd-timeline-wizard.stories.d.ts +54 -0
  112. package/dist/pd-timeline-wizard/pd-timeline-wizard.stories.d.ts.map +1 -0
  113. package/dist/pd-timeline-wizard.d.ts +2 -0
  114. package/dist/pd-timeline-wizard.js +8 -0
  115. package/dist/pd-timeline.d.ts +2 -0
  116. package/dist/pd-timeline.js +8 -0
  117. package/dist/types.d.ts +25 -0
  118. package/dist/types.d.ts.map +1 -1
  119. package/package.json +16 -7
@@ -1,6 +1,15 @@
1
1
  import { LitElement, CSSResultGroup } from 'lit';
2
2
  /**
3
+ * A responsive grid container for displaying content in columns.
4
+ *
3
5
  * @tagname pd-box-view
6
+ * @summary Responsive CSS Grid container with configurable columns.
7
+ *
8
+ * @slot - Default slot for grid items.
9
+ *
10
+ * @cssprop --pd-box-columns - Number of grid columns. Default: `4`.
11
+ * @cssprop --pd-box-min-width - Minimum width of each grid item. Default: `100px`.
12
+ * @cssprop --pd-box-gap - Gap between grid items. Default: `25px`.
4
13
  */
5
14
  export declare class PdBoxView extends LitElement {
6
15
  static styles: CSSResultGroup;
@@ -1 +1 @@
1
- {"version":3,"file":"PdBoxView.d.ts","sourceRoot":"","sources":["../../src/pd-box-view/PdBoxView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAE5D;;GAEG;AACH,qBAAa,SAAU,SAAQ,UAAU;IACvC,OAAgB,MAAM,EAAE,cAAc,CAWpC;IAEO,MAAM;CAGhB"}
1
+ {"version":3,"file":"PdBoxView.d.ts","sourceRoot":"","sources":["../../src/pd-box-view/PdBoxView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,qBAAa,SAAU,SAAQ,UAAU;IACvC,OAAgB,MAAM,EAAE,cAAc,CAWpC;IAEO,MAAM;CAGhB"}
@@ -1,10 +1,43 @@
1
- import { StoryObj } from '@storybook/web-components';
2
- declare const meta: {
3
- title: string;
4
- component: string;
5
- render: () => import('lit').TemplateResult<1>;
6
- };
1
+ import { Meta, StoryObj } from '@storybook/web-components-vite';
2
+ /**
3
+ * Story arguments interface for pd-box-view component.
4
+ * Maps to the component's public API via CSS custom properties.
5
+ */
6
+ interface PdBoxViewArgs {
7
+ /** Number of columns in the grid */
8
+ columns: number;
9
+ /** Gap between items */
10
+ gap: string;
11
+ /** Minimum width of each box */
12
+ minWidth: string;
13
+ }
14
+ /**
15
+ * ## pd-box-view
16
+ *
17
+ * A responsive CSS Grid container for displaying content in configurable columns.
18
+ *
19
+ * ### Features
20
+ * - Pure CSS Grid layout with no JavaScript logic
21
+ * - Configurable column count via `--pd-box-columns`
22
+ * - Configurable gap spacing via `--pd-box-gap`
23
+ * - Minimum item width via `--pd-box-min-width` for responsive wrapping
24
+ * - Items automatically wrap when they cannot maintain minimum width
25
+ * - Lightweight: zero properties, zero events, all configuration via CSS
26
+ *
27
+ * ### Accessibility
28
+ * - Pure layout component with no interactive behavior
29
+ * - Content is fully accessible via standard HTML in the default slot
30
+ * - Grid layout does not affect reading order for screen readers
31
+ */
32
+ declare const meta: Meta<PdBoxViewArgs>;
7
33
  export default meta;
8
- type Story = StoryObj;
9
- export declare const BoxView: Story;
34
+ type Story = StoryObj<PdBoxViewArgs>;
35
+ /** Default 4-column grid layout. Interactive via Controls panel. */
36
+ export declare const Default: Story;
37
+ /** Visual comparison of 1, 2, 3, and 4 column layouts. */
38
+ export declare const AllVariants: Story;
39
+ /** Demonstrates responsive wrapping when items cannot maintain minimum width. */
40
+ export declare const ResponsiveMinWidth: Story;
41
+ /** CSS Custom Properties -- Tight grid vs. spacious grid. */
42
+ export declare const CustomStyling: Story;
10
43
  //# sourceMappingURL=pd-box-view.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pd-box-view.stories.d.ts","sourceRoot":"","sources":["../../src/pd-box-view/pd-box-view.stories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,kBAAkB,CAAC;AAE1B,QAAA,MAAM,IAAI;;;;CA6CM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAEtB,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
1
+ {"version":3,"file":"pd-box-view.stories.d.ts","sourceRoot":"","sources":["../../src/pd-box-view/pd-box-view.stories.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,kBAAkB,CAAC;AAM1B;;;GAGG;AACH,UAAU,aAAa;IACrB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB;AA2CD;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,aAAa,CAmC7B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAMrC,oEAAoE;AACpE,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AAMF,0DAA0D;AAC1D,eAAO,MAAM,WAAW,EAAE,KA6CzB,CAAC;AAMF,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,EAAE,KA4BhC,CAAC;AAMF,6DAA6D;AAC7D,eAAO,MAAM,aAAa,EAAE,KA0D3B,CAAC"}
@@ -0,0 +1,105 @@
1
+ import { CSSResultGroup, LitElement, PropertyValues } from 'lit';
2
+ /**
3
+ * Supported programming languages for syntax highlighting.
4
+ */
5
+ export type CodeLanguage = "javascript" | "typescript" | "html" | "css" | "json" | "bash" | "yaml" | "python" | "java" | "sql" | "markdown" | "plain";
6
+ /**
7
+ * Code snippet component with syntax highlighting.
8
+ *
9
+ * Displays code with proper syntax highlighting using Prism.js,
10
+ * with an optional title, copy-to-clipboard button, and source URL.
11
+ *
12
+ * @tagname pd-code-snippet
13
+ * @summary Code display component with syntax highlighting and copy functionality.
14
+ *
15
+ * @cssprop --pd-code-snippet-width - Width of the component. Default: `100%`.
16
+ * @cssprop --pd-code-snippet-border-radius - Border radius. Default: `--pd-radius-md`.
17
+ * @cssprop --pd-code-snippet-padding - Code padding. Default: `--pd-spacing-md`.
18
+ * @cssprop --pd-code-snippet-font-family - Code font family. Default: monospace.
19
+ * @cssprop --pd-code-snippet-font-size - Code font size. Default: `0.875rem`.
20
+ * @cssprop --pd-code-snippet-line-height - Code line height. Default: `1.5`.
21
+ * @cssprop --pd-code-snippet-bg-col - Code background color. Default: `--pd-default-bg-light-col`.
22
+ * @cssprop --pd-code-snippet-text-col - Code text color. Default: `--pd-default-font-content-col`.
23
+ * @cssprop --pd-code-snippet-header-bg-col - Header background. Default: `--pd-default-bg-dark-col`.
24
+ * @cssprop --pd-code-snippet-header-col - Header text color. Default: `--pd-default-font-col`.
25
+ * @cssprop --pd-code-snippet-url-col - URL link color. Default: `--pd-default-font-link-col`.
26
+ * @cssprop --pd-code-snippet-border-col - Border color. Default: `--pd-default-light-col`.
27
+ * @cssprop --pd-code-snippet-line-number-col - Line number color. Default: `--pd-default-font-muted-col`.
28
+ * @cssprop --pd-code-snippet-token-class - Syntax color for class names, regex, and variables. Default: `#267f99`.
29
+ * @cssprop --pd-code-snippet-token-comment - Syntax color for comments, prologs, and doctypes. Default: `#6a9955`.
30
+ * @cssprop --pd-code-snippet-token-function - Syntax color for functions and class-name tokens. Default: `#795e26`.
31
+ * @cssprop --pd-code-snippet-token-keyword - Syntax color for keywords, at-rules, and attr-values. Default: `#0550ae`.
32
+ * @cssprop --pd-code-snippet-token-number - Syntax color for numbers, constants, booleans, and symbols. Default: `#098658`.
33
+ * @cssprop --pd-code-snippet-token-operator - Syntax color for operators, entities, and URLs. Default: `#1e1e1e`.
34
+ * @cssprop --pd-code-snippet-token-property - Syntax color for property tokens. Default: `#0451a5`.
35
+ * @cssprop --pd-code-snippet-token-punctuation - Syntax color for punctuation. Default: `#1e1e1e`.
36
+ * @cssprop --pd-code-snippet-token-string - Syntax color for strings, selectors, and char tokens. Default: `#a31515`.
37
+ *
38
+ * @example
39
+ * ```html
40
+ * <pd-code-snippet
41
+ * title="Installation"
42
+ * language="bash"
43
+ * url="https://docs.example.com/install"
44
+ * >
45
+ * npm install @progressive-development/pd-content
46
+ * </pd-code-snippet>
47
+ * ```
48
+ */
49
+ export declare class PdCodeSnippet extends LitElement {
50
+ /**
51
+ * Title displayed in the header.
52
+ */
53
+ title: string;
54
+ /**
55
+ * Programming language for syntax highlighting.
56
+ */
57
+ language: CodeLanguage;
58
+ /**
59
+ * Source URL displayed below the code.
60
+ */
61
+ url: string;
62
+ /**
63
+ * The code content to display.
64
+ * Can be set via property or slotted text content.
65
+ */
66
+ code: string;
67
+ /**
68
+ * Whether to show line numbers.
69
+ */
70
+ showLineNumbers: boolean;
71
+ /**
72
+ * Copy button state.
73
+ * @ignore
74
+ */
75
+ private _copied;
76
+ /**
77
+ * Code extracted from slot.
78
+ * @ignore
79
+ */
80
+ private _slotCode;
81
+ static styles: CSSResultGroup;
82
+ updated(changedProperties: PropertyValues): void;
83
+ render(): import('lit').TemplateResult<1>;
84
+ /**
85
+ * Extract code from slotted content.
86
+ */
87
+ private _handleSlotChange;
88
+ /**
89
+ * Apply syntax highlighting to the code.
90
+ */
91
+ private _highlightCode;
92
+ /**
93
+ * Get Prism grammar for the current language.
94
+ */
95
+ private _getGrammar;
96
+ /**
97
+ * Copy code to clipboard.
98
+ */
99
+ private _copyToClipboard;
100
+ /**
101
+ * Format URL for display (truncate if too long).
102
+ */
103
+ private _formatUrl;
104
+ }
105
+ //# sourceMappingURL=PdCodeSnippet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdCodeSnippet.d.ts","sourceRoot":"","sources":["../../src/pd-code-snippet/PdCodeSnippet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,cAAc,EAEd,UAAU,EAEV,cAAc,EACf,MAAM,KAAK,CAAC;AAMb,OAAO,qCAAqC,CAAC;AAC7C,OAAO,+BAA+B,CAAC;AACvC,OAAO,+BAA+B,CAAC;AACvC,OAAO,+BAA+B,CAAC;AACvC,OAAO,iCAAiC,CAAC;AACzC,OAAO,+BAA+B,CAAC;AACvC,OAAO,8BAA8B,CAAC;AACtC,OAAO,mCAAmC,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,YAAY,GACZ,MAAM,GACN,KAAK,GACL,MAAM,GACN,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,KAAK,GACL,UAAU,GACV,OAAO,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBAAa,aAAc,SAAQ,UAAU;IAC3C;;OAEG;IAEH,KAAK,SAAM;IAEX;;OAEG;IAEH,QAAQ,EAAE,YAAY,CAAgB;IAEtC;;OAEG;IAEH,GAAG,SAAM;IAET;;;OAGG;IAEH,IAAI,SAAM;IAEV;;OAEG;IAEH,eAAe,UAAS;IAExB;;;OAGG;IAEH,OAAO,CAAC,OAAO,CAAS;IAExB;;;OAGG;IAEH,OAAO,CAAC,SAAS,CAAM;IAEvB,OAAgB,MAAM,EAAE,cAAc,CAwRpC;IAEO,OAAO,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI;IAahD,MAAM;IA4Ff;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAazB;;OAEG;IACH,OAAO,CAAC,cAAc;IAyBtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAoBnB;;OAEG;YACW,gBAAgB;IAgB9B;;OAEG;IACH,OAAO,CAAC,UAAU;CASnB"}
@@ -0,0 +1,504 @@
1
+ import { LitElement, css, nothing, html } from 'lit';
2
+ import { property, state } from 'lit/decorators.js';
3
+ import Prism from '../_virtual/prism.js';
4
+ import '../_virtual/prism-typescript.js';
5
+ import '../node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-bash.js';
6
+ import '../node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-json.js';
7
+ import '../node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-yaml.js';
8
+ import '../_virtual/prism-python.js';
9
+ import '../_virtual/prism-java.js';
10
+ import '../node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-sql.js';
11
+ import '../node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-markdown.js';
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __decorateClass = (decorators, target, key, kind) => {
15
+ var result = void 0 ;
16
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
17
+ if (decorator = decorators[i])
18
+ result = (decorator(target, key, result) ) || result;
19
+ if (result) __defProp(target, key, result);
20
+ return result;
21
+ };
22
+ class PdCodeSnippet extends LitElement {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.title = "";
26
+ this.language = "javascript";
27
+ this.url = "";
28
+ this.code = "";
29
+ this.showLineNumbers = false;
30
+ this._copied = false;
31
+ this._slotCode = "";
32
+ }
33
+ static {
34
+ this.styles = [
35
+ css`
36
+ :host {
37
+ /* Layout */
38
+ --_width: var(--pd-code-snippet-width, 100%);
39
+ --_radius: var(
40
+ --pd-code-snippet-border-radius,
41
+ var(--pd-radius-md, 8px)
42
+ );
43
+ --_padding: var(--pd-code-snippet-padding, var(--pd-spacing-md, 1rem));
44
+
45
+ /* Typography */
46
+ --_font-family: var(
47
+ --pd-code-snippet-font-family,
48
+ "Fira Code",
49
+ "Consolas",
50
+ "Monaco",
51
+ monospace
52
+ );
53
+ --_font-size: var(--pd-code-snippet-font-size, 0.875rem);
54
+ --_line-height: var(--pd-code-snippet-line-height, 1.5);
55
+
56
+ /* Colors - Uses existing pd-default-* theme tokens with component-specific fallbacks */
57
+ --_bg-col: var(
58
+ --pd-code-snippet-bg-col,
59
+ var(--pd-default-bg-light-col, #f2f9fa)
60
+ );
61
+ --_text-col: var(
62
+ --pd-code-snippet-text-col,
63
+ var(--pd-default-font-content-col, #353738)
64
+ );
65
+ --_header-bg-col: var(
66
+ --pd-code-snippet-header-bg-col,
67
+ var(--pd-default-bg-dark-col, #e3f2f5)
68
+ );
69
+ --_header-col: var(
70
+ --pd-code-snippet-header-col,
71
+ var(--pd-default-font-col, #3c3c3b)
72
+ );
73
+ --_url-col: var(
74
+ --pd-code-snippet-url-col,
75
+ var(--pd-default-font-link-col, #067394)
76
+ );
77
+ --_border-col: var(
78
+ --pd-code-snippet-border-col,
79
+ var(--pd-default-light-col, #afc1d2)
80
+ );
81
+ --_line-number-col: var(
82
+ --pd-code-snippet-line-number-col,
83
+ var(--pd-default-font-muted-col, #6b7280)
84
+ );
85
+
86
+ /* Prism syntax token colors - light theme defaults */
87
+ --_token-comment: var(--pd-code-snippet-token-comment, #6a9955);
88
+ --_token-keyword: var(--pd-code-snippet-token-keyword, #0550ae);
89
+ --_token-string: var(--pd-code-snippet-token-string, #a31515);
90
+ --_token-number: var(--pd-code-snippet-token-number, #098658);
91
+ --_token-function: var(--pd-code-snippet-token-function, #795e26);
92
+ --_token-class: var(--pd-code-snippet-token-class, #267f99);
93
+ --_token-operator: var(--pd-code-snippet-token-operator, #1e1e1e);
94
+ --_token-punctuation: var(--pd-code-snippet-token-punctuation, #1e1e1e);
95
+ --_token-property: var(--pd-code-snippet-token-property, #0451a5);
96
+
97
+ display: block;
98
+ width: var(--_width);
99
+ }
100
+
101
+ .snippet-container {
102
+ border-radius: var(--_radius);
103
+ border: 1px solid var(--_border-col);
104
+ overflow: hidden;
105
+ background: var(--_bg-col);
106
+ }
107
+
108
+ /* Header */
109
+ .header {
110
+ display: flex;
111
+ align-items: center;
112
+ justify-content: space-between;
113
+ padding: 0.5rem var(--_padding);
114
+ background: var(--_header-bg-col);
115
+ border-bottom: 1px solid var(--_border-col);
116
+ min-height: 2.5rem;
117
+ box-sizing: border-box;
118
+ }
119
+
120
+ .title {
121
+ margin: 0;
122
+ font-size: 0.875rem;
123
+ font-weight: 500;
124
+ color: var(--_header-col);
125
+ font-family: var(--pd-default-font-content-family, inherit);
126
+ }
127
+
128
+ .language-badge {
129
+ font-size: 0.75rem;
130
+ color: var(--_header-col);
131
+ opacity: 0.7;
132
+ text-transform: uppercase;
133
+ letter-spacing: 0.05em;
134
+ }
135
+
136
+ .header-actions {
137
+ display: flex;
138
+ align-items: center;
139
+ gap: 0.75rem;
140
+ }
141
+
142
+ /* Copy button */
143
+ .copy-button {
144
+ display: flex;
145
+ align-items: center;
146
+ gap: 0.25rem;
147
+ padding: 0.25rem 0.5rem;
148
+ border: 1px solid var(--_border-col);
149
+ border-radius: 4px;
150
+ background: transparent;
151
+ color: var(--_header-col);
152
+ font-size: 0.75rem;
153
+ cursor: pointer;
154
+ transition: all 0.2s ease;
155
+ }
156
+
157
+ .copy-button:hover {
158
+ background: var(--pd-default-hover-col, #ffc857);
159
+ color: var(--pd-on-secondary-col, #0a3a48);
160
+ border-color: var(--pd-default-hover-col, #ffc857);
161
+ }
162
+
163
+ .copy-button:focus-visible {
164
+ outline: 2px solid var(--pd-focus-ring-col, #067394);
165
+ outline-offset: 2px;
166
+ }
167
+
168
+ .copy-button.copied {
169
+ color: var(--pd-default-success-col, #348b11);
170
+ border-color: var(--pd-default-success-col, #348b11);
171
+ }
172
+
173
+ .copy-icon {
174
+ width: 14px;
175
+ height: 14px;
176
+ fill: currentColor;
177
+ }
178
+
179
+ /* Code area */
180
+ .code-wrapper {
181
+ overflow-x: auto;
182
+ padding: var(--_padding);
183
+ }
184
+
185
+ pre {
186
+ margin: 0;
187
+ padding: 0;
188
+ background: transparent;
189
+ font-family: var(--_font-family);
190
+ font-size: var(--_font-size);
191
+ line-height: var(--_line-height);
192
+ color: var(--_text-col);
193
+ white-space: pre;
194
+ word-wrap: normal;
195
+ tab-size: 2;
196
+ }
197
+
198
+ code {
199
+ font-family: inherit;
200
+ background: transparent;
201
+ }
202
+
203
+ /* Line numbers */
204
+ :host([showLineNumbers]) .code-wrapper {
205
+ display: flex;
206
+ }
207
+
208
+ .line-numbers {
209
+ flex-shrink: 0;
210
+ padding-right: 1rem;
211
+ margin-right: 1rem;
212
+ border-right: 1px solid var(--_border-col);
213
+ color: var(--_line-number-col);
214
+ text-align: right;
215
+ user-select: none;
216
+ font-family: var(--_font-family);
217
+ font-size: var(--_font-size);
218
+ line-height: var(--_line-height);
219
+ }
220
+
221
+ /* URL footer */
222
+ .footer {
223
+ padding: 0.5rem var(--_padding);
224
+ background: var(--_header-bg-col);
225
+ border-top: 1px solid var(--_border-col);
226
+ }
227
+
228
+ .source-url {
229
+ display: flex;
230
+ align-items: center;
231
+ gap: 0.5rem;
232
+ font-size: 0.75rem;
233
+ color: var(--_header-col);
234
+ }
235
+
236
+ .source-url a {
237
+ color: var(--_url-col);
238
+ text-decoration: none;
239
+ word-break: break-all;
240
+ }
241
+
242
+ .source-url a:hover {
243
+ text-decoration: underline;
244
+ }
245
+
246
+ .link-icon {
247
+ width: 12px;
248
+ height: 12px;
249
+ fill: currentColor;
250
+ flex-shrink: 0;
251
+ }
252
+
253
+ /* Hidden slot for extracting text content */
254
+ .hidden-slot {
255
+ display: none;
256
+ }
257
+
258
+ /* Prism.js token styling */
259
+ .token.comment,
260
+ .token.prolog,
261
+ .token.doctype,
262
+ .token.cdata {
263
+ color: var(--_token-comment);
264
+ }
265
+
266
+ .token.punctuation {
267
+ color: var(--_token-punctuation);
268
+ }
269
+
270
+ .token.property,
271
+ .token.tag,
272
+ .token.boolean,
273
+ .token.number,
274
+ .token.constant,
275
+ .token.symbol,
276
+ .token.deleted {
277
+ color: var(--_token-number);
278
+ }
279
+
280
+ .token.selector,
281
+ .token.attr-name,
282
+ .token.string,
283
+ .token.char,
284
+ .token.builtin,
285
+ .token.inserted {
286
+ color: var(--_token-string);
287
+ }
288
+
289
+ .token.operator,
290
+ .token.entity,
291
+ .token.url,
292
+ .language-css .token.string,
293
+ .style .token.string {
294
+ color: var(--_token-operator);
295
+ }
296
+
297
+ .token.atrule,
298
+ .token.attr-value,
299
+ .token.keyword {
300
+ color: var(--_token-keyword);
301
+ }
302
+
303
+ .token.function,
304
+ .token.class-name {
305
+ color: var(--_token-function);
306
+ }
307
+
308
+ .token.regex,
309
+ .token.important,
310
+ .token.variable {
311
+ color: var(--_token-class);
312
+ }
313
+ `
314
+ ];
315
+ }
316
+ updated(changedProperties) {
317
+ super.updated(changedProperties);
318
+ if (changedProperties.has("code") || changedProperties.has("language") || changedProperties.has("_slotCode")) {
319
+ this._highlightCode();
320
+ }
321
+ }
322
+ render() {
323
+ const codeContent = this.code || this._slotCode;
324
+ const lineCount = codeContent.split("\n").length;
325
+ return html`
326
+ <div class="snippet-container">
327
+ ${this.title || this.language !== "plain" ? html`
328
+ <div class="header">
329
+ <div class="title-area">
330
+ ${this.title ? html`<h4 class="title">${this.title}</h4>` : html`<span class="language-badge"
331
+ >${this.language}</span
332
+ >`}
333
+ </div>
334
+ <div class="header-actions">
335
+ ${this.title && this.language !== "plain" ? html`<span class="language-badge">${this.language}</span>` : nothing}
336
+ <button
337
+ class="copy-button ${this._copied ? "copied" : ""}"
338
+ @click=${this._copyToClipboard}
339
+ aria-label="Copy code to clipboard"
340
+ >
341
+ ${this._copied ? html`
342
+ <svg class="copy-icon" viewBox="0 0 24 24">
343
+ <path
344
+ d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
345
+ />
346
+ </svg>
347
+ Copied
348
+ ` : html`
349
+ <svg class="copy-icon" viewBox="0 0 24 24">
350
+ <path
351
+ d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
352
+ />
353
+ </svg>
354
+ Copy
355
+ `}
356
+ </button>
357
+ </div>
358
+ </div>
359
+ ` : nothing}
360
+
361
+ <div class="code-wrapper">
362
+ ${this.showLineNumbers ? html`
363
+ <div class="line-numbers" aria-hidden="true">
364
+ ${Array.from(
365
+ { length: lineCount },
366
+ (_, i) => html`${i + 1}<br />`
367
+ )}
368
+ </div>
369
+ ` : nothing}
370
+ <pre><code id="code-block"></code></pre>
371
+ </div>
372
+
373
+ ${this.url ? html`
374
+ <div class="footer">
375
+ <div class="source-url">
376
+ <svg class="link-icon" viewBox="0 0 24 24">
377
+ <path
378
+ d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"
379
+ />
380
+ </svg>
381
+ <span>Source:</span>
382
+ <a
383
+ href="${this.url}"
384
+ target="_blank"
385
+ rel="noopener noreferrer"
386
+ >
387
+ ${this._formatUrl(this.url)}
388
+ </a>
389
+ </div>
390
+ </div>
391
+ ` : nothing}
392
+ </div>
393
+
394
+ <!-- Hidden slot to capture text content -->
395
+ <div class="hidden-slot">
396
+ <slot @slotchange=${this._handleSlotChange}></slot>
397
+ </div>
398
+ `;
399
+ }
400
+ /**
401
+ * Extract code from slotted content.
402
+ */
403
+ _handleSlotChange(e) {
404
+ const slot = e.target;
405
+ const nodes = slot.assignedNodes({ flatten: true });
406
+ const text = nodes.map((node) => node.textContent || "").join("").trim();
407
+ if (text && text !== this._slotCode) {
408
+ this._slotCode = text;
409
+ }
410
+ }
411
+ /**
412
+ * Apply syntax highlighting to the code.
413
+ */
414
+ _highlightCode() {
415
+ const codeBlock = this.shadowRoot?.getElementById("code-block");
416
+ if (!codeBlock) return;
417
+ const codeContent = this.code || this._slotCode;
418
+ if (!codeContent) {
419
+ codeBlock.textContent = "";
420
+ return;
421
+ }
422
+ const grammar = this._getGrammar();
423
+ if (grammar && this.language !== "plain") {
424
+ codeBlock.innerHTML = Prism.highlight(
425
+ codeContent,
426
+ grammar,
427
+ this.language
428
+ );
429
+ } else {
430
+ codeBlock.textContent = codeContent;
431
+ }
432
+ }
433
+ /**
434
+ * Get Prism grammar for the current language.
435
+ */
436
+ _getGrammar() {
437
+ const languageMap = {
438
+ javascript: "javascript",
439
+ typescript: "typescript",
440
+ html: "html",
441
+ css: "css",
442
+ json: "json",
443
+ bash: "bash",
444
+ yaml: "yaml",
445
+ python: "python",
446
+ java: "java",
447
+ sql: "sql",
448
+ markdown: "markdown",
449
+ plain: ""
450
+ };
451
+ const prismLang = languageMap[this.language];
452
+ return prismLang ? Prism.languages[prismLang] : null;
453
+ }
454
+ /**
455
+ * Copy code to clipboard.
456
+ */
457
+ async _copyToClipboard() {
458
+ const codeContent = this.code || this._slotCode;
459
+ try {
460
+ await navigator.clipboard.writeText(codeContent);
461
+ this._copied = true;
462
+ setTimeout(() => {
463
+ this._copied = false;
464
+ }, 2e3);
465
+ } catch (err) {
466
+ console.error("Failed to copy code:", err);
467
+ }
468
+ }
469
+ /**
470
+ * Format URL for display (truncate if too long).
471
+ */
472
+ _formatUrl(url) {
473
+ try {
474
+ const parsed = new URL(url);
475
+ const display = parsed.hostname + parsed.pathname;
476
+ return display.length > 50 ? display.substring(0, 47) + "..." : display;
477
+ } catch {
478
+ return url.length > 50 ? url.substring(0, 47) + "..." : url;
479
+ }
480
+ }
481
+ }
482
+ __decorateClass([
483
+ property({ type: String })
484
+ ], PdCodeSnippet.prototype, "title");
485
+ __decorateClass([
486
+ property({ type: String })
487
+ ], PdCodeSnippet.prototype, "language");
488
+ __decorateClass([
489
+ property({ type: String })
490
+ ], PdCodeSnippet.prototype, "url");
491
+ __decorateClass([
492
+ property({ type: String })
493
+ ], PdCodeSnippet.prototype, "code");
494
+ __decorateClass([
495
+ property({ type: Boolean })
496
+ ], PdCodeSnippet.prototype, "showLineNumbers");
497
+ __decorateClass([
498
+ state()
499
+ ], PdCodeSnippet.prototype, "_copied");
500
+ __decorateClass([
501
+ state()
502
+ ], PdCodeSnippet.prototype, "_slotCode");
503
+
504
+ export { PdCodeSnippet };
@@ -0,0 +1,4 @@
1
+ import { PdCodeSnippet } from './PdCodeSnippet.js';
2
+ export { PdCodeSnippet };
3
+ export type { CodeLanguage } from './PdCodeSnippet.js';
4
+ //# sourceMappingURL=pd-code-snippet.d.ts.map