Skip to content

Commit 2758b92

Browse files
committed
v0.1.9: Add Tree components, update React wrapper plugin
1 parent 71bff82 commit 2758b92

12 files changed

Lines changed: 51 additions & 136 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.1.9 (2025-12-19)
4+
- Added `Tree`, `TreeItem` components for hierarchical data display
5+
- Updated React wrapper plugin to support new file structure
6+
- Removed `CopyButton` component
7+
- Changed React wrapper output directory to `react-components`
8+
39
## 0.1.8 (2025-12-18)
410
- **Breaking Change**: Added `U` prefix to all component class names (e.g., `Alert``UAlert`)
511
- **Breaking Change**: Changed file naming convention
@@ -40,4 +46,4 @@
4046
- removed `toggle` method from theme utility.
4147

4248
## 0.1.0 (2025-11-12)
43-
- Initial library version release
49+
- Initial library version release

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Modern web components library built with Lit-Element for building reactive user interfaces.
44

5+
Visit our [Demo Site](https://components.iyulab.com) to explore all components and their features.
6+
57
## Installation
68

79
```bash
@@ -10,19 +12,10 @@ npm install @iyulab/components
1012

1113
## Usage
1214

13-
### Basic Import
14-
1515
```js
1616
import "@iyulab/components";
1717
```
1818

19-
## Links
20-
21-
- [GitHub Repository](https://github.com/iyulab/u-components)
22-
- [NPM Package](https://www.npmjs.com/package/@iyulab/components)
23-
24-
> 📝 **Note**: Demo site is coming soon!
25-
2619
## Core Dependencies
2720

2821
- [lit](https://www.npmjs.com/package/lit) - Fast web components framework

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@iyulab/components",
33
"description": "web-components library based on lit-element made by iyulab",
4-
"version": "0.1.8",
4+
"version": "0.1.9",
55
"keywords": [
66
"iyulab",
77
"components",

plugins/vite-plugin-react-wrapper.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,19 @@ function collectComponents(componentsDir: string): ComponentInfo[] {
115115

116116
// 디렉토리인 경우에만 처리
117117
if (stat.isDirectory()) {
118-
const indexPath = join(entryPath, 'index.ts');
118+
// U로 시작하는 .ts 파일 찾기 (예: UButton.ts, UTree.ts)
119+
const files = readdirSync(entryPath);
120+
const componentFile = files.find(f =>
121+
f.startsWith('U') &&
122+
f.endsWith('.ts') &&
123+
!f.includes('.component') &&
124+
!f.includes('.styles')
125+
);
119126

120-
if (existsSync(indexPath)) {
121-
const content = readFileSync(indexPath, 'utf-8');
122-
const componentInfo = parseComponentInfo(content, entry, indexPath);
127+
if (componentFile) {
128+
const filePath = join(entryPath, componentFile);
129+
const content = readFileSync(filePath, 'utf-8');
130+
const componentInfo = parseComponentInfo(content, entry, filePath, componentFile);
123131

124132
if (componentInfo) {
125133
components.push(componentInfo);
@@ -132,32 +140,35 @@ function collectComponents(componentsDir: string): ComponentInfo[] {
132140
}
133141

134142
/**
135-
* 컴포넌트 index.ts 파일에서 정보 추출
143+
* 컴포넌트 파일에서 정보 추출 (예: UButton.ts)
136144
*/
137-
function parseComponentInfo(content: string, folderName: string, filePath: string): ComponentInfo | null {
138-
// 클래스명 추출 (예: export { Button })
145+
function parseComponentInfo(content: string, folderName: string, filePath: string, fileName: string): ComponentInfo | null {
146+
// 클래스명 추출 (예: export { UButton })
139147
const exportMatch = content.match(/export\s*\{\s*([^}\s]+)\s*\}/);
140148
if (!exportMatch) {
141149
return null;
142150
}
143151

144-
const componentName = exportMatch[1]; // Button
145-
const reactName = `U${componentName}`; // UButton
152+
const componentName = exportMatch[1]; // UButton
153+
const reactName = componentName; // UButton (이미 U 접두사가 있음)
146154

147-
// 태그명 추출 (예: Button.define("u-button"))
155+
// 태그명 추출 (예: UButton.define("u-button"))
148156
const tagMatch = content.match(/\.define\s*\(\s*["']([^"']+)["']/);
149157
if (!tagMatch) {
150158
return null;
151159
}
152160

153161
const tagName = tagMatch[1]; // u-button
154162

163+
// 파일명에서 확장자 제거 (UButton.ts -> UButton)
164+
const fileBaseName = fileName.replace('.ts', '');
165+
155166
return {
156167
componentName,
157168
reactName,
158169
tagName,
159170
filePath,
160-
relativePath: `components/${folderName}`
171+
relativePath: `components/${folderName}/${fileBaseName}`
161172
};
162173
}
163174

@@ -173,8 +184,8 @@ function generateReactWrapper(
173184
const files: Array<{ path: string; size: number; gzipSize: number }> = [];
174185

175186
// import 경로 계산 (상대 경로)
176-
// dist/integrations/react/UButton.js 에서 dist/components/button/index.js 로 가는 경로
177-
const targetPath = resolve(outDir, '..', '..', relativePath, 'index.js');
187+
// dist/react-components/UButton.js 에서 dist/components/button/UButton.js 로 가는 경로
188+
const targetPath = resolve(outDir, '..', relativePath + '.js');
178189
let importPath = relative(outDir, targetPath).replace(/\\/g, '/');
179190

180191
// 상대 경로가 ./ 또는 ../로 시작하지 않으면 추가

src/components/copy-button/UCopyButton.component.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/components/copy-button/UCopyButton.styles.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/components/copy-button/UCopyButton.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/components/tree-item/UTreeItem.component.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export class UTreeItem extends BaseElement {
3636

3737
connectedCallback(): void {
3838
super.connectedCallback();
39-
this.setAttribute('role', 'treeitem');
4039
this.setAttribute('tabindex', this.disabled ? '-1' : '0');
4140
}
4241

@@ -45,16 +44,8 @@ export class UTreeItem extends BaseElement {
4544

4645
if (changedProperties.has('disabled')) {
4746
this.setAttribute('tabindex', this.disabled ? '-1' : '0');
48-
this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');
49-
}
50-
if (changedProperties.has('expanded')) {
51-
this.setAttribute('aria-expanded', this.expanded ? 'true' : 'false');
52-
}
53-
if (changedProperties.has('selected')) {
54-
this.setAttribute('aria-selected', this.selected ? 'true' : 'false');
5547
}
5648
if (changedProperties.has('level')) {
57-
this.setAttribute('aria-level', String(this.level + 1));
5849
this.headerEl.style.paddingLeft = `calc(${this.level} * var(--indent-size, 20px))`;
5950
}
6051
}
@@ -64,6 +55,7 @@ export class UTreeItem extends BaseElement {
6455
<div class="header" @click=${this.handleHeaderClick}>
6556
<u-icon class="expand-icon"
6657
?hidden=${this.leaf}
58+
lib="internal"
6759
name=${this.expanded ? 'chevron-down' : 'chevron-right'}
6860
></u-icon>
6961
<slot name="prefix"></slot>

src/components/tree/UTree.component.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export class UTree extends BaseElement {
1717

1818
private selectedItems: Set<UTreeItem> = new Set();
1919

20-
@queryAssignedElements({ selector: 'u-tree-item' })
21-
treeItems!: UTreeItem[];
20+
@queryAssignedElements({ flatten: false, selector: 'u-tree-item' })
21+
items!: UTreeItem[];
2222

2323
/** 트리가 비활성화 상태인지 여부입니다. */
2424
@property({ type: Boolean, reflect: true }) disabled: boolean = false;
@@ -29,7 +29,6 @@ export class UTree extends BaseElement {
2929

3030
connectedCallback(): void {
3131
super.connectedCallback();
32-
this.setAttribute('role', 'tree');
3332
this.addEventListener('u-select', this.handleItemSelect as EventListener);
3433
this.addEventListener('u-toggle', this.handleItemToggle as EventListener);
3534
}
@@ -72,12 +71,6 @@ export class UTree extends BaseElement {
7271
} else {
7372
this.selectedItems.delete(item);
7473
}
75-
76-
this.emit('u-tree-select', {
77-
value: item.value,
78-
item: item,
79-
selectedItems: Array.from(this.selectedItems)
80-
});
8174
}
8275

8376
/** 트리 항목 확장/축소 이벤트를 처리합니다. */
@@ -86,12 +79,6 @@ export class UTree extends BaseElement {
8679
e.stopPropagation();
8780
return;
8881
}
89-
90-
const item = e.detail.item as UTreeItem;
91-
this.emit('u-tree-toggle', {
92-
expanded: item.expanded,
93-
item: item
94-
});
9582
}
9683

9784
/**
@@ -114,7 +101,7 @@ export class UTree extends BaseElement {
114101
/**
115102
* 재귀적으로 모든 TreeItem을 가져옵니다.
116103
*/
117-
private getAllTreeItems(items: Element[] = this.treeItems): UTreeItem[] {
104+
private getAllTreeItems(items: Element[] = this.items): UTreeItem[] {
118105
let allItems: UTreeItem[] = [];
119106

120107
items.forEach((item) => {

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Components
22
export * from './components/alert/UAlert.js';
33
export * from './components/button/UButton.js';
4-
export * from './components/copy-button/UCopyButton.js';
54
export * from './components/dialog/UDialog.js';
65
export * from './components/divider/UDivider.js';
76
export * from './components/drawer/UDrawer.js';

0 commit comments

Comments
 (0)