File size: 16,875 Bytes
951c359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<script lang="ts">
  import { createEventDispatcher } from "svelte";
  import { sampleDatasets } from "./sampleData";

  const dispatch = createEventDispatcher();

  export let selectedDataset = "basic";
  export let currentTheme = "default";
  export let editable = true;
  export let show_row_numbers = true;
  export let show_search: "none" | "search" | "filter" = "search";
  export let show_copy_button = true;
  export let show_fullscreen_button = true;
  export let show_label = true;
  export let label = "Sample Data";
  export let max_height = 500;
  export let line_breaks = true;
  export let wrap = false;
  export let max_chars: number | undefined = undefined;

  // Controls panel state
  let activeControlsTab = "properties"; // "properties" or "actions"

  function switchDataset(dataset: string) {
    selectedDataset = dataset;
    dispatch('datasetChange', { dataset });
  }

  function applyTheme(theme: string) {
    currentTheme = theme;
    dispatch('themeChange', { theme });
  }

  function addCustomColumn() {
    dispatch('addColumn');
  }

  function addCustomRow() {
    dispatch('addRow');
  }
</script>

<!-- Storybook Controls Panel -->
<div class="h-full flex flex-col w-full">
  <!-- Controls Tab Header -->
  <div class="p-4 border-b-2 border-[#e0e0e0] bg-[#f8fafc]">
    <div class="flex items-center justify-between">
      <h2 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider">Controls</h2>
      <div class="flex space-x-4">
        <button 
          on:click={() => activeControlsTab = "properties"}
          class="flex items-center py-2.5 !px-4 text-sm font-medium transition-all duration-200 rounded-lg 
                 {activeControlsTab === 'properties' 
                   ? 'text-[#F87701] bg-white border border-[#F87701]' 
                   : 'text-[#64748b] hover:text-[#F87701] hover:bg-white/50 border border-transparent'}"
        >
          <span class="mr-2">⚙️</span>
          Properties
        </button>
        <button 
          on:click={() => activeControlsTab = "actions"}
          class="flex items-center py-2.5 !px-4 text-sm font-medium transition-all duration-200 rounded-lg
                 {activeControlsTab === 'actions' 
                   ? 'text-[#F87701] bg-white border border-[#F87701]' 
                   : 'text-[#64748b] hover:text-[#F87701] hover:bg-white/50 border border-transparent'}"
        >
          <span class="mr-2">📝</span>
          Actions
        </button>
      </div>
    </div>
  </div>

  <!-- Controls Content -->
  <div class="flex-1 overflow-x-scroll overflow-y-scroll p-4 min-h-0">
    
    {#if activeControlsTab === "properties"}
      <!-- Properties Tab Content -->
      <div class="flex space-x-8 min-w-max">
        
        <!-- Boolean Controls -->
        <div class="min-w-[300px]">
          <h4 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider mb-4">Display</h4>
      
      <div class="space-y-4">
        <label class="flex items-center justify-between py-3 px-3 hover:bg-[#f6f9fc] rounded-lg transition-all duration-200">
          <span class="text-[14px] text-[#2e3438]">editable</span>
          <input 
            type="checkbox" 
            bind:checked={editable} 
            class="w-5 h-5 rounded border-[#e0e0e0] text-[#F87701] focus:ring-[#F87701] focus:ring-2 bg-white"
          >
        </label>

        <label class="flex items-center justify-between py-3 px-3 hover:bg-[#f6f9fc] rounded-lg transition-all duration-200">
          <span class="text-[14px] text-[#2e3438]">show_row_numbers</span>
          <input 
            type="checkbox" 
            bind:checked={show_row_numbers} 
            class="w-5 h-5 rounded border-[#e0e0e0] text-[#F87701] focus:ring-[#F87701] focus:ring-2 bg-white"
          >
        </label>

        <label class="flex items-center justify-between py-3 px-3 hover:bg-[#f6f9fc] rounded-lg transition-all duration-200">
          <span class="text-[14px] text-[#2e3438]">show_copy_button</span>
          <input 
            type="checkbox" 
            bind:checked={show_copy_button} 
            class="w-5 h-5 rounded border-[#e0e0e0] text-[#F87701] focus:ring-[#F87701] focus:ring-2 bg-white"
          >
        </label>

        <label class="flex items-center justify-between py-3 px-3 hover:bg-[#f6f9fc] rounded-lg transition-all duration-200">
          <span class="text-[14px] text-[#2e3438]">show_fullscreen_button</span>
          <input 
            type="checkbox" 
            bind:checked={show_fullscreen_button} 
            class="w-5 h-5 rounded border-[#e0e0e0] text-[#F87701] focus:ring-[#F87701] focus:ring-2 bg-white"
          >
        </label>

        <label class="flex items-center justify-between py-3 px-3 hover:bg-[#f6f9fc] rounded-lg transition-all duration-200">
          <span class="text-[14px] text-[#2e3438]">show_label</span>
          <input 
            type="checkbox" 
            bind:checked={show_label} 
            class="w-5 h-5 rounded border-[#e0e0e0] text-[#F87701] focus:ring-[#F87701] focus:ring-2 bg-white"
          >
        </label>

        <label class="flex items-center justify-between py-3 px-3 hover:bg-[#f6f9fc] rounded-lg transition-all duration-200">
          <span class="text-[14px] text-[#2e3438]">line_breaks</span>
          <input 
            type="checkbox" 
            bind:checked={line_breaks} 
            class="w-5 h-5 rounded border-[#e0e0e0] text-[#F87701] focus:ring-[#F87701] focus:ring-2 bg-white"
          >
        </label>

        <label class="flex items-center justify-between py-3 px-3 hover:bg-[#f6f9fc] rounded-lg transition-all duration-200">
          <span class="text-[14px] text-[#2e3438]">wrap</span>
          <input 
            type="checkbox" 
            bind:checked={wrap} 
            class="w-5 h-5 rounded border-[#e0e0e0] text-[#F87701] focus:ring-[#F87701] focus:ring-2 bg-white"
          >
        </label>
          </div>
        </div>

        <!-- Options Controls -->
        <div class="min-w-[250px]">
          <h4 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider mb-4">Options</h4>
      
      <div class="space-y-2">
        <label for="show-search" class="block text-sm font-medium text-[#374151] mb-2">Search Type</label>
        <div class="relative">
          <select 
            id="show-search"
            bind:value={show_search}
            class="w-full px-4 py-3 !rounded-sm text-sm border-2 border-[#e5e7eb] rounded-lg bg-[#f9fafb] text-[#374151] focus:ring-2 focus:ring-[#F87701] focus:border-[#F87701] focus:bg-white transition-all duration-200 appearance-none cursor-pointer shadow-sm"
          >
            <option value="none">None</option>
            <option value="search">Search</option>
            <option value="filter">Filter</option>
          </select>
          <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
            <svg class="w-4 h-4 text-[#9ca3af]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
            </svg>
          </div>
        </div>
        <p class="text-xs text-[#6b7280] mt-1">Configure search functionality</p>
          </div>
        </div>

        <!-- Number Controls -->
        <div class="min-w-[250px]">
          <h4 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider mb-4">Numbers</h4>
      
      <div class="space-y-6">
        <div class="space-y-2">
          <label for="max-height" class="block text-sm font-medium text-[#374151]">Maximum Height</label>
          <div class="relative">
            <input 
              id="max-height"
              type="number" 
              bind:value={max_height}
              min="200"
              max="1000"
              step="50"
              class="w-full px-4 py-3 text-sm !rounded-sm border-2 border-[#e5e7eb] rounded-lg bg-[#f9fafb] text-[#374151] focus:ring-2 focus:ring-[#F87701] focus:border-[#F87701] focus:bg-white transition-all duration-200 shadow-sm"
            >
            <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
              <span class="text-xs text-[#9ca3af] font-medium">px</span>
            </div>
          </div>
          <p class="text-xs text-[#6b7280]">Height constraint for the table (200-1000px)</p>
        </div>

        <div class="space-y-2">
          <label for="max-chars" class="block text-sm font-medium text-[#374151]">Character Limit</label>
          <input 
            id="max-chars"
            type="number" 
            bind:value={max_chars}
            min="10"
            max="1000"
            step="10"
            placeholder="No limit"
            class="w-full px-4 py-3 text-sm !rounded-sm border-2 border-[#e5e7eb] rounded-lg bg-[#f9fafb] text-[#374151] placeholder-[#9ca3af] focus:ring-2 focus:ring-[#F87701] focus:border-[#F87701] focus:bg-white transition-all duration-200 shadow-sm"
          >
          <p class="text-xs text-[#6b7280]">Maximum characters per cell (leave empty for no limit)</p>
        </div>
          </div>
        </div>

        <!-- Text Controls -->
        <div class="min-w-[250px]">
          <h4 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider mb-4">Text</h4>
      
      <div class="space-y-2">
        <label for="label-input" class="block text-sm font-medium text-[#374151]">Table Label</label>
        <div class="relative">
          <input 
            id="label-input"
            type="text" 
            bind:value={label}
            placeholder="Enter table label..."
            class="w-full px-4 py-3 text-sm !rounded-sm border-2 border-[#e5e7eb] rounded-lg bg-[#f9fafb] text-[#374151] placeholder-[#9ca3af] focus:ring-2 focus:ring-[#F87701] focus:border-[#F87701] focus:bg-white transition-all duration-200 shadow-sm"
          >
          <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
            <svg class="w-4 h-4 text-[#9ca3af]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a.997.997 0 01-1.414 0l-7-7A1.997 1.997 0 013 12V7a4 4 0 014-4z"></path>
            </svg>
          </div>
        </div>
          <p class="text-xs text-[#6b7280]">Display label shown above the dataframe</p>
        </div>
      </div>
      </div>

    {:else if activeControlsTab === "actions"}
      <!-- Actions Tab Content -->
      <div class="flex space-x-8 min-w-max">
        
        <!-- Data Manipulation Section -->
        <div class="min-w-[300px]">
        <div>
          <h4 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider mb-3">Data Manipulation</h4>
          <p class="text-sm text-[#64748b] mb-5 leading-relaxed">Add new rows and columns to the dataframe</p>
          
          <div class="grid grid-cols-1 gap-3">
            <button 
              on:click={addCustomColumn}
              class="flex items-center justify-center px-6 py-4 text-sm font-semibold bg-gradient-to-r from-[#F87701] to-[#0f8bda] text-white rounded-xl hover:from-[#0f8bda] hover:to-[#0569b5] focus:ring-2 focus:ring-[#F87701] focus:ring-offset-2 transition-all duration-200"
            >
              <svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5">
                <path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4"></path>
              </svg>
              Add Column
            </button>

            <button 
              on:click={addCustomRow}
              class="flex items-center justify-center px-6 py-4 text-sm font-semibold bg-gradient-to-r from-[#10b981] to-[#059669] text-white rounded-xl hover:from-[#059669] hover:to-[#047857] focus:ring-2 focus:ring-[#10b981] focus:ring-offset-2 transition-all duration-200"
            >
              <svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5">
                <path stroke-linecap="round" stroke-linejoin="round" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
              </svg>
              Add Row
            </button>
          </div>
        </div>

        <div class="border-t border-[#e2e8f0] pt-6">
          <h4 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider mb-3">Export Options</h4>
          <p class="text-sm text-[#64748b] mb-5 leading-relaxed">Export your data in different formats</p>
          
          <div class="grid grid-cols-1 gap-3">
            <button 
              class="flex items-center justify-center px-4 py-3 text-sm font-medium bg-[#f59e0b] text-white rounded-lg hover:bg-[#d97706] focus:ring-2 focus:ring-[#f59e0b] focus:ring-offset-2 transition-all duration-200 shadow-sm"
            >
              <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
              </svg>
              Export as CSV
            </button>

            <button 
              class="flex items-center justify-center px-4 py-3 text-sm font-medium bg-[#8b5cf6] text-white rounded-lg hover:bg-[#7c3aed] focus:ring-2 focus:ring-[#8b5cf6] focus:ring-offset-2 transition-all duration-200 shadow-sm"
            >
              <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
              </svg>
              Copy to Clipboard
            </button>
          </div>
          </div>
        </div>

        <!-- Export & Reset Actions -->
        <div class="min-w-[300px]">
          <h4 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider mb-3">Export Options</h4>
          <p class="text-sm text-[#64748b] mb-5 leading-relaxed">Export your data in different formats</p>
          
          <div class="grid grid-cols-1 gap-3 mb-6">
            <button 
              class="flex items-center justify-center px-5 py-3 text-sm font-semibold bg-gradient-to-r from-[#f59e0b] to-[#d97706] text-white rounded-xl hover:from-[#d97706] hover:to-[#b45309] focus:ring-2 focus:ring-[#f59e0b] focus:ring-offset-2 transition-all duration-200"
            >
              <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5">
                <path stroke-linecap="round" stroke-linejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
              </svg>
              Export CSV
            </button>
            
            <button 
              class="flex items-center justify-center px-5 py-3 text-sm font-semibold bg-gradient-to-r from-[#6366f1] to-[#4f46e5] text-white rounded-xl hover:from-[#4f46e5] hover:to-[#4338ca] focus:ring-2 focus:ring-[#6366f1] focus:ring-offset-2 transition-all duration-200"
            >
              <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5">
                <path stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
              </svg>
              Copy to Clipboard
            </button>
          </div>

          <div class="border-t border-[#e2e8f0] pt-4">
            <h4 class="text-xs font-bold text-[#2e3438] uppercase tracking-wider mb-3">Reset Actions</h4>
            <button 
              class="w-full flex items-center justify-center px-5 py-3 text-sm font-semibold bg-gradient-to-r from-[#ef4444] to-[#dc2626] text-white rounded-xl hover:from-[#dc2626] hover:to-[#b91c1c] focus:ring-2 focus:ring-[#ef4444] focus:ring-offset-2 transition-all duration-200"
            >
              <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5">
                <path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
              </svg>
              Reset Data
            </button>
          </div>
        </div>
      </div>
    {/if}
  </div>
</div>