/**!
 * Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto3";

option java_package = "com.snowflake.apps.streamlit";
option java_outer_classname = "ArrowProto";

message Arrow {
  // The serialized arrow dataframe
  bytes data = 1;
  // Pandas styler information
  Styler styler = 2;
  // DEPRECATED: Width in pixels. Use Element.width_config instead.
  uint32 width = 3 [deprecated=true];
  // DEPRECATED: Height in pixels. Use Element.height_config instead.
  uint32 height = 4 [deprecated=true];
  // DEPRECATED: Use Element.width_config.use_stretch instead.
  bool use_container_width = 5 [deprecated=true];
  // The id of the widget, this is required if the dataframe is editable
  string id = 6;
  // Column configuration as JSON
  string columns = 7;
  // Activate table editing
  EditingMode editing_mode = 8;
  // Deactivates editing
  bool disabled = 9;
  // The form ID of the widget, this is required if the dataframe is editable
  string form_id = 10;
  // Defines the order in which columns are displayed
  repeated string column_order = 11;
  // Activated dataframe selections events
  repeated SelectionMode selection_mode = 12;
  // Row height in pixels
  optional uint32 row_height = 13;
  // How to show borders around the table and between cells. Note that this property
  // is only used for `st.table` at the moment.
  BorderMode border_mode = 14;
  // Placeholder string used when rendering missing values (e.g. nulls, NaNs).
  optional string placeholder = 15;

  // Available editing modes:
  enum EditingMode {
    READ_ONLY = 0; // Read-only table.
    FIXED = 1; // Activates editing but only allow editing of existing cells.
    DYNAMIC = 2; // Activates editing and allow adding & deleting rows.
    ADD_ONLY = 3; // Activates editing and allow adding rows (no deleting).
    DELETE_ONLY = 4; // Activates editing and allow deleting rows (no adding).
  }

  // Available selection modes:
  enum SelectionMode {
    SINGLE_ROW = 0; // Only one row can be selected at a time.
    MULTI_ROW = 1; // Multiple rows can be selected at a time.
    SINGLE_COLUMN = 2; // Only one column can be selected at a time.
    MULTI_COLUMN = 3; // Multiple columns can be selected at a time.
    SINGLE_CELL = 4; // Only one cell can be selected at a time.
    MULTI_CELL = 5; // Multiple cells (continuous range) can be selected.
  }

  // Available border modes:
  enum BorderMode {
    ALL = 0; // Show borders around the table and between cells.
    NONE = 1; // Show no borders.
    HORIZONTAL = 2; // Show only horizontal borders between rows.
  }
}

message Styler {
  // The Styler's source UUID (if the user provided one), or the path-based
  // hash that we generate (if no source UUID was provided).
  string uuid = 1;

  // The table's caption.
  string caption = 2;

  // `styles` contains the CSS for the entire source table.
  string styles = 3;

  // display_values is another ArrowTable: a copy of the source table, but
  // with all the display values formatted to the user-specified rules.
  bytes display_values = 4;
}
